Skip to content

Commit 7b6523b

Browse files
committed
Cleanup
1 parent 8529aba commit 7b6523b

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

process.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,7 @@ func findExe(exe string) (string, []string, error) {
132132
// See if the command string contains args. As it is best effort, we do not
133133
// handle parse errors.
134134
if exeArgs, _ := shellwords.Parse(exe); len(exeArgs) > 0 {
135-
// We want to return the original error if this command isn't found so
136-
// do not overwrite it.
137-
if p, err2 := execabs.LookPath(exeArgs[0]); err2 == nil {
135+
if p, err := execabs.LookPath(exeArgs[0]); err == nil {
138136
return p, exeArgs[1:], nil
139137
}
140138
}

process_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import (
77
"sync/atomic" // Note: atomic.Bool was added at Go 1.19
88
"testing"
99
"time"
10+
11+
"golang.org/x/sys/execabs"
1012
)
1113

1214
func testStartEchoCommand(t *testing.T, proc *concurrentProcess, done *atomic.Bool) {
@@ -64,9 +66,16 @@ func TestProcessRunConcurrently(t *testing.T) {
6466
}
6567

6668
func TestProcessRunWithArgs(t *testing.T) {
69+
if _, err := execabs.LookPath("echo"); err != nil {
70+
t.Skipf("echo command is necessary to run this test: %s", err)
71+
}
72+
6773
var done atomic.Bool
6874
p := newConcurrentProcess(1)
69-
echo := testSkipIfNoCommand(t, p, "echo hello")
75+
echo, err := p.newCommandRunner("echo hello", false)
76+
if err != nil {
77+
t.Fatalf(`parsing "echo hello" failed: %v`, err)
78+
}
7079
echo.run(nil, "", func(b []byte, err error) error {
7180
if err != nil {
7281
t.Error(err)

0 commit comments

Comments
 (0)