1 # Run a builder, flip exit code, save log and fix outputs
4 # - Delegate to another original builder passed via args
5 # - Save the build log to output for further checks
6 # - Make the derivation succeed if the original builder fails
7 # - Make the derivation fail if the original builder returns exit code 0
10 # This runs before, without and after stdenv. Do not modify the environment;
11 # especially not before invoking the original builder. For example, use
12 # "@" substitutions instead of PATH.
13 # Do not export any variables.
18 # ------------------------
19 # Run the original builder
21 echo "testBuildFailure: Expecting non-zero exit from builder and args: ${*@Q}"
23 ("$@" 2>&1) | @coreutils@
/bin
/tee $TMPDIR/testBuildFailure.log \
24 |
while IFS
= read -r ln; do
25 echo "original builder: $ln"
30 echo "testBuildFailure: The builder did not fail, but a failure was expected!"
33 echo "testBuildFailure: Original builder produced exit code: $r"
35 # -----------------------------------------
36 # Write the build log to the default output
38 # # from stdenv setup.sh
40 if [ -n "$__structuredAttrs" ]; then
47 outs
=( $
(getAllOutputNames
) )
51 if [[ ! -d $defOutPath ]]; then
52 if [[ -e $defOutPath ]]; then
53 @coreutils@
/bin
/mv $defOutPath $TMPDIR/out-node
54 @coreutils@
/bin
/mkdir
$defOutPath
55 @coreutils@
/bin
/mv $TMPDIR/out-node
$defOutPath/result
59 @coreutils@
/bin
/mkdir
-p $defOutPath
60 @coreutils@
/bin
/mv $TMPDIR/testBuildFailure.log
$defOutPath/testBuildFailure.log
61 echo $r >$defOutPath/testBuildFailure.
exit
63 # ------------------------------------------------------
64 # Put empty directories in place for any missing outputs
66 for outputName
in ${outputs:-out}; do
67 outputPath
="${!outputName}"
68 if [[ ! -e "${outputPath}" ]]; then
69 @coreutils@
/bin
/mkdir
"${outputPath}";