@@ -36,6 +36,7 @@ type ArduinoCLI struct {
36
36
path * paths.Path
37
37
t * require.Assertions
38
38
proc * executils.Process
39
+ cliEnvVars []string
39
40
cliConfigPath * paths.Path
40
41
daemonAddr string
41
42
daemonConn * grpc.ClientConn
@@ -45,17 +46,11 @@ type ArduinoCLI struct {
45
46
// NewArduinoCliWithinEnvironment creates a new Arduino CLI client inside the given environment.
46
47
func NewArduinoCliWithinEnvironment (t * testing.T , cliPath * paths.Path , env * Environment ) * ArduinoCLI {
47
48
cli := NewArduinoCli (t , cliPath )
48
- cli .cliConfigPath = env .Root ().Join ("arduino-cli.yaml" )
49
- config := fmt .Sprintf (`
50
- directories:
51
- data: %s
52
- downloads: %s
53
- user: %s
54
- ` ,
55
- env .Root ().Join ("arduino15" ),
56
- env .Root ().Join ("arduino15/staging" ),
57
- env .Root ().Join ("Arduino" ))
58
- require .NoError (t , cli .cliConfigPath .WriteFile ([]byte (config )))
49
+ cli .cliEnvVars = []string {
50
+ fmt .Sprintf ("ARDUINO_DATA_DIR=%s" , env .Root ().Join ("arduino15" )),
51
+ fmt .Sprintf ("ARDUINO_DOWNLOADS_DIR=%s" , env .Root ().Join ("arduino15/staging" )),
52
+ fmt .Sprintf ("ARDUINO_SKETCHBOOK_DIR=%s" , env .Root ().Join ("Arduino" )),
53
+ }
59
54
return cli
60
55
}
61
56
@@ -77,11 +72,11 @@ func (cli *ArduinoCLI) CleanUp() {
77
72
78
73
// Run executes the given arduino-cli command and returns the output.
79
74
func (cli * ArduinoCLI ) Run (args ... string ) ([]byte , []byte , error ) {
80
- fmt .Println (color .HiBlackString (">>> Running: " ) + color .HiYellowString ("%s %s" , cli .path , strings .Join (args , " " )))
81
75
if cli .cliConfigPath != nil {
82
76
args = append ([]string {"--config-file" , cli .cliConfigPath .String ()}, args ... )
83
77
}
84
- cliProc , err := executils .NewProcessFromPath (nil , cli .path , args ... )
78
+ fmt .Println (color .HiBlackString (">>> Running: " ) + color .HiYellowString ("%s %s" , cli .path , strings .Join (args , " " )))
79
+ cliProc , err := executils .NewProcessFromPath (cli .cliEnvVars , cli .path , args ... )
85
80
cli .t .NoError (err )
86
81
stdout , err := cliProc .StdoutPipe ()
87
82
cli .t .NoError (err )
0 commit comments