@@ -141,6 +141,10 @@ func TestUploadPropertiesComposition(t *testing.T) {
141141 tests := []test {
142142 // classic upload, requires port
143143 {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" },
144148 }
145149 for i , test := range tests {
146150 t .Run (fmt .Sprintf ("SubTest%02d" , i ), func (t * testing.T ) {
@@ -160,9 +164,13 @@ func TestUploadPropertiesComposition(t *testing.T) {
160164 outStream ,
161165 errStream ,
162166 )
163- require .NoError (t , err )
164- out := strings .TrimSpace (outStream .String ())
165- require .Equal (t , strings .ReplaceAll (test .expected , "$$VERBOSE-VERIFY$$" , "quiet noverify" ), out )
167+ if test .expected == "FAIL" {
168+ require .Error (t , err )
169+ } else {
170+ require .NoError (t , err )
171+ out := strings .TrimSpace (outStream .String ())
172+ require .Equal (t , strings .ReplaceAll (test .expected , "$$VERBOSE-VERIFY$$" , "quiet noverify" ), out )
173+ }
166174 })
167175 t .Run (fmt .Sprintf ("SubTest%02d-WithVerifyAndVerbose" , i ), func (t * testing.T ) {
168176 outStream := & bytes.Buffer {}
@@ -181,15 +189,19 @@ func TestUploadPropertiesComposition(t *testing.T) {
181189 outStream ,
182190 errStream ,
183191 )
184- require .NoError (t , err )
185- out := strings .Split (outStream .String (), "\n " )
186- // With verbose enabled, the upload will output 3 lines:
187- // - the command line that the cli is going to run
188- // - the output of the command
189- // - an empty line
190- // we are interested in the second line
191- require .Len (t , out , 3 )
192- require .Equal (t , strings .ReplaceAll (test .expected , "$$VERBOSE-VERIFY$$" , "verbose verify" ), out [1 ])
192+ if test .expected == "FAIL" {
193+ require .Error (t , err )
194+ } else {
195+ require .NoError (t , err )
196+ out := strings .Split (outStream .String (), "\n " )
197+ // With verbose enabled, the upload will output 3 lines:
198+ // - the command line that the cli is going to run
199+ // - the output of the command
200+ // - an empty line
201+ // we are interested in the second line
202+ require .Len (t , out , 3 )
203+ require .Equal (t , strings .ReplaceAll (test .expected , "$$VERBOSE-VERIFY$$" , "verbose verify" ), out [1 ])
204+ }
193205 })
194206 }
195207}
0 commit comments