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

regression: hide include-not-found errors during library discovery #2267

Merged
merged 2 commits into from
Aug 18, 2023

Conversation

cmaglie
Copy link
Member

@cmaglie cmaglie commented Aug 17, 2023

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?

This regression was made during a refactoring of the Arduino preprocessor. In particular the wrong change was part of this commit: 0585435#diff-65ff16cbee816c0f443157444d99bcc144beee06c3329aec891894c8aeda7b27L372-R378

-                       preproc_stderr, preproc_err = GCCPreprocRunner(ctx, sourcePath, targetFilePath, includes)
+                       var preproc_stdout []byte
+                       preproc_stdout, preproc_stderr, preproc_err = preprocessor.GCC(sourcePath, targetFilePath, includes, ctx.BuildProperties)
+                       if ctx.Verbose {
+                               ctx.WriteStdout(preproc_stdout)
+                               ctx.WriteStdout(preproc_stderr)
+                       }

Previously GCCPreprocRunner, in verbose mode would show ONLY the stdout of the process, the "refactored" code wrongly added also stderr to the output.

For reference, this is the old GCCPreprocRunner implementation: 0585435#diff-371f93465ca5a66f01cbe876348f67990750091d27a827781c8633456b93ef3bL36

-func GCCPreprocRunner(ctx *types.Context, sourceFilePath *paths.Path, targetFilePath *paths.Path, includes paths.PathList) ([]byte, error) {
-       cmd, err := prepareGCCPreprocRecipeProperties(ctx, sourceFilePath, targetFilePath, includes)
-       if err != nil {
-               return nil, err
-       }
-       _, stderr, err := utils.ExecCommand(ctx, cmd, utils.ShowIfVerbose /* stdout */, utils.Capture /* stderr */)
-       return stderr, err
-}

This PR fixes the regression.

What is the current behavior?

Include not found errors are shown during library discovery in verbose compile. See #2263 for details.

What is the new behavior?

The spurious errors are not displayed anymore.

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

No

Other information

The regression has been introduced in #2194.
Fix #2263

This regression was made during a refactoring of the Arduino preprocessor.
In particular the wrong change was part of this commit:
arduino@0585435#diff-65ff16cbee816c0f443157444d99bcc144beee06c3329aec891894c8aeda7b27L372-R378

-                       preproc_stderr, preproc_err = GCCPreprocRunner(ctx, sourcePath, targetFilePath, includes)
+                       var preproc_stdout []byte
+                       preproc_stdout, preproc_stderr, preproc_err = preprocessor.GCC(sourcePath, targetFilePath, includes, ctx.BuildProperties)
+                       if ctx.Verbose {
+                               ctx.WriteStdout(preproc_stdout)
+                               ctx.WriteStdout(preproc_stderr)
+                       }

Previously GCCPreprocRunner, in verbose modem will show ONLY the stdout of
the process, instead the "refactored" code wrongly added also stderr to the
output.

For reference this is the old GCCPreprocRunner implementation:
arduino@0585435#diff-371f93465ca5a66f01cbe876348f67990750091d27a827781c8633456b93ef3bL36

-func GCCPreprocRunner(ctx *types.Context, sourceFilePath *paths.Path, targetFilePath *paths.Path, includes paths.PathList) ([]byte, error) {
-       cmd, err := prepareGCCPreprocRecipeProperties(ctx, sourceFilePath, targetFilePath, includes)
-       if err != nil {
-               return nil, err
-       }
-       _, stderr, err := utils.ExecCommand(ctx, cmd, utils.ShowIfVerbose /* stdout */, utils.Capture /* stderr */)
-       return stderr, err
-}

This commit fixes the regression.
@cmaglie cmaglie added priority: high Resolution is a high priority topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project criticality: highest Of highest impact labels Aug 17, 2023
@cmaglie cmaglie added this to the Arduino CLI 0.34.0 milestone Aug 17, 2023
@cmaglie cmaglie self-assigned this Aug 17, 2023
@codecov
Copy link

codecov bot commented Aug 17, 2023

Codecov Report

Patch coverage has no change and project coverage change: -0.01% ⚠️

Comparison is base (9510d61) 62.95% compared to head (38f33e6) 62.95%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2267      +/-   ##
==========================================
- Coverage   62.95%   62.95%   -0.01%     
==========================================
  Files         220      220              
  Lines       19546    19545       -1     
==========================================
- Hits        12305    12304       -1     
  Misses       6151     6151              
  Partials     1090     1090              
Flag Coverage Δ
unit 62.95% <ø> (-0.01%) ⬇️

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

Files Changed Coverage Δ
legacy/builder/container_find_includes.go 71.92% <ø> (-0.10%) ⬇️

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

@cmaglie cmaglie merged commit b64876c into arduino:master Aug 18, 2023
89 checks passed
@cmaglie cmaglie deleted the fix_regression_1 branch August 18, 2023 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
criticality: highest Of highest impact priority: high Resolution is a high priority topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Spurious "No such file or directory" errors printed in verbose compile output
2 participants