mirror of
https://gitlab.com/TECHNOFAB/nixtest.git
synced 2025-12-12 02:00:18 +01:00
feat: add pure mode which unsets env variables before script tests
This commit is contained in:
parent
7bb5c65259
commit
3ff5b358d5
2 changed files with 9 additions and 2 deletions
|
|
@ -106,7 +106,11 @@ func buildAndRun(derivation string) (exitCode int, stdout bytes.Buffer, stderr b
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := exec.Command("bash", path)
|
args := []string{"bash", path}
|
||||||
|
if *pure {
|
||||||
|
args = append([]string{"env", "-i"}, args...)
|
||||||
|
}
|
||||||
|
cmd := exec.Command(args[0], args[1:]...)
|
||||||
cmd.Stdout = &stdout
|
cmd.Stdout = &stdout
|
||||||
cmd.Stderr = &stderr
|
cmd.Stderr = &stderr
|
||||||
|
|
||||||
|
|
@ -296,6 +300,7 @@ var (
|
||||||
)
|
)
|
||||||
updateSnapshots *bool = flag.Bool("update-snapshots", false, "Update all snapshots")
|
updateSnapshots *bool = flag.Bool("update-snapshots", false, "Update all snapshots")
|
||||||
skipPattern *string = flag.String("skip", "", "Regular expression to skip (e.g., 'test-.*|.*-b')")
|
skipPattern *string = flag.String("skip", "", "Regular expression to skip (e.g., 'test-.*|.*-b')")
|
||||||
|
pure *bool = flag.Bool("pure", false, "Unset all env vars before running script tests")
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,9 @@
|
||||||
type = "script";
|
type = "script";
|
||||||
script = ''
|
script = ''
|
||||||
echo Test something here
|
echo Test something here
|
||||||
exit 1
|
# required in pure mode:
|
||||||
|
export PATH="${lib.makeBinPath [pkgs.gnugrep]}"
|
||||||
|
grep -q "test" ${builtins.toFile "test" "test"}
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue