about summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorProfpatsch <mail@profpatsch.de>2019-09-24 21:00:01 +0200
committerProfpatsch <mail@profpatsch.de>2019-09-24 21:37:03 +0200
commitb0ec67b409dc389890d1debed4fe2317bacff366 (patch)
treec5264b5be3cef3e41000bad8e035b574d86d0d54 /pkgs
parentc11d43c59fe3c82ebb17df1e592cce3fff0816c1 (diff)
pkgs/profpatsch: export runExeclineLocal & run tests locally
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/profpatsch/default.nix74
-rw-r--r--pkgs/profpatsch/execline/run-execline-tests.nix26
2 files changed, 64 insertions, 36 deletions
diff --git a/pkgs/profpatsch/default.nix b/pkgs/profpatsch/default.nix
index 347d1679..24a69871 100644
--- a/pkgs/profpatsch/default.nix
+++ b/pkgs/profpatsch/default.nix
@@ -46,6 +46,49 @@ let
       allowSubstitutes = false;
     }) cmd;
 
+  testing = import ./testing {
+    inherit stdenv lib;
+    inherit (runExeclineFns) runExecline;
+    inherit (pkgs) runCommand;
+    bin = bins pkgs.s6PortableUtils [ "s6-touch" "s6-echo" ];
+  };
+
+  runExeclineFns =
+    # todo: factor out calling tests
+    let
+      it = import ./execline/run-execline.nix {
+        bin = (bins execlineb-with-builtins [ "execlineb" ])
+           // (bins pkgs.execline [ "redirfd" "importas" "exec" ]);
+        inherit stdenv;
+      };
+      itLocal = args: it (args // {
+        derivationArgs = args.derivationArgs or {} // {
+          preferLocalBuild = true;
+          allowSubstitutes = false;
+        };
+      });
+      tests = import ./execline/run-execline-tests.nix {
+        # can’t use runExeclineLocal in the tests,
+        # because it is tested by the tests (well, it does
+        # work, but then you have to run the tests every time)
+        runExecline = it;
+        inherit (testing) drvSeqL;
+        inherit (pkgs) coreutils;
+        inherit stdenv;
+        bin = (bins execlineb-with-builtins [ "execlineb" ])
+           // (bins pkgs.execline [
+                 { use = "if"; as = "execlineIf"; }
+                 "redirfd" "importas"
+               ])
+           // (bins pkgs.s6PortableUtils
+                [ "s6-cat" "s6-grep" "s6-touch" "s6-test" "s6-chmod" ]);
+       };
+    in {
+      runExecline = it;
+      runExeclineLocal = args: testing.drvSeqL tests (itLocal args);
+    };
+
+
 in rec {
   inherit (nixperiments)
     # filterSource by parsing a .gitignore file
@@ -91,35 +134,8 @@ in rec {
     ];
   });
 
-  runExecline =
-    # todo: factor out calling tests
-    let
-      it = import ./execline/run-execline.nix {
-        bin = (bins execlineb-with-builtins [ "execlineb" ])
-           // (bins pkgs.execline [ "redirfd" "importas" "exec" ]);
-        inherit stdenv;
-      };
-      tests = import ./execline/run-execline-tests.nix {
-        runExecline = it;
-        inherit (testing) drvSeqL;
-        inherit (pkgs) coreutils;
-        inherit stdenv;
-        bin = (bins execlineb-with-builtins [ "execlineb" ])
-           // (bins pkgs.execline [
-                 { use = "if"; as = "execlineIf"; }
-                 "redirfd" "importas"
-               ])
-           // (bins pkgs.s6PortableUtils
-                [ "s6-cat" "s6-grep" "s6-touch" "s6-test" "s6-chmod" ]);
-       };
-    in tests;
-
-
-  testing = import ./testing {
-    inherit stdenv lib runExecline;
-    inherit (pkgs) runCommand;
-    bin = bins pkgs.s6PortableUtils [ "s6-touch" "s6-echo" ];
-  };
+  inherit (runExeclineFns)
+    runExecline runExeclineLocal;
 
   symlink = pkgs.callPackage ./execline/symlink.nix {
     inherit runExecline;
diff --git a/pkgs/profpatsch/execline/run-execline-tests.nix b/pkgs/profpatsch/execline/run-execline-tests.nix
index ebfdeb20..76f18105 100644
--- a/pkgs/profpatsch/execline/run-execline-tests.nix
+++ b/pkgs/profpatsch/execline/run-execline-tests.nix
@@ -2,8 +2,6 @@
 # https://www.mail-archive.com/skaware@list.skarnet.org/msg01256.html
 , coreutils }:
 
-# TODO: run all of these locally! runExeclineLocal
-
 let
 
   # lol
@@ -12,6 +10,8 @@ let
     derivationArgs = {
       inherit script;
       passAsFile = [ "script" ];
+      preferLocalBuild = true;
+      allowSubstitutes = false;
     };
     execline = ''
       importas -ui s scriptPath
@@ -30,7 +30,7 @@ let
   # in the given file. Does not use runExecline, because
   # that should be tested after all.
   fileHasLine = line: file: derivation {
-    name = "file-${file.name}-has-line";
+    name = "run-execline-test-file-${file.name}-has-line";
     inherit (stdenv) system;
     builder = bin.execlineIf;
     args =
@@ -47,16 +47,20 @@ let
 
   # basic test that touches out
   basic = runExecline {
-    name = "basic";
+    name = "run-execline-test-basic";
     execline = ''
       importas -ui out out
       ${bin.s6-touch} $out
     '';
+    derivationArgs = {
+      preferLocalBuild = true;
+      allowSubstitutes = false;
+    };
   };
 
   # whether the stdin argument works as intended
   stdin = fileHasLine "foo" (runExecline {
-    name = "stdin";
+    name = "run-execline-test-stdin";
     stdin = "foo\nbar\nfoo";
     execline = ''
       importas -ui out out
@@ -64,10 +68,14 @@ let
       # and s6-cat redirects from stdin to stdout
       redirfd -w 1 $out ${bin.s6-cat}
     '';
+    derivationArgs = {
+      preferLocalBuild = true;
+      allowSubstitutes = false;
+    };
   });
 
   wrapWithVar = runExecline {
-    name = "wrap-with-var";
+    name = "run-execline-test-wrap-with-var";
     builderWrapper = writeScript "var-wrapper" ''
       #!${bin.execlineb} -S0
       export myvar myvalue $@
@@ -78,6 +86,10 @@ let
         importas out out
         ${bin.s6-touch} $out
     '';
+    derivationArgs = {
+      preferLocalBuild = true;
+      allowSubstitutes = false;
+    };
   };
 
-in args: drvSeqL [ basic stdin wrapWithVar ] (runExecline args)
+in [ basic stdin wrapWithVar ]