Skip to content

Commit eacd81c

Browse files
committed
Before killing the daemon, try a graceful shutdown
Otherwise the process will not outut the coverage data.
1 parent 27ac5fd commit eacd81c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Diff for: internal/integrationtest/arduino-cli.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ type ArduinoCLI struct {
7070
path *paths.Path
7171
t *require.Assertions
7272
proc *executils.Process
73+
stdIn io.WriteCloser
7374
cliEnvVars map[string]string
7475
cliConfigPath *paths.Path
7576
stagingDir *paths.Path
@@ -122,7 +123,12 @@ func NewArduinoCliWithinEnvironment(env *Environment, config *ArduinoCLIConfig)
122123
func (cli *ArduinoCLI) CleanUp() {
123124
if cli.proc != nil {
124125
cli.daemonConn.Close()
125-
cli.proc.Kill()
126+
cli.stdIn.Close()
127+
proc := cli.proc
128+
go func() {
129+
time.Sleep(time.Second)
130+
proc.Kill()
131+
}()
126132
cli.proc.Wait()
127133
}
128134
}
@@ -251,10 +257,11 @@ func (cli *ArduinoCLI) StartDaemon(verbose bool) string {
251257
cli.t.NoError(err)
252258
stderr, err := cliProc.StderrPipe()
253259
cli.t.NoError(err)
254-
_, err = cliProc.StdinPipe()
260+
stdIn, err := cliProc.StdinPipe()
255261
cli.t.NoError(err)
256262

257263
cli.t.NoError(cliProc.Start())
264+
cli.stdIn = stdIn
258265
cli.proc = cliProc
259266
cli.daemonAddr = "127.0.0.1:50051"
260267

0 commit comments

Comments
 (0)