From e22ff66a81c5d07b8d155d8e540f7a081e17295f Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Thu, 9 Jan 2025 14:49:04 +0100 Subject: [PATCH 1/3] Slightly refactored integration test --- .../integrationtest/compile_3/compile_test.go | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/internal/integrationtest/compile_3/compile_test.go b/internal/integrationtest/compile_3/compile_test.go index aabd30445d0..9b9cfc19c2f 100644 --- a/internal/integrationtest/compile_3/compile_test.go +++ b/internal/integrationtest/compile_3/compile_test.go @@ -107,7 +107,7 @@ func TestCompilerErrOutput(t *testing.T) { _, _, err := cli.Run("core", "install", "arduino:avr@1.8.5") require.NoError(t, err) - { + t.Run("Diagnostics", func(t *testing.T) { // prepare sketch sketch, err := paths.New("testdata", "blink_with_wrong_cpp").Abs() require.NoError(t, err) @@ -126,10 +126,11 @@ func TestCompilerErrOutput(t *testing.T) { "context": [ { "message": "In function 'void wrong()':" } ] } ]`) - } + }) + + t.Run("PreprocessorDiagnostics", func(t *testing.T) { + // Test the preprocessor errors are present in the diagnostics - // Test the preprocessor errors are present in the diagnostics - { // prepare sketch sketch, err := paths.New("testdata", "blink_with_wrong_include").Abs() require.NoError(t, err) @@ -148,14 +149,15 @@ func TestCompilerErrOutput(t *testing.T) { "message": "invalid preprocessing directive #wrong\n #wrong\n ^~~~~", } ]`) - } + }) + + t.Run("PreprocessorDiagnosticsWithLibErrors", func(t *testing.T) { + // Test the preprocessor errors are present in the diagnostics. + // In case we have 2 libraries: + // 1. one is missing + // 2. the other one is missing only from the first GCC run + // The diagnostics should report only 1 missing library. - // Test the preprocessor errors are present in the diagnostics. - // In case we have 2 libraries: - // 1. one is missing - // 2. the other one is missing only from the first GCC run - // The diagnostics should report only 1 missing library. - { // prepare sketch sketch, err := paths.New("testdata", "using_Wire_with_missing_lib").Abs() require.NoError(t, err) @@ -175,11 +177,12 @@ func TestCompilerErrOutput(t *testing.T) { "column": 10, } ]`) - } + }) + + t.Run("LibraryDiscoverFalseErrors", func(t *testing.T) { + // Check that library discover do not generate false errors + // https://github.com/arduino/arduino-cli/issues/2263 - // Check that library discover do not generate false errors - // https://github.com/arduino/arduino-cli/issues/2263 - { // prepare sketch sketch, err := paths.New("testdata", "using_Wire").Abs() require.NoError(t, err) @@ -191,7 +194,7 @@ func TestCompilerErrOutput(t *testing.T) { jsonOut.Query(".compiler_out").MustNotContain(`"fatal error"`) jsonOut.Query(".compiler_err").MustNotContain(`"fatal error"`) jsonOut.MustNotContain(`{ "diagnostics" : [] }`) - } + }) } func TestCompileRelativeLibraryPath(t *testing.T) { From fa37144ca17340dee2a2a5b3f156e91e99c4117b Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Thu, 9 Jan 2025 15:02:46 +0100 Subject: [PATCH 2/3] Added integration test --- .../integrationtest/compile_3/compile_test.go | 25 +++++++++++++++++++ .../blink_with_error_directive.ino | 1 + 2 files changed, 26 insertions(+) create mode 100644 internal/integrationtest/compile_3/testdata/blink_with_error_directive/blink_with_error_directive.ino diff --git a/internal/integrationtest/compile_3/compile_test.go b/internal/integrationtest/compile_3/compile_test.go index 9b9cfc19c2f..8e15b901c6d 100644 --- a/internal/integrationtest/compile_3/compile_test.go +++ b/internal/integrationtest/compile_3/compile_test.go @@ -195,6 +195,31 @@ func TestCompilerErrOutput(t *testing.T) { jsonOut.Query(".compiler_err").MustNotContain(`"fatal error"`) jsonOut.MustNotContain(`{ "diagnostics" : [] }`) }) + + t.Run("PreprocessorErrorsOnStderr", func(t *testing.T) { + // Test the preprocessor errors are present in the diagnostics + // when they are printed on stderr + + // prepare sketch + sketch, err := paths.New("testdata", "blink_with_error_directive").Abs() + require.NoError(t, err) + + // Run compile and catch err stream + out, _, err := cli.Run("compile", "-b", "arduino:avr:uno", "-v", "--json", sketch.String()) + require.Error(t, err) + jsonOut := requirejson.Parse(t, out) + jsonOut.Query(".compiler_out").MustNotContain(`"error:"`) + jsonOut.Query(".compiler_err").MustContain(`"error:"`) + jsonOut.Query(`.builder_result.diagnostics`).MustContain(` + [ + { + "severity": "ERROR", + "message": "#error void setup(){} void loop(){}\n #error void setup(){} void loop(){}\n ^~~~~", + "line": 1, + "column": 2 + } + ]`) + }) } func TestCompileRelativeLibraryPath(t *testing.T) { diff --git a/internal/integrationtest/compile_3/testdata/blink_with_error_directive/blink_with_error_directive.ino b/internal/integrationtest/compile_3/testdata/blink_with_error_directive/blink_with_error_directive.ino new file mode 100644 index 00000000000..02bc8b99521 --- /dev/null +++ b/internal/integrationtest/compile_3/testdata/blink_with_error_directive/blink_with_error_directive.ino @@ -0,0 +1 @@ +#error void setup(){} void loop(){} From 5810d620c787b65dde11bed28b3212169dc420a3 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Thu, 9 Jan 2025 15:03:15 +0100 Subject: [PATCH 3/3] Fixed output channel for stderr in sketch preprocessing --- internal/arduino/builder/preprocess_sketch.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/arduino/builder/preprocess_sketch.go b/internal/arduino/builder/preprocess_sketch.go index 86d7bd7e7e9..b7fe178db02 100644 --- a/internal/arduino/builder/preprocess_sketch.go +++ b/internal/arduino/builder/preprocess_sketch.go @@ -32,7 +32,7 @@ func (b *Builder) preprocessSketch(includes paths.PathList) error { if b.logger.Verbose() { b.logger.WriteStdout(result.Stdout()) } - b.logger.WriteStdout(result.Stderr()) + b.logger.WriteStderr(result.Stderr()) b.diagnosticStore.Parse(result.Args(), result.Stderr()) } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy