Skip to content

Commit b64876c

Browse files
authored
[skip-changelog] regression: hide include-not-found errors during library discovery (#2267)
* regression: hide include-not-found errors during library discovery 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 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: 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. * Added integration test
1 parent 3bd60c6 commit b64876c

File tree

3 files changed

+29
-9
lines changed

3 files changed

+29
-9
lines changed

Diff for: internal/integrationtest/compile_3/compile_test.go

+25-8
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,32 @@ func TestCompilerErrOutput(t *testing.T) {
107107
_, _, err := cli.Run("core", "install", "arduino:[email protected]")
108108
require.NoError(t, err)
109109

110-
// prepare sketch
111-
sketch, err := paths.New("testdata", "blink_with_wrong_cpp").Abs()
112-
require.NoError(t, err)
110+
{
111+
// prepare sketch
112+
sketch, err := paths.New("testdata", "blink_with_wrong_cpp").Abs()
113+
require.NoError(t, err)
114+
115+
// Run compile and catch err stream
116+
out, _, err := cli.Run("compile", "-b", "arduino:avr:uno", "--format", "json", sketch.String())
117+
require.Error(t, err)
118+
compilerErr := requirejson.Parse(t, out).Query(".compiler_err")
119+
compilerErr.MustContain(`"error"`)
120+
}
113121

114-
// Run compile and catch err stream
115-
out, _, err := cli.Run("compile", "-b", "arduino:avr:uno", "--format", "json", sketch.String())
116-
require.Error(t, err)
117-
compilerErr := requirejson.Parse(t, out).Query(".compiler_err")
118-
compilerErr.MustContain(`"error"`)
122+
// Check that library discover do not generate false errors
123+
// https://github.com/arduino/arduino-cli/issues/2263
124+
{
125+
// prepare sketch
126+
sketch, err := paths.New("testdata", "using_Wire").Abs()
127+
require.NoError(t, err)
128+
129+
// Run compile and catch err stream
130+
out, _, err := cli.Run("compile", "-b", "arduino:avr:uno", "-v", "--format", "json", sketch.String())
131+
require.NoError(t, err)
132+
jsonOut := requirejson.Parse(t, out)
133+
jsonOut.Query(".compiler_out").MustNotContain(`"fatal error"`)
134+
jsonOut.Query(".compiler_err").MustNotContain(`"fatal error"`)
135+
}
119136
}
120137

121138
func TestCompileRelativeLibraryPath(t *testing.T) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#include <Wire.h>
2+
3+
void setup() {}
4+
void loop() {}

Diff for: legacy/builder/container_find_includes.go

-1
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,6 @@ func findIncludesUntilDone(ctx *types.Context, cache *includeCache, sourceFileQu
374374
preprocStdout, preprocStderr, preprocErr = preprocessor.GCC(sourcePath, targetFilePath, includeFolders, ctx.BuildProperties)
375375
if ctx.Verbose {
376376
ctx.WriteStdout(preprocStdout)
377-
ctx.WriteStdout(preprocStderr)
378377
}
379378
// Unwrap error and see if it is an ExitError.
380379
_, isExitErr := errors.Cause(preprocErr).(*exec.ExitError)

0 commit comments

Comments
 (0)