pyocd / pyOCD

Open source Python library for programming and debugging Arm Cortex-M microcontrollers
https://pyocd.io
Apache License 2.0
1.13k stars 483 forks source link

pack subcommand should return non-zero status on error #1130

Open ACleverDisguise opened 3 years ago

ACleverDisguise commented 3 years ago

pyocd pack --update generates one "ERRO" line in red and dozens of "WARN" lines. It returns a status of 0 (success). Errors and warnings should be non-zero for scripting purposes.

ACleverDisguise commented 3 years ago

This seems to be pack related. Other errors (including syntax errors in pack command lines) do the right thing, but pyocd pack --install booger also fails (for obvious reasons) without setting a correct status.

flit commented 3 years ago

pyocd pack --install not returning non-zero on install failure (and similar for pyocd pack --find) is clearly an issue.

However, pyocd pack --update is not so straightforward. The update does ultimately succeed. We could return non-zero status on any pack metadata fetch errors, but there will almost always be some of those (some silicon vendors are quite bad about this!). It's really only an error if the packs you care about are not fetched. Process status codes can't cleanly indicate partial failure.

This is ultimately a problem caused by cmsis-pack-manager (CPM) not returning any indication of success or failure. We need to extend the CPM API to provide this status before this can be resolved.

Btw, --update and --clean can be combined with --find or --install to fetch new metadata prior to looking for and possibly installing a pack.