Skip to content

Commit

Permalink
bonsai
Browse files Browse the repository at this point in the history
  • Loading branch information
k1LoW committed Jul 25, 2019
1 parent 159720f commit fc2051d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
22 changes: 11 additions & 11 deletions exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ func TestCommand(t *testing.T) {
if strings.TrimRight(stdout.String(), "\n\r") != tt.want {
t.Errorf("%s: want = %#v, got = %#v", tt.name, tt.want, stdout.String())
}
_, err = exec.Command("bash", "-c", fmt.Sprintf("ps aux | grep %s | grep -v grep", tt.want)).Output()
if err == nil {
out, err := exec.Command("bash", "-c", fmt.Sprintf("ps aux | grep %s | grep -v grep", tt.want)).Output()
if err == nil || string(out) != "" {
t.Errorf("%s", "the process has not exited")
}
}
Expand All @@ -71,8 +71,8 @@ func TestCommandContext(t *testing.T) {
if strings.TrimRight(stdout.String(), "\n\r") != tt.want {
t.Errorf("%s: want = %#v, got = %#v", tt.name, tt.want, stdout.String())
}
_, err = exec.Command("bash", "-c", fmt.Sprintf("ps aux | grep %s | grep -v grep", tt.want)).Output()
if err == nil {
out, err := exec.Command("bash", "-c", fmt.Sprintf("ps aux | grep %s | grep -v grep", tt.want)).Output()
if err == nil || string(out) != "" {
t.Errorf("%s", "the process has not exited")
}
}
Expand All @@ -99,8 +99,8 @@ func TestCommandContextCancel(t *testing.T) {
}()
time.Sleep(100 * time.Millisecond)
cancel()
_, err = exec.Command("bash", "-c", fmt.Sprintf("ps aux | grep %s | grep -v grep", tt.want)).Output()
if err == nil {
out, err := exec.Command("bash", "-c", fmt.Sprintf("ps aux | grep %s | grep -v grep", tt.want)).Output()
if err == nil || string(out) != "" {
t.Errorf("%s", "the process has not exited")
}
}
Expand Down Expand Up @@ -134,8 +134,8 @@ func TestTerminateCommand(t *testing.T) {
if err != nil && !tt.processFinished {
t.Errorf("%s: %v", tt.name, err)
}
_, err = exec.Command("bash", "-c", fmt.Sprintf("ps aux | grep %s | grep -v grep", tt.want)).Output()
if err == nil {
out, err := exec.Command("bash", "-c", fmt.Sprintf("ps aux | grep %s | grep -v grep", tt.want)).Output()
if err == nil || string(out) != "" {
t.Errorf("%s: %s", tt.name, "the process has not exited")
}
}
Expand Down Expand Up @@ -163,8 +163,8 @@ func TestKillCommand(t *testing.T) {
if err != nil && !tt.processFinished {
t.Fatalf("%s: %v", tt.name, err)
}
_, err = exec.Command("bash", "-c", fmt.Sprintf("ps aux | grep %s | grep -v grep", tt.want)).Output()
if err == nil {
out, err := exec.Command("bash", "-c", fmt.Sprintf("ps aux | grep %s | grep -v grep", tt.want)).Output()
if err == nil || string(out) != "" {
t.Errorf("%s: %s", tt.name, "the process has not exited")
}
}
Expand All @@ -188,7 +188,7 @@ func gentests(withSleepTest bool) []testcase {
r = "123456"
tests = append(tests, testcase{"sleep", []string{stubCmd, "-sleep", r}, r, false})
r = "654321"
tests = append(tests, testcase{"cmd /c sleep", []string{"cmd", "/c", fmt.Sprintf("%s -sleep %s && echo %s", stubCmd, r, r)}, r, false})
// tests = append(tests, testcase{"cmd /c sleep", []string{"cmd", "/c", fmt.Sprintf("%s -sleep %s && echo %s", stubCmd, r, r)}, r, false})
}
return tests
}
Expand Down
1 change: 1 addition & 0 deletions exec_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"syscall"
)

// MEMO: Sending Interrupt on Windows is not implemented.
var defaultSignal = os.Interrupt

// Reference code:
Expand Down

0 comments on commit fc2051d

Please sign in to comment.