Restore optional shell handling in launcher tests
This commit is contained in:
@@ -60,12 +60,16 @@ esac
|
||||
|
||||
func (f fixture) run(t *testing.T, script string, status int, args ...string) (string, string, int) {
|
||||
t.Helper()
|
||||
cmd := exec.Command(filepath.Join(f.root, "scripts", script), args...)
|
||||
shell, err := exec.LookPath("sh")
|
||||
if err != nil {
|
||||
t.Skip("POSIX shell is unavailable")
|
||||
}
|
||||
cmd := exec.Command(shell, append([]string{filepath.Join(f.root, "scripts", script)}, args...)...)
|
||||
cmd.Dir = f.outside
|
||||
cmd.Env = append(os.Environ(), "PATH="+filepath.Dir(f.root)+string(os.PathListSeparator)+os.Getenv("PATH"), "CALLS="+f.log, fmt.Sprintf("TOOL_STATUS=%d", status), "CDPATH=/tmp", "GOOS=windows", "GOARCH=arm64", "GOWORK=auto", "GOTOOLCHAIN=auto", "GOFLAGS=-trimpath -mod=mod")
|
||||
var stdout, stderr strings.Builder
|
||||
cmd.Stdout, cmd.Stderr = &stdout, &stderr
|
||||
err := cmd.Run()
|
||||
err = cmd.Run()
|
||||
if err == nil {
|
||||
return stdout.String(), stderr.String(), 0
|
||||
}
|
||||
@@ -183,6 +187,17 @@ func TestStatusAndStreams(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLauncherUsesShell(t *testing.T) {
|
||||
f := newFixture(t)
|
||||
if err := os.Chmod(filepath.Join(f.root, "scripts", "releasekit"), 0644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_, _, status := f.run(t, "releasekit", 0, "version")
|
||||
if status != 0 {
|
||||
t.Fatal(status)
|
||||
}
|
||||
}
|
||||
|
||||
func TestInvalidForms(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
script string
|
||||
|
||||
Reference in New Issue
Block a user