@@ -59,3 +59,45 @@ func TestCompileSketchWithPdeExtesnion(t *testing.T) {
59
59
require .Contains (t , string (stderr ), "Sketches with .pde extension are deprecated, please rename the following files to .ino:" )
60
60
require .Contains (t , string (stderr ), sketchFilePde .String ())
61
61
}
62
+
63
+ func TestCompileSketchWithMultipleMainFiles (t * testing.T ) {
64
+ env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
65
+ defer env .CleanUp ()
66
+
67
+ // Init the environment explicitly
68
+ _ , _ , err := cli .Run ("update" )
69
+ require .NoError (t , err )
70
+
71
+ // Install core to compile
72
+ _ ,
_ ,
err = cli .
Run (
"core" ,
"install" ,
"arduino:[email protected] " )
73
+ require .NoError (t , err )
74
+
75
+ sketchName := "CompileSketchMultipleMainFiles"
76
+ sketchPath := cli .SketchbookDir ().Join (sketchName )
77
+ fqbn := "arduino:avr:uno"
78
+
79
+ // Create a test sketch
80
+ _ , _ , err = cli .Run ("sketch" , "new" , sketchPath .String ())
81
+ require .NoError (t , err )
82
+
83
+ // Copy .ino sketch file to .pde
84
+ sketchFileIno := sketchPath .Join (sketchName + ".ino" )
85
+ sketchFilePde := sketchPath .Join (sketchName + ".pde" )
86
+ err = sketchFileIno .CopyTo (sketchFilePde )
87
+ require .NoError (t , err )
88
+
89
+ // Build sketch from folder
90
+ _ , stderr , err := cli .Run ("compile" , "--clean" , "-b" , fqbn , sketchPath .String ())
91
+ require .Error (t , err )
92
+ require .Contains (t , string (stderr ), "Error opening sketch: multiple main sketch files found" )
93
+
94
+ // Build sketch from .ino file
95
+ _ , stderr , err = cli .Run ("compile" , "--clean" , "-b" , fqbn , sketchFileIno .String ())
96
+ require .Error (t , err )
97
+ require .Contains (t , string (stderr ), "Error opening sketch: multiple main sketch files found" )
98
+
99
+ // Build sketch from .pde file
100
+ _ , stderr , err = cli .Run ("compile" , "--clean" , "-b" , fqbn , sketchFilePde .String ())
101
+ require .Error (t , err )
102
+ require .Contains (t , string (stderr ), "Error opening sketch: multiple main sketch files found" )
103
+ }
0 commit comments