From f71332b2ae893de049f2d1237b0ed8ddbf7fead0 Mon Sep 17 00:00:00 2001 From: Connor Baker Date: Thu, 20 Feb 2025 10:19:33 -0800 Subject: [PATCH] testers.testBuildFailure': output is created so long as checks succeed --- doc/build-helpers/testers.chapter.md | 5 ++++- pkgs/build-support/testers/test/default.nix | 5 ----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/doc/build-helpers/testers.chapter.md b/doc/build-helpers/testers.chapter.md index 81e13043e896..74e70162ed3d 100644 --- a/doc/build-helpers/testers.chapter.md +++ b/doc/build-helpers/testers.chapter.md @@ -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" ''; } ``` diff --git a/pkgs/build-support/testers/test/default.nix b/pkgs/build-support/testers/test/default.nix index ac05f95f54a9..a7187a7dbfbf 100644 --- a/pkgs/build-support/testers/test/default.nix +++ b/pkgs/build-support/testers/test/default.nix @@ -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 ''; };