Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress compile summary stats if --quiet flag is set on compile. #2820

Merged
merged 10 commits into from
Jan 24, 2025

Conversation

cmaglie
Copy link
Member

@cmaglie cmaglie commented Jan 21, 2025

Please check if the PR fulfills these requirements

See how to contribute

  • The PR has no duplicates (please search among the Pull Requests
    before creating one)
  • The PR follows
    our contributing guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • UPGRADING.md has been updated with a migration guide (for breaking changes)
  • configuration.schema.json updated if new parameters are added.

What kind of change does this PR introduce?

  • It makes the compile output completely silent if the --quiet flag is specified and the compile has no errors.
  • It removes the recap table if the build is successful and no --verbose or --quiet flags have been provided.
  • Adds the -q shortcut to the --quiet flag
Command line A successful build shows A build with errors shows
arduino-cli compile Sketch size Sketch size, used libraries
arduino-cli compile -v Build commands, sketch size, used libraries Build commands, sketch size, used libraries
arduino-cli compile -q nothing Errors only

What is the current behavior?

$ arduino-cli compile -b arduino:samd:nano_33_iot
Sketch uses 11544 bytes (4%) of program storage space. Maximum is 262144 bytes.
Global variables use 3560 bytes (10%) of dynamic memory, leaving 29208 bytes for local variables. Maximum is 32768 bytes.

Used platform Version Path
arduino:samd  1.8.14  /home/cmaglie/.arduino15/packages/arduino/hardware/samd/1.8.14
$ arduino-cli compile -b arduino:samd:nano_33_iot --quiet
Sketch uses 11544 bytes (4%) of program storage space. Maximum is 262144 bytes.
Global variables use 3560 bytes (10%) of dynamic memory, leaving 29208 bytes for local variables. Maximum is 32768 bytes.

Used platform Version Path
arduino:samd  1.8.14  /home/cmaglie/.arduino15/packages/arduino/hardware/samd/1.8.14
$

What is the new behavior?

$ arduino-cli compile -b arduino:samd:nano_33_iot
Sketch uses 11544 bytes (4%) of program storage space. Maximum is 262144 bytes.
Global variables use 3560 bytes (10%) of dynamic memory, leaving 29208 bytes for local variables. Maximum is 32768 bytes.
$ arduino-cli compile -b arduino:samd:nano_33_iot -q
$

Does this PR introduce a breaking change, and is titled accordingly?

Other information

Fix #2796
Fix #2510

@cmaglie cmaglie self-assigned this Jan 21, 2025
@cmaglie cmaglie force-pushed the suppress_compile_stats branch from d6ded91 to 0c2d093 Compare January 21, 2025 12:01
@cmaglie cmaglie added type: enhancement Proposed improvement topic: code Related to content of the project itself labels Jan 21, 2025
Copy link

codecov bot commented Jan 21, 2025

Codecov Report

Attention: Patch coverage is 86.41975% with 11 lines in your changes missing coverage. Please review.

Project coverage is 67.72%. Comparing base (e9092cc) to head (17ced8f).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
...nal/arduino/builder/internal/preprocessor/ctags.go 57.14% 3 Missing ⚠️
...rnal/arduino/builder/internal/detector/detector.go 75.00% 1 Missing and 1 partial ⚠️
internal/arduino/builder/sketch.go 0.00% 0 Missing and 2 partials ⚠️
internal/arduino/builder/archive_compiled_files.go 50.00% 0 Missing and 1 partial ⚠️
internal/arduino/builder/linker.go 0.00% 0 Missing and 1 partial ⚠️
internal/arduino/builder/recipe.go 0.00% 0 Missing and 1 partial ⚠️
internal/arduino/builder/sizer.go 94.11% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2820      +/-   ##
==========================================
+ Coverage   67.69%   67.72%   +0.02%     
==========================================
  Files         238      238              
  Lines       22388    22406      +18     
==========================================
+ Hits        15156    15174      +18     
  Misses       6036     6036              
  Partials     1196     1196              
Flag Coverage Δ
unit 67.72% <86.41%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@alessio-perugini alessio-perugini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a dedicated integration test that assert this new behaviour?
If not I'm afraid that we should add one, especially in the case -q and -v is provided.

commands/service_compile.go Show resolved Hide resolved
internal/cli/compile/compile.go Show resolved Hide resolved
@cmaglie cmaglie force-pushed the suppress_compile_stats branch from 29a623a to 924bbb8 Compare January 23, 2025 12:52
@cmaglie cmaglie force-pushed the suppress_compile_stats branch from 924bbb8 to c9122eb Compare January 23, 2025 12:54
Because it has a better error message than the cobra-provided one:

  Can't use the following flags together: --quiet, --verbose

Instead of:

  Error: if any flags in the group [quiet verbose] are set none of the others can be; [quiet verbose] were all set
@cmaglie
Copy link
Member Author

cmaglie commented Jan 23, 2025

Do we have a dedicated integration test that assert this new behaviour?
If not I'm afraid that we should add one, especially in the case -q and -v is provided.

I've added the tests and they helped me to finally spot where the infamous \n in stderr was coming from!
I've also spotted another stderr contamination in the ctags launcher. Overall, it's good that we have those tests in place now.

@alessio-perugini
Copy link
Contributor

Also tested on my machine (linux) works 🥳

@cmaglie cmaglie merged commit 92fae9c into arduino:master Jan 24, 2025
98 checks passed
@cmaglie cmaglie deleted the suppress_compile_stats branch January 24, 2025 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
2 participants