Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions arduino/monitor/monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ func TestDummyMonitor(t *testing.T) {
go func() {
buff := [1024]byte{}
// Receive "TEST" echoed back
n, err = rw.Read(buff[:])
_, err := rw.Read(buff[:])
require.NoError(t, err)
require.Equal(t, 4, n)
require.Equal(t, "TEST", string(buff[:4]))

// Block on read until the port is closed
n, err = rw.Read(buff[:])
_, err = rw.Read(buff[:])
require.ErrorIs(t, err, io.EOF)
atomic.StoreInt32(&completed, 1) // notify completion
}()
Expand Down
6 changes: 4 additions & 2 deletions executils/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ func (p *Process) SetEnvironment(values []string) {
// RunWithinContext starts the specified command and waits for it to complete. If the given context
// is canceled before the normal process termination, the process is killed.
func (p *Process) RunWithinContext(ctx context.Context) error {
if err := p.Start(); err != nil {
return err
}
completed := make(chan struct{})
defer close(completed)
go func() {
Expand All @@ -169,6 +172,5 @@ func (p *Process) RunWithinContext(ctx context.Context) error {
case <-completed:
}
}()
res := p.cmd.Run()
return res
return p.Wait()
}