nasa / fprime-tools

F´ Python tooling and helpers.
https://github.com/nasa/fprime
Apache License 2.0
21 stars 39 forks source link

Refactor build directory purging logic #194

Closed IvoBrandao closed 9 months ago

IvoBrandao commented 9 months ago
Related Issue(s) 2463
Has Unit Tests (y/n) n
Documentation Included (y/n) n

Change Description

This commit refactors the logic for purging the build directory in the run_fbuild_cli function. It now uses a try-except block to handle PermissionError exceptions when attempting to purge the build directory.

Rationale

Fixes Bug

Testing/Review Recommendations

For the testing I did a manual test, the procedure I followed was the following one:

  1. Execute `fprime-util generate
  2. Execute fprime-util build
  3. Change a file to immutable e.g sudo chattr +i build-fprime-automatic-native/lib/Linux/libFw_Buffer.a
  4. Execute fprime-util purge
  5. The output shows which file cannot be removed as shown below.
[INFO] Purge build directory at: <path>/fprime/testv1/build-fprime-automatic-native
Purge this directory? (yes/no) [yes]: yes
Error: Permission denied while purging <path>/fprime/testprj/build-fprime-automatic-native: [Errno 1] Operation not permitted: 'libFw_Buffer.a'

Future Work

Maybe unit tests, if necessary...