summary refs log tree commit diff
diff options
context:
space:
mode:
authorRobert Hensing <robert@roberthensing.nl>2023-10-24 11:16:34 +0200
committerRobert Hensing <robert@roberthensing.nl>2023-10-24 11:17:38 +0200
commita6622bf00a033921d1c08a38fb9d64b8feafdf56 (patch)
treeb402a5db8ef72f4ae934a48013be7645846c91e9
parente64f987fd6b922cfc0b42d2dd516c8e7924befd4 (diff)
downloadnixpkgs-a6622bf00a033921d1c08a38fb9d64b8feafdf56.tar
nixpkgs-a6622bf00a033921d1c08a38fb9d64b8feafdf56.tar.gz
nixpkgs-a6622bf00a033921d1c08a38fb9d64b8feafdf56.tar.bz2
nixpkgs-a6622bf00a033921d1c08a38fb9d64b8feafdf56.tar.lz
nixpkgs-a6622bf00a033921d1c08a38fb9d64b8feafdf56.tar.xz
nixpkgs-a6622bf00a033921d1c08a38fb9d64b8feafdf56.tar.zst
nixpkgs-a6622bf00a033921d1c08a38fb9d64b8feafdf56.zip
writers/test: Refactor
It now also checks the executable bit.
-rw-r--r--pkgs/build-support/writers/test.nix10
1 files changed, 2 insertions, 8 deletions
diff --git a/pkgs/build-support/writers/test.nix b/pkgs/build-support/writers/test.nix
index ba481e6f625..005daf0be5b 100644
--- a/pkgs/build-support/writers/test.nix
+++ b/pkgs/build-support/writers/test.nix
@@ -7,6 +7,7 @@
 , python3Packages
 , pypy3Packages
 , runCommand
+, testers
 , writers
 , writeText
 }:
@@ -36,14 +37,7 @@ let
     let
       expectedFile = writeText "${file.name}-expected" expected;
     in
-    runCommand "run-${file.name}" {} ''
-      if ! diff -u ${file} ${expectedFile}; then
-        echo 'test ${file.name} failed'
-        exit 1
-      fi
-
-      touch $out
-    '';
+    testers.testEqualContents { expected = expectedFile; actual = file; assertion = "${file.name} matches"; };
 in
 lib.recurseIntoAttrs {
   bin = lib.recurseIntoAttrs {