@@ -19,6 +19,7 @@ import (
19
19
"testing"
20
20
21
21
"github.com/arduino/arduino-cli/internal/integrationtest"
22
+ "github.com/arduino/go-paths-helper"
22
23
"github.com/stretchr/testify/require"
23
24
)
24
25
@@ -38,3 +39,48 @@ func TestCompileWithoutFqbn(t *testing.T) {
38
39
_ , _ , err = cli .Run ("compile" )
39
40
require .Error (t , err )
40
41
}
42
+
43
+ func TestCompileErrorMessage (t * testing.T ) {
44
+ env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
45
+ defer env .CleanUp ()
46
+
47
+ // Init the environment explicitly
48
+ _ , _ , err := cli .Run ("core" , "update-index" )
49
+ require .NoError (t , err )
50
+
51
+ // Download latest AVR
52
+ _ , _ , err = cli .Run ("core" , "install" , "arduino:avr" )
53
+ require .NoError (t , err )
54
+
55
+ // Run a batch of bogus compile in a temp dir to check the error messages
56
+ tmp , err := paths .MkTempDir ("" , "tmp_dir" )
57
+ require .NoError (t , err )
58
+ defer tmp .RemoveAll ()
59
+ abcdef := tmp .Join ("ABCDEF" )
60
+ _ , stderr , err := cli .Run ("compile" , "-b" , "arduino:avr:uno" , abcdef .String ())
61
+ require .Error (t , err )
62
+ require .Contains (t , string (stderr ), "no such file or directory:" )
63
+ _ , stderr , err = cli .Run ("compile" , "-b" , "arduino:avr:uno" , abcdef .Join ("ABCDEF.ino" ).String ())
64
+ require .Error (t , err )
65
+ require .Contains (t , string (stderr ), "no such file or directory:" )
66
+ _ , stderr , err = cli .Run ("compile" , "-b" , "arduino:avr:uno" , abcdef .Join ("QWERTY" ).String ())
67
+ require .Error (t , err )
68
+ require .Contains (t , string (stderr ), "no such file or directory:" )
69
+
70
+ err = abcdef .Mkdir ()
71
+ require .NoError (t , err )
72
+ _ , stderr , err = cli .Run ("compile" , "-b" , "arduino:avr:uno" , abcdef .String ())
73
+ require .Error (t , err )
74
+ require .Contains (t , string (stderr ), "main file missing from sketch:" )
75
+ _ , stderr , err = cli .Run ("compile" , "-b" , "arduino:avr:uno" , abcdef .Join ("ABCDEF.ino" ).String ())
76
+ require .Error (t , err )
77
+ require .Contains (t , string (stderr ), "no such file or directory:" )
78
+
79
+ qwertyIno := abcdef .Join ("QWERTY.ino" )
80
+ f , err := qwertyIno .Create ()
81
+ require .NoError (t , err )
82
+ defer f .Close ()
83
+ _ , stderr , err = cli .Run ("compile" , "-b" , "arduino:avr:uno" , qwertyIno .String ())
84
+ require .Error (t , err )
85
+ require .Contains (t , string (stderr ), "main file missing from sketch:" )
86
+ }
0 commit comments