@@ -125,6 +125,8 @@ yun.serial.disableDTR=true
125125 sketchWithPort := getSketchPath ("SketchWithDefaultPort" )
126126 sketchWithFQBN := getSketchPath ("SketchWithDefaultFQBN" )
127127 sketchWithPortAndFQBN := getSketchPath ("SketchWithDefaultPortAndFQBN" )
128+ sketchWithPortAndConfig := getSketchPath ("SketchWithDefaultPortAndConfig" )
129+ sketchWithPortAndConfigAndProfile := getSketchPath ("SketchWithDefaultPortAndConfigAndProfile" )
128130
129131 t .Run ("NoFlags" , func (t * testing.T ) {
130132 t .Run ("NoDefaultPortNoDefaultFQBN" , func (t * testing.T ) {
@@ -161,6 +163,30 @@ yun.serial.disableDTR=true
161163 require .Error (t , err )
162164 require .Contains (t , string (stderr ), "not an FQBN: broken_fqbn" )
163165 })
166+
167+ t .Run ("WithDefaultPortAndConfig" , func (t * testing.T ) {
168+ stdout , _ , err := cli .RunWithCustomInput (quitMonitor (), "monitor" , "--raw" , sketchWithPortAndConfig )
169+ require .NoError (t , err )
170+ require .Contains (t , string (stdout ), "Opened port: /dev/ttyDEF" )
171+ require .Contains (t , string (stdout ), "Configuration rts = on" )
172+ require .Contains (t , string (stdout ), "Configuration dtr = on" )
173+ require .Contains (t , string (stdout ), "Configuration baudrate = 57600" )
174+ require .Contains (t , string (stdout ), "Configuration bits = 9" )
175+ require .Contains (t , string (stdout ), "Configuration parity = none" )
176+ require .Contains (t , string (stdout ), "Configuration stop_bits = 1" )
177+ })
178+
179+ t .Run ("WithDefaultPortAndConfigAndProfile" , func (t * testing.T ) {
180+ stdout , _ , err := cli .RunWithCustomInput (quitMonitor (), "monitor" , "--raw" , sketchWithPortAndConfigAndProfile )
181+ require .NoError (t , err )
182+ require .Contains (t , string (stdout ), "Opened port: /dev/ttyDEF" )
183+ require .Contains (t , string (stdout ), "Configuration rts = on" )
184+ require .Contains (t , string (stdout ), "Configuration dtr = on" )
185+ require .Contains (t , string (stdout ), "Configuration baudrate = 57600" )
186+ require .Contains (t , string (stdout ), "Configuration bits = 9" )
187+ require .Contains (t , string (stdout ), "Configuration parity = none" )
188+ require .Contains (t , string (stdout ), "Configuration stop_bits = 1" )
189+ })
164190 })
165191
166192 t .Run ("WithPortFlag" , func (t * testing.T ) {
@@ -202,6 +228,30 @@ yun.serial.disableDTR=true
202228 require .Error (t , err )
203229 require .Contains (t , string (stderr ), "not an FQBN: broken_fqbn" )
204230 })
231+
232+ t .Run ("WithDefaultPortAndConfig" , func (t * testing.T ) {
233+ stdout , _ , err := cli .RunWithCustomInput (quitMonitor (), "monitor" , "-p" , "/dev/ttyARGS" , "--raw" , sketchWithPortAndConfig )
234+ require .NoError (t , err )
235+ require .Contains (t , string (stdout ), "Opened port: /dev/ttyARGS" )
236+ require .Contains (t , string (stdout ), "Configuration rts = on" )
237+ require .Contains (t , string (stdout ), "Configuration dtr = on" )
238+ require .Contains (t , string (stdout ), "Configuration baudrate = 57600" )
239+ require .Contains (t , string (stdout ), "Configuration bits = 9" )
240+ require .Contains (t , string (stdout ), "Configuration parity = none" )
241+ require .Contains (t , string (stdout ), "Configuration stop_bits = 1" )
242+ })
243+
244+ t .Run ("WithDefaultPortAndConfigAndProfile" , func (t * testing.T ) {
245+ stdout , _ , err := cli .RunWithCustomInput (quitMonitor (), "monitor" , "-p" , "/dev/ttyARGS" , "--raw" , sketchWithPortAndConfigAndProfile )
246+ require .NoError (t , err )
247+ require .Contains (t , string (stdout ), "Opened port: /dev/ttyARGS" )
248+ require .Contains (t , string (stdout ), "Configuration rts = on" )
249+ require .Contains (t , string (stdout ), "Configuration dtr = on" )
250+ require .Contains (t , string (stdout ), "Configuration baudrate = 57600" )
251+ require .Contains (t , string (stdout ), "Configuration bits = 9" )
252+ require .Contains (t , string (stdout ), "Configuration parity = none" )
253+ require .Contains (t , string (stdout ), "Configuration stop_bits = 1" )
254+ })
205255 })
206256
207257 t .Run ("WithFQBNFlag" , func (t * testing.T ) {
@@ -240,6 +290,30 @@ yun.serial.disableDTR=true
240290 require .Contains (t , string (stdout ), "Configuration rts = off" )
241291 require .Contains (t , string (stdout ), "Configuration dtr = on" )
242292 })
293+
294+ t .Run ("WithDefaultPortAndConfig" , func (t * testing.T ) {
295+ stdout , _ , err := cli .RunWithCustomInput (quitMonitor (), "monitor" , "-b" , "arduino:avr:uno" , "--raw" , "--profile" , "profile1" , sketchWithPortAndConfig )
296+ require .NoError (t , err )
297+ require .Contains (t , string (stdout ), "Opened port: /dev/ttyDEF" )
298+ require .Contains (t , string (stdout ), "Configuration rts = off" )
299+ require .Contains (t , string (stdout ), "Configuration dtr = on" )
300+ require .Contains (t , string (stdout ), "Configuration baudrate = 57600" )
301+ require .Contains (t , string (stdout ), "Configuration bits = 9" )
302+ require .Contains (t , string (stdout ), "Configuration parity = none" )
303+ require .Contains (t , string (stdout ), "Configuration stop_bits = 1" )
304+ })
305+
306+ t .Run ("WithDefaultPortAndConfigAndProfile" , func (t * testing.T ) {
307+ stdout , _ , err := cli .RunWithCustomInput (quitMonitor (), "monitor" , "-b" , "arduino:avr:uno" , "--raw" , "--profile" , "profile1" , sketchWithPortAndConfigAndProfile )
308+ require .NoError (t , err )
309+ require .Contains (t , string (stdout ), "Opened port: /dev/ttyDEF" )
310+ require .Contains (t , string (stdout ), "Configuration rts = off" )
311+ require .Contains (t , string (stdout ), "Configuration dtr = on" )
312+ require .Contains (t , string (stdout ), "Configuration baudrate = 57600" )
313+ require .Contains (t , string (stdout ), "Configuration bits = 9" )
314+ require .Contains (t , string (stdout ), "Configuration parity = none" )
315+ require .Contains (t , string (stdout ), "Configuration stop_bits = 1" )
316+ })
243317 })
244318
245319 t .Run ("WithPortAndFQBNFlags" , func (t * testing.T ) {
@@ -275,6 +349,30 @@ yun.serial.disableDTR=true
275349 require .Contains (t , string (stdout ), "Configuration dtr = on" )
276350 })
277351
352+ t .Run ("WithDefaultPortAndConfig" , func (t * testing.T ) {
353+ stdout , _ , err := cli .RunWithCustomInput (quitMonitor (), "monitor" , "-p" , "/dev/ttyARGS" , "-b" , "arduino:avr:uno" , "--raw" , sketchWithPortAndConfig )
354+ require .NoError (t , err )
355+ require .Contains (t , string (stdout ), "Opened port: /dev/ttyARGS" )
356+ require .Contains (t , string (stdout ), "Configuration rts = off" )
357+ require .Contains (t , string (stdout ), "Configuration dtr = on" )
358+ require .Contains (t , string (stdout ), "Configuration baudrate = 57600" )
359+ require .Contains (t , string (stdout ), "Configuration bits = 9" )
360+ require .Contains (t , string (stdout ), "Configuration parity = none" )
361+ require .Contains (t , string (stdout ), "Configuration stop_bits = 1" )
362+ })
363+
364+ t .Run ("WithDefaultPortAndConfigAndProfile" , func (t * testing.T ) {
365+ stdout , _ , err := cli .RunWithCustomInput (quitMonitor (), "monitor" , "-p" , "/dev/ttyARGS" , "-b" , "arduino:avr:uno" , "--raw" , sketchWithPortAndConfigAndProfile )
366+ require .NoError (t , err )
367+ require .Contains (t , string (stdout ), "Opened port: /dev/ttyARGS" )
368+ require .Contains (t , string (stdout ), "Configuration rts = off" )
369+ require .Contains (t , string (stdout ), "Configuration dtr = on" )
370+ require .Contains (t , string (stdout ), "Configuration baudrate = 57600" )
371+ require .Contains (t , string (stdout ), "Configuration bits = 9" )
372+ require .Contains (t , string (stdout ), "Configuration parity = none" )
373+ require .Contains (t , string (stdout ), "Configuration stop_bits = 1" )
374+ })
375+
278376 t .Run ("IgnoreProfile" , func (t * testing.T ) {
279377 stdout , _ , err := cli .RunWithCustomInput (quitMonitor (), "monitor" , "-p" , "/dev/ttyARGS" , "-b" , "arduino:avr:uno" , "--raw" , "--profile" , "profile1" , sketchWithPortAndFQBN )
280378 require .NoError (t , err )
@@ -283,4 +381,18 @@ yun.serial.disableDTR=true
283381 require .Contains (t , string (stdout ), "Configuration dtr = on" )
284382 })
285383 })
384+
385+ t .Run ("WithProfileFlags" , func (t * testing.T ) {
386+ t .Run ("NoOtherArgs" , func (t * testing.T ) {
387+ stdout , _ , err := cli .RunWithCustomInput (quitMonitor (), "monitor" , "-m" , "uno" , "--raw" , sketchWithPortAndConfigAndProfile )
388+ require .NoError (t , err )
389+ require .Contains (t , string (stdout ), "Opened port: /dev/ttyPROF" )
390+ require .Contains (t , string (stdout ), "Configuration rts = on" ) // This is taken from profile-installed AVR core (not patched by this test)
391+ require .Contains (t , string (stdout ), "Configuration dtr = on" )
392+ require .Contains (t , string (stdout ), "Configuration baudrate = 19200" )
393+ require .Contains (t , string (stdout ), "Configuration bits = 8" )
394+ require .Contains (t , string (stdout ), "Configuration parity = none" )
395+ require .Contains (t , string (stdout ), "Configuration stop_bits = 1" )
396+ })
397+ })
286398}
0 commit comments