testers.testBuildFailure': output is created so long as checks succeed

This commit is contained in:
Connor Baker
2025-02-20 10:19:33 -08:00
parent 38745b132d
commit f71332b2ae
2 changed files with 4 additions and 6 deletions

View File

@@ -260,10 +260,14 @@ runCommand "example" {
This tester wraps the functionality provided by [`testers.testBuildFailure`](#tester-testBuildFailure) to make writing checks easier by simplifying checking the exit code of the builder and asserting the existence of entries in the builder's log.
Additionally, users may specify a script containing additional checks, accessing the result of applying `testers.testBuildFailure` through the variable `failed`.
NOTE: This tester will produce an empty output and exit with success if none of the checks fail; there is no need to `touch "$out"` in `script`.
:::{.example #ex-testBuildFailurePrime-doc-example}
# Check that a build fails, and verify the changes made during build
Re-using the example from [`testers.testBuildFailure`](#ex-testBuildFailure-showingenvironmentchanges), we can see how common checks are made easier and remove the need for `runCommand`:
```nix
testers.testBuildFailure' {
drv = runCommand "doc-example" { } ''
@@ -275,7 +279,6 @@ testers.testBuildFailure' {
expectedBuilderLogEntries = [ "failing though" ];
script = ''
grep --silent -F 'ok-ish' "$failed/result"
touch "$out"
'';
}
```

View File

@@ -234,7 +234,6 @@ lib.recurseIntoAttrs {
expectedBuilderLogEntries = [ "failing though" ];
script = ''
grep --silent -F 'ok-ish' "$failed/result"
touch "$out"
'';
};
@@ -258,7 +257,6 @@ lib.recurseIntoAttrs {
];
script = ''
grep --silent -F 'ok-ish' "$failed/result"
touch "$out"
'';
};
@@ -293,7 +291,6 @@ lib.recurseIntoAttrs {
# Checking our note that dev is the default output
echo $failed/_ | grep -- '-dev/_' >/dev/null
echo 'All good.'
touch $out
'';
};
@@ -326,8 +323,6 @@ lib.recurseIntoAttrs {
];
script = ''
[[ ! -e side-effect ]]
touch $out
'';
};