@@ -354,16 +354,19 @@ func (cli *ArduinoCLI) RunWithCustomInput(in io.Reader, args ...string) ([]byte,
354
354
return stdoutBuf .Bytes (), errBuf , err
355
355
}
356
356
357
- func (cli * ArduinoCLI ) run (ctx context.Context , stdoutBuff , stderrBuff io.Writer , stdinBuff io.Reader , env map [string ]string , args ... string ) error {
357
+ func (cli * ArduinoCLI ) run (ctx context.Context , stdoutBuff , stderrBuff io.Writer , stdinBuff io.Reader , env map [string ]string , args ... string ) ( _err error ) {
358
358
if cli .cliConfigPath != nil {
359
359
args = append ([]string {"--config-file" , cli .cliConfigPath .String ()}, args ... )
360
360
}
361
361
362
362
// Accumulate all output to terminal and spit-out all at once at the end of the test
363
363
// This allows to correctly group test output when running t.Parallel() tests.
364
364
terminalOut := new (bytes.Buffer )
365
+ terminalErr := new (bytes.Buffer )
365
366
defer func () {
366
367
fmt .Print (terminalOut .String ())
368
+ fmt .Print (terminalErr .String ())
369
+ fmt .Fprintln (terminalOut , color .HiBlackString ("<<< Run completed (err = %v)" , _err ))
367
370
}()
368
371
369
372
// Github-actions workflow tags to fold log lines
@@ -401,20 +404,19 @@ func (cli *ArduinoCLI) run(ctx context.Context, stdoutBuff, stderrBuff io.Writer
401
404
if stderrBuff == nil {
402
405
stderrBuff = io .Discard
403
406
}
404
- if _ , err := io .Copy (stderrBuff , io .TeeReader (stderr , terminalOut )); err != nil {
405
- fmt .Fprintln (terminalOut , color .HiBlackString ("<<< stderr copy error:" ), err )
407
+ if _ , err := io .Copy (stderrBuff , io .TeeReader (stderr , terminalErr )); err != nil {
408
+ fmt .Fprintln (terminalErr , color .HiBlackString ("<<< stderr copy error:" ), err )
406
409
}
407
410
}()
408
411
if stdinBuff != nil {
409
412
go func () {
410
413
if _ , err := io .Copy (stdin , stdinBuff ); err != nil {
411
- fmt .Fprintln (terminalOut , color .HiBlackString ("<<< stdin copy error:" ), err )
414
+ fmt .Fprintln (terminalErr , color .HiBlackString ("<<< stdin copy error:" ), err )
412
415
}
413
416
}()
414
417
}
415
418
cliErr := cliProc .WaitWithinContext (ctx )
416
419
wg .Wait ()
417
- fmt .Fprintln (terminalOut , color .HiBlackString ("<<< Run completed (err = %v)" , cliErr ))
418
420
419
421
return cliErr
420
422
}
0 commit comments