about summary refs log tree commit diff
path: root/pkgs/development/interpreters/bats
diff options
context:
space:
mode:
authorTravis A. Everett <travis.a.everett@gmail.com>2022-04-23 16:05:53 -0500
committerTravis A. Everett <travis.a.everett@gmail.com>2022-04-23 16:05:53 -0500
commita60c1dbb51350c3a7c7ec766c130014d46cdf1eb (patch)
tree0254fa742b1a3bf077caacebaf27e5113d46b0b1 /pkgs/development/interpreters/bats
parent749b97bb2345395e4f7d947c71ac603dbce01d72 (diff)
bats: move installCheck into passthru.tests
I happily painted myself into a corner when converting bats to use
resholve. Since resholve tests itself with bats, all updates to
resholve now require rebuilding bats. The build itself is quick, but
the tests take a few minutes; moving them into passthru saves time. :)
Diffstat (limited to 'pkgs/development/interpreters/bats')
-rw-r--r--pkgs/development/interpreters/bats/default.nix41
1 files changed, 26 insertions, 15 deletions
diff --git a/pkgs/development/interpreters/bats/default.nix b/pkgs/development/interpreters/bats/default.nix
index 03984f9779fe1..184d23b92b909 100644
--- a/pkgs/development/interpreters/bats/default.nix
+++ b/pkgs/development/interpreters/bats/default.nix
@@ -103,22 +103,33 @@ resholve.mkDerivation rec {
     };
   };
 
-  inherit doInstallCheck;
-  installCheckInputs = [
-    ncurses
-    parallel # skips some tests if it can't detect
-    flock # skips some tests if it can't detect
-    ps
-  ] ++ lib.optionals stdenv.isDarwin [ lsof ];
-  installCheckPhase = ''
-    # TODO: cut if https://github.com/bats-core/bats-core/issues/418 allows
-    sed -i '/test works even if PATH is reset/a skip' test/bats.bats
+  passthru.tests.upstream = bats.unresholved.overrideAttrs (old: {
+    name = "${bats.name}-tests";
+    installCheckInputs = [
+      ncurses
+      parallel # skips some tests if it can't detect
+      flock # skips some tests if it can't detect
+      ps
+    ] ++ lib.optionals stdenv.isDarwin [ lsof ];
+    inherit doInstallCheck;
+    installCheckPhase = ''
+      # TODO: cut if https://github.com/bats-core/bats-core/issues/418 allows
+      sed -i '/test works even if PATH is reset/a skip "disabled for nix build"' test/bats.bats
+      # TODO: cut when https://github.com/bats-core/bats-core/pull/554 allows
+      substituteInPlace test/parallel.bats --replace '&& type -p shlock' '|| type -p shlock'
 
-    # test generates file with absolute shebang dynamically
-    substituteInPlace test/install.bats --replace \
-      "/usr/bin/env bash" "${bash}/bin/bash"
-    bin/bats test
-  '';
+      # skip tests that assume bats `install.sh` will be in BATS_ROOT
+      rm test/root.bats
+
+      # test generates file with absolute shebang dynamically
+      substituteInPlace test/install.bats --replace \
+        "/usr/bin/env bash" "${bash}/bin/bash"
+
+      ${bats}/bin/bats test
+      rm -rf $out
+      touch $out
+    '';
+  });
 
   meta = with lib; {
     homepage = "https://github.com/bats-core/bats-core";