@@ -136,25 +136,36 @@ func TestUploadPropertiesComposition(t *testing.T) {
136136 programmer string
137137 burnBootloader bool
138138 expected string
139+ expected2 string
139140 }
140141
142+ cwdPath , err := paths .Getwd ()
143+ require .NoError (t , err )
144+ cwd := cwdPath .String ()
145+
141146 tests := []test {
142- // classic upload, requires port
143- {buildPath1 , "alice:avr:board1" , "port" , "" , false , "conf-board1 conf-general conf-upload $$VERBOSE-VERIFY$$ protocol port -bspeed testdata/build_path_1/sketch.ino.hex" },
144- {buildPath1 , "alice:avr:board1" , "" , "" , false , "FAIL" },
145- // classic upload, no port
146- {buildPath1 , "alice:avr:board2" , "port" , "" , false , "conf-board1 conf-general conf-upload $$VERBOSE-VERIFY$$ protocol -bspeed testdata/build_path_1/sketch.ino.hex" },
147- {buildPath1 , "alice:avr:board2" , "" , "" , false , "conf-board1 conf-general conf-upload $$VERBOSE-VERIFY$$ protocol -bspeed testdata/build_path_1/sketch.ino.hex" },
148-
149- // upload with programmer, requires port
150- {buildPath1 , "alice:avr:board1" , "port" , "progr1" , false , "conf-board1 conf-general conf-program $$VERBOSE-VERIFY$$ progprotocol port -bspeed testdata/build_path_1/sketch.ino.hex" },
151- {buildPath1 , "alice:avr:board1" , "" , "progr1" , false , "FAIL" },
152- // upload with programmer, no port
153- {buildPath1 , "alice:avr:board1" , "port" , "progr2" , false , "conf-board1 conf-general conf-program $$VERBOSE-VERIFY$$ prog2protocol -bspeed testdata/build_path_1/sketch.ino.hex" },
154- {buildPath1 , "alice:avr:board1" , "" , "progr2" , false , "conf-board1 conf-general conf-program $$VERBOSE-VERIFY$$ prog2protocol -bspeed testdata/build_path_1/sketch.ino.hex" },
155- // upload with programmer, require port through extra params
156- {buildPath1 , "alice:avr:board1" , "port" , "progr3" , false , "conf-board1 conf-general conf-program $$VERBOSE-VERIFY$$ prog3protocol port -bspeed testdata/build_path_1/sketch.ino.hex" },
157- {buildPath1 , "alice:avr:board1" , "" , "progr3" , false , "FAIL" },
147+ // 0: classic upload, requires port
148+ {buildPath1 , "alice:avr:board1" , "port" , "" , false , "conf-board1 conf-general conf-upload $$VERBOSE-VERIFY$$ protocol port -bspeed testdata/build_path_1/sketch.ino.hex" , "" },
149+ {buildPath1 , "alice:avr:board1" , "" , "" , false , "FAIL" , "" },
150+ // 2: classic upload, no port
151+ {buildPath1 , "alice:avr:board2" , "port" , "" , false , "conf-board1 conf-general conf-upload $$VERBOSE-VERIFY$$ protocol -bspeed testdata/build_path_1/sketch.ino.hex" , "" },
152+ {buildPath1 , "alice:avr:board2" , "" , "" , false , "conf-board1 conf-general conf-upload $$VERBOSE-VERIFY$$ protocol -bspeed testdata/build_path_1/sketch.ino.hex" , "" },
153+
154+ // 4: upload with programmer, requires port
155+ {buildPath1 , "alice:avr:board1" , "port" , "progr1" , false , "conf-board1 conf-general conf-program $$VERBOSE-VERIFY$$ progprotocol port -bspeed testdata/build_path_1/sketch.ino.hex" , "" },
156+ {buildPath1 , "alice:avr:board1" , "" , "progr1" , false , "FAIL" , "" },
157+ // 6: upload with programmer, no port
158+ {buildPath1 , "alice:avr:board1" , "port" , "progr2" , false , "conf-board1 conf-general conf-program $$VERBOSE-VERIFY$$ prog2protocol -bspeed testdata/build_path_1/sketch.ino.hex" , "" },
159+ {buildPath1 , "alice:avr:board1" , "" , "progr2" , false , "conf-board1 conf-general conf-program $$VERBOSE-VERIFY$$ prog2protocol -bspeed testdata/build_path_1/sketch.ino.hex" , "" },
160+ // 8: upload with programmer, require port through extra params
161+ {buildPath1 , "alice:avr:board1" , "port" , "progr3" , false , "conf-board1 conf-general conf-program $$VERBOSE-VERIFY$$ prog3protocol port -bspeed testdata/build_path_1/sketch.ino.hex" , "" },
162+ {buildPath1 , "alice:avr:board1" , "" , "progr3" , false , "FAIL" , "" },
163+
164+ // 10: burn bootloader, require port
165+ {buildPath1 , "alice:avr:board1" , "port" , "" , true , "FAIL" , "" }, // requires programmer
166+ {buildPath1 , "alice:avr:board1" , "port" , "progr1" , true ,
167+ "ERASE conf-board1 conf-general conf-erase $$VERBOSE-VERIFY$$ genprog1protocol port -bspeed" ,
168+ "BURN conf-board1 conf-general conf-bootloader $$VERBOSE-VERIFY$$ genprog1protocol port -bspeed -F0xFF " + cwd + "/testdata/hardware/alice/avr/bootloaders/niceboot/niceboot.hex" },
158169 }
159170 for i , test := range tests {
160171 t .Run (fmt .Sprintf ("SubTest%02d" , i ), func (t * testing.T ) {
@@ -178,8 +189,19 @@ func TestUploadPropertiesComposition(t *testing.T) {
178189 require .Error (t , err )
179190 } else {
180191 require .NoError (t , err )
181- out := strings .TrimSpace (outStream .String ())
182- require .Equal (t , strings .ReplaceAll (test .expected , "$$VERBOSE-VERIFY$$" , "quiet noverify" ), out )
192+ out := strings .Split (outStream .String (), "\n " )
193+ // With verbose disable, the upload will output at least 2 lines:
194+ // - the output of the command (1 or 2 lines)
195+ // - an empty line
196+ if test .expected2 != "" {
197+ require .Len (t , out , 3 )
198+ } else {
199+ require .Len (t , out , 2 )
200+ }
201+ require .Equal (t , strings .ReplaceAll (test .expected , "$$VERBOSE-VERIFY$$" , "quiet noverify" ), out [0 ])
202+ if test .expected2 != "" {
203+ require .Equal (t , strings .ReplaceAll (test .expected2 , "$$VERBOSE-VERIFY$$" , "quiet noverify" ), out [1 ])
204+ }
183205 }
184206 })
185207 t .Run (fmt .Sprintf ("SubTest%02d-WithVerifyAndVerbose" , i ), func (t * testing.T ) {
@@ -204,13 +226,21 @@ func TestUploadPropertiesComposition(t *testing.T) {
204226 } else {
205227 require .NoError (t , err )
206228 out := strings .Split (outStream .String (), "\n " )
207- // With verbose enabled, the upload will output 3 lines:
208- // - the command line that the cli is going to run
209- // - the output of the command
229+ // With verbose enabled, the upload will output at least 3 lines:
230+ // - the first command line that the cli is going to run
231+ // - the output of the first command
232+ // - OPTIONAL: the second command line that the cli is going to run
233+ // - OPTIONAL: the output of the second command
210234 // - an empty line
211- // we are interested in the second line
212- require .Len (t , out , 3 )
235+ if test .expected2 != "" {
236+ require .Len (t , out , 5 )
237+ } else {
238+ require .Len (t , out , 3 )
239+ }
213240 require .Equal (t , strings .ReplaceAll (test .expected , "$$VERBOSE-VERIFY$$" , "verbose verify" ), out [1 ])
241+ if test .expected2 != "" {
242+ require .Equal (t , strings .ReplaceAll (test .expected2 , "$$VERBOSE-VERIFY$$" , "verbose verify" ), out [3 ])
243+ }
214244 }
215245 })
216246 }
0 commit comments