@@ -31,7 +31,6 @@ import (
3131 "strings"
3232 "sync"
3333 "sync/atomic"
34- "syscall"
3534 "testing"
3635 "time"
3736)
@@ -115,10 +114,15 @@ func TestSingleflightDoAndDoChan(t *testing.T) {
115114}
116115
117116func TestShellCommandProvisionerAndStatelessPoller (t * testing.T ) {
117+ origPath := os .Getenv ("PATH" )
118+ tempBin := t .TempDir ()
119+ for _ , shName := range []string {"sh" , "sh.exe" } {
120+ _ = os .WriteFile (filepath .Join (tempBin , shName ), []byte ("#!/bin/sh\n " ), 0o755 )
121+ }
122+ t .Setenv ("PATH" , tempBin )
118123 if bin , args := ResolveProvisionShell ("windows" , "echo ok" ); ! strings .Contains (bin , "sh" ) || len (args ) != 2 || args [0 ] != "-c" {
119124 t .Errorf ("ResolveProvisionShell(windows with PATH sh) = (%q, %v), want sh -c" , bin , args )
120125 }
121- origPath := os .Getenv ("PATH" )
122126 t .Setenv ("PATH" , "" )
123127 if bin , args := ResolveProvisionShell ("windows" , "echo ok" ); bin != "cmd.exe" || len (args ) != 2 || args [0 ] != "/C" {
124128 t .Errorf ("ResolveProvisionShell(windows without PATH sh) = (%q, %v), want cmd.exe /C" , bin , args )
@@ -159,8 +163,8 @@ func TestShellCommandProvisionerAndStatelessPoller(t *testing.T) {
159163 if idx := strings .LastIndexByte (string (statBytes ), ')' ); idx >= 0 {
160164 fields := strings .Fields (string (statBytes [idx + 1 :]))
161165 if len (fields ) >= 3 {
162- if childPgid , err := strconv .Atoi (fields [2 ]); err == nil && childPgid == syscall . Getpgrp () {
163- t .Errorf ("childPgid = %d, want != parent pgid %d (ConfigureSubprocessGroup must set new process group)" , childPgid , syscall . Getpgrp ())
166+ if childPgid , err := strconv .Atoi (fields [2 ]); err == nil && childPgid == os . Getpid () {
167+ t .Errorf ("childPgid = %d, want != parent pid %d (ConfigureSubprocessGroup must set new process group)" , childPgid , os . Getpid ())
164168 }
165169 }
166170 }
0 commit comments