@@ -20,11 +20,13 @@ import (
20
20
"context"
21
21
"fmt"
22
22
"io"
23
+ "strings"
23
24
"testing"
24
25
25
26
"github.com/arduino/arduino-cli/executils"
26
27
"github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
27
28
"github.com/arduino/go-paths-helper"
29
+ "github.com/fatih/color"
28
30
"github.com/stretchr/testify/require"
29
31
"google.golang.org/grpc"
30
32
)
@@ -75,6 +77,7 @@ func (cli *ArduinoCLI) CleanUp() {
75
77
76
78
// Run executes the given arduino-cli command and returns the output.
77
79
func (cli * ArduinoCLI ) Run (args ... string ) ([]byte , []byte , error ) {
80
+ fmt .Println (color .HiBlackString (">>> Running: " ) + color .HiYellowString ("%s %s" , cli .path , strings .Join (args , " " )))
78
81
if cli .cliConfigPath != nil {
79
82
args = append ([]string {"--config-file" , cli .cliConfigPath .String ()}, args ... )
80
83
}
@@ -93,15 +96,17 @@ func (cli *ArduinoCLI) Run(args ...string) ([]byte, []byte, error) {
93
96
stdoutCtx , stdoutCancel := context .WithCancel (context .Background ())
94
97
stderrCtx , stderrCancel := context .WithCancel (context .Background ())
95
98
go func () {
96
- io .Copy (& stdoutBuf , stdout )
99
+ io .Copy (& stdoutBuf , io . TeeReader ( stdout , os . Stdout ) )
97
100
stdoutCancel ()
98
101
}()
99
102
go func () {
100
- io .Copy (& stderrBuf , stderr )
103
+ io .Copy (& stderrBuf , io . TeeReader ( stderr , os . Stderr ) )
101
104
stderrCancel ()
102
105
}()
103
106
cliErr := cliProc .Wait ()
104
107
<- stdoutCtx .Done ()
105
108
<- stderrCtx .Done ()
109
+ fmt .Println (color .HiBlackString ("<<< Run completed (err = %v)" , cliErr ))
110
+
106
111
return stdoutBuf .Bytes (), stderrBuf .Bytes (), cliErr
107
112
}
0 commit comments