feat: allow for setup.sh based user fixtures

This commit is contained in:
2026-03-21 11:20:29 +00:00
parent cf9330e483
commit d72f727322
10 changed files with 222 additions and 45 deletions
+4 -4
View File
@@ -17,7 +17,7 @@ type recordIO struct {
err io.Writer
}
func recordScenario(target, shellPath string, rio recordIO, sandboxConfig map[string]string) error {
func recordScenario(target, shellPath string, rio recordIO, sandboxConfig map[string]string, setupScripts []string) error {
rawIn, rawOut, cleanup, err := newRecordFiles()
if err != nil {
return err
@@ -40,7 +40,7 @@ func recordScenario(target, shellPath string, rio recordIO, sandboxConfig map[st
output.Fprintln(rio.err, "Run commands in the recorder shell, then type exit to finish.")
if err := runRecordSession(target, rawIn, rawOut, shellPath, sandbox, rio, sandboxConfig); err != nil {
if err := runRecordSession(target, rawIn, rawOut, shellPath, sandbox, rio, sandboxConfig, setupScripts); err != nil {
return err
}
@@ -119,10 +119,10 @@ func newRecordSandboxForPathEnv(pathEnv string) (recordSandbox, func(), error) {
return sandbox, cleanup, nil
}
func runRecordSession(dir, rawIn, rawOut, shellPath string, sandbox recordSandbox, rio recordIO, sandboxConfig map[string]string) error {
func runRecordSession(dir, rawIn, rawOut, shellPath string, sandbox recordSandbox, rio recordIO, sandboxConfig map[string]string, setupScripts []string) error {
cmd := exec.Command("script", "-q", "-E", "always", "-I", rawIn, "-O", rawOut, "-c", shellPath)
cmd.Dir = dir
cmd.Env = recordSessionEnv(sandbox, sandboxConfig)
cmd.Env = recordSessionEnv(sandbox, sandboxConfig, setupScripts)
cmd.Stdin = rio.in
cmd.Stdout = rio.out
cmd.Stderr = rio.err