@@ -26,7 +26,9 @@ import (
26
26
"time"
27
27
28
28
"github.com/arduino/arduino-cli/arduino/builder/cpp"
29
+ "github.com/arduino/arduino-cli/internal/cli/feedback"
29
30
"github.com/arduino/arduino-cli/internal/integrationtest"
31
+ "github.com/arduino/arduino-cli/internal/integrationtest/assert"
30
32
"github.com/arduino/go-paths-helper"
31
33
"github.com/stretchr/testify/require"
32
34
"go.bug.st/testifyjson/requirejson"
@@ -91,21 +93,26 @@ func compileErrorMessage(t *testing.T, env *integrationtest.Environment, cli *in
91
93
_ , stderr , err := cli .Run ("compile" , "-b" , "arduino:avr:uno" , abcdef .String ())
92
94
require .Error (t , err )
93
95
require .Contains (t , string (stderr ), "no such file or directory:" )
96
+ assert .CmdExitCode (t , feedback .ErrSketchError , err )
94
97
_ , stderr , err = cli .Run ("compile" , "-b" , "arduino:avr:uno" , abcdef .Join ("ABCDEF.ino" ).String ())
95
98
require .Error (t , err )
96
99
require .Contains (t , string (stderr ), "no such file or directory:" )
100
+ assert .CmdExitCode (t , feedback .ErrSketchError , err )
97
101
_ , stderr , err = cli .Run ("compile" , "-b" , "arduino:avr:uno" , abcdef .Join ("QWERTY" ).String ())
98
102
require .Error (t , err )
99
103
require .Contains (t , string (stderr ), "no such file or directory:" )
104
+ assert .CmdExitCode (t , feedback .ErrSketchError , err )
100
105
101
106
err = abcdef .Mkdir ()
102
107
require .NoError (t , err )
103
108
_ , stderr , err = cli .Run ("compile" , "-b" , "arduino:avr:uno" , abcdef .String ())
104
109
require .Error (t , err )
105
110
require .Contains (t , string (stderr ), "main file missing from sketch:" )
111
+ assert .CmdExitCode (t , feedback .ErrSketchError , err )
106
112
_ , stderr , err = cli .Run ("compile" , "-b" , "arduino:avr:uno" , abcdef .Join ("ABCDEF.ino" ).String ())
107
113
require .Error (t , err )
108
114
require .Contains (t , string (stderr ), "no such file or directory:" )
115
+ assert .CmdExitCode (t , feedback .ErrSketchError , err )
109
116
110
117
qwertyIno := abcdef .Join ("QWERTY.ino" )
111
118
f , err := qwertyIno .Create ()
@@ -114,6 +121,7 @@ func compileErrorMessage(t *testing.T, env *integrationtest.Environment, cli *in
114
121
_ , stderr , err = cli .Run ("compile" , "-b" , "arduino:avr:uno" , qwertyIno .String ())
115
122
require .Error (t , err )
116
123
require .Contains (t , string (stderr ), "main file missing from sketch:" )
124
+ assert .CmdExitCode (t , feedback .ErrSketchError , err )
117
125
}
118
126
119
127
func compileWithSimpleSketch (t * testing.T , env * integrationtest.Environment , cli * integrationtest.ArduinoCLI ) {
@@ -228,6 +236,7 @@ func compileWithSketchWithSymlinkSelfloop(t *testing.T, env *integrationtest.Env
228
236
// returning a different error detailed message
229
237
require .Contains (t , string (stderr ), "Can't open sketch:" )
230
238
require .Error (t , err )
239
+ assert .CmdExitCode (t , feedback .ErrSketchError , err )
231
240
}
232
241
{
233
242
sketchName := "CompileIntegrationTestSymlinkDirLoop"
@@ -254,6 +263,7 @@ func compileWithSketchWithSymlinkSelfloop(t *testing.T, env *integrationtest.Env
254
263
// returning a different error detailed message
255
264
require .Contains (t , string (stderr ), "Can't open sketch:" )
256
265
require .Error (t , err )
266
+ assert .CmdExitCode (t , feedback .ErrSketchError , err )
257
267
}
258
268
}
259
269
@@ -349,6 +359,7 @@ func compileWithMultipleBuildPropertyFlags(t *testing.T, env *integrationtest.En
349
359
sketchPath .String (), "--verbose" , "--clean" ,
350
360
)
351
361
require .Error (t , err )
362
+ assert .CmdExitCode (t , feedback .ErrCompilation , err )
352
363
353
364
// Compile using multiple build properties separated by a space and properly quoted
354
365
stdout , _ , err := cli .Run (
@@ -366,6 +377,7 @@ func compileWithMultipleBuildPropertyFlags(t *testing.T, env *integrationtest.En
366
377
sketchPath .String (), "--verbose" , "--clean" ,
367
378
)
368
379
require .Error (t , err )
380
+ assert .CmdExitCode (t , feedback .ErrCompilation , err )
369
381
370
382
stdout , _ , err = cli .Run (
371
383
"compile" , "-b" , fqbn ,
@@ -376,6 +388,7 @@ func compileWithMultipleBuildPropertyFlags(t *testing.T, env *integrationtest.En
376
388
require .Error (t , err )
377
389
require .NotContains (t , string (stdout ), "-DPIN=2" )
378
390
require .Contains (t , string (stdout ), "-DSSID=\\ \" This is a String\\ \" " )
391
+ assert .CmdExitCode (t , feedback .ErrCompilation , err )
379
392
380
393
stdout , _ , err = cli .Run (
381
394
"compile" , "-b" , fqbn ,
@@ -621,16 +634,19 @@ func compileWithMultipleMainFiles(t *testing.T, env *integrationtest.Environment
621
634
_ , stderr , err := cli .Run ("compile" , "--clean" , "-b" , fqbn , sketchPath .String ())
622
635
require .Error (t , err )
623
636
require .Contains (t , string (stderr ), "Can't open sketch: multiple main sketch files found" )
637
+ assert .CmdExitCode (t , feedback .ErrSketchError , err )
624
638
625
639
// Build sketch from .ino file
626
640
_ , stderr , err = cli .Run ("compile" , "--clean" , "-b" , fqbn , sketchFileIno .String ())
627
641
require .Error (t , err )
628
642
require .Contains (t , string (stderr ), "Can't open sketch: multiple main sketch files found" )
643
+ assert .CmdExitCode (t , feedback .ErrSketchError , err )
629
644
630
645
// Build sketch from .pde file
631
646
_ , stderr , err = cli .Run ("compile" , "--clean" , "-b" , fqbn , sketchFilePde .String ())
632
647
require .Error (t , err )
633
648
require .Contains (t , string (stderr ), "Can't open sketch: multiple main sketch files found" )
649
+ assert .CmdExitCode (t , feedback .ErrSketchError , err )
634
650
}
635
651
636
652
func compileCaseMismatchFails (t * testing.T , env * integrationtest.Environment , cli * integrationtest.ArduinoCLI ) {
@@ -653,16 +669,19 @@ func compileCaseMismatchFails(t *testing.T, env *integrationtest.Environment, cl
653
669
_ , stderr , err := cli .Run ("compile" , "--clean" , "-b" , fqbn , sketchPath .String ())
654
670
require .Error (t , err )
655
671
require .Contains (t , string (stderr ), "Can't open sketch:" )
672
+ assert .CmdExitCode (t , feedback .ErrSketchError , err )
656
673
// * Compiling with sketch main file
657
674
_ , stderr , err = cli .Run ("compile" , "--clean" , "-b" , fqbn , sketchMainFile .String ())
658
675
require .Error (t , err )
659
676
require .Contains (t , string (stderr ), "Can't open sketch:" )
677
+ assert .CmdExitCode (t , feedback .ErrSketchError , err )
660
678
// * Compiling in sketch path
661
679
cli .SetWorkingDir (sketchPath )
662
680
defer cli .SetWorkingDir (env .RootDir ())
663
681
_ , stderr , err = cli .Run ("compile" , "--clean" , "-b" , fqbn )
664
682
require .Error (t , err )
665
683
require .Contains (t , string (stderr ), "Can't open sketch:" )
684
+ assert .CmdExitCode (t , feedback .ErrSketchError , err )
666
685
}
667
686
668
687
func compileOnlyCompilationDatabaseFlag (t * testing.T , env * integrationtest.Environment , cli * integrationtest.ArduinoCLI ) {
@@ -721,6 +740,7 @@ func compileUsingPlatformLocalTxt(t *testing.T, env *integrationtest.Environment
721
740
_ , stderr , err := cli .Run ("compile" , "--clean" , "-b" , fqbn , sketchPath .String ())
722
741
require .Error (t , err )
723
742
require .Contains (t , string (stderr ), "my-compiler-that-does-not-exist" )
743
+ assert .CmdExitCode (t , feedback .ErrCompilation , err )
724
744
}
725
745
726
746
func compileUsingBoardsLocalTxt (t * testing.T , env * integrationtest.Environment , cli * integrationtest.ArduinoCLI ) {
@@ -737,6 +757,7 @@ func compileUsingBoardsLocalTxt(t *testing.T, env *integrationtest.Environment,
737
757
_ , stderr , err := cli .Run ("compile" , "--clean" , "-b" , fqbn , sketchPath .String ())
738
758
require .Error (t , err )
739
759
require .Contains (t , string (stderr ), "Error during build: Invalid FQBN: board arduino:avr:nessuno not found" )
760
+ assert .CmdExitCode (t , feedback .ErrCompilation , err )
740
761
741
762
// Use custom boards.local.txt with made arduino:avr:nessuno board
742
763
boardsLocalTxt := cli .DataDir ().Join ("packages" , "arduino" , "hardware" , "avr" , "1.8.5" , "boards.local.txt" )
@@ -999,6 +1020,7 @@ func TestCompileManuallyInstalledPlatformUsingPlatformLocalTxt(t *testing.T) {
999
1020
_ , stderr , err := cli .Run ("compile" , "--clean" , "-b" , fqbn , sketchPath .String ())
1000
1021
require .Error (t , err )
1001
1022
require .Contains (t , string (stderr ), "my-compiler-that-does-not-exist" )
1023
+ assert .CmdExitCode (t , feedback .ErrCompilation , err )
1002
1024
}
1003
1025
1004
1026
func compileWithInvalidBuildOptionJson (t * testing.T , env * integrationtest.Environment , cli * integrationtest.ArduinoCLI ) {
@@ -1134,6 +1156,7 @@ func compileWithFakeSecureBootCore(t *testing.T, env *integrationtest.Environmen
1134
1156
)
1135
1157
require .Error (t , err )
1136
1158
require .Contains (t , string (stderr ), "Flag --sign-key is mandatory when used in conjunction with: --keys-keychain, --sign-key, --encrypt-key" )
1159
+ assert .CmdExitCode (t , feedback .ErrBadArgument , err )
1137
1160
1138
1161
// Verifies compilation works with secure boot enabled and when overriding the sign key and encryption key used
1139
1162
keysDir := cli .SketchbookDir ().Join ("keys_dir" )
0 commit comments