about summary refs log tree commit diff
path: root/nix/buildLisp
diff options
context:
space:
mode:
authorsterni <sternenseemann@systemli.org>2022-09-13T16·33+0200
committersterni <sternenseemann@systemli.org>2022-09-20T10·43+0000
commitf39a4e4fa711215e7ebbff72505d7f6e30bc26b4 (patch)
treeca7989b45b1b081e8970e4cda02b914dd9eeb6c0 /nix/buildLisp
parentcd280e07964db1a789c44748a1a7e5dc4e5d534e (diff)
refactor(nix/buildLisp/tests/argv0): use derivation for tests r/4934
There is no need to use an extraStep, actually, and using derivations
reduces noise on CI.

Change-Id: I897c3c3f7e0acee8f051fcc01450ff57176726f8
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6573
Autosubmit: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
Diffstat (limited to 'nix/buildLisp')
-rw-r--r--nix/buildLisp/tests/argv0.nix92
1 files changed, 57 insertions, 35 deletions
diff --git a/nix/buildLisp/tests/argv0.nix b/nix/buildLisp/tests/argv0.nix
index bc29337d06cd..ca5f2b9741e6 100644
--- a/nix/buildLisp/tests/argv0.nix
+++ b/nix/buildLisp/tests/argv0.nix
@@ -1,36 +1,58 @@
-{ depot, pkgs, ... }:
-
-depot.nix.buildLisp.program {
-  name = "argv0-test";
-
-  srcs = [
-    (pkgs.writeText "argv0-test.lisp" ''
-      (defpackage :argv0-test (:use :common-lisp :uiop) (:export :main))
-      (in-package :argv0-test)
-
-      (defun main ()
-        (format t "~A~%" (uiop:argv0)))
-    '')
-  ];
-
-  deps = [
-    {
-      sbcl = depot.nix.buildLisp.bundled "uiop";
-      default = depot.nix.buildLisp.bundled "asdf";
-    }
-  ];
-
-  passthru.meta.ci = {
-    extraSteps.verify = {
-      label = "verify argv[0] output";
-      needsOutput = true;
-      command = pkgs.writeShellScript "check-argv0" ''
-        set -eux
-
-        for invocation in "$(pwd)/result/bin/argv0-test" "./result/bin/argv0-test"; do
-          test "$invocation" = "$("$invocation")"
-        done
-      '';
+{ depot, pkgs, lib, ... }:
+
+let
+  # Trivial test program that outputs argv[0] and exits
+  prog =
+    depot.nix.buildLisp.program {
+      name = "argv0-test";
+
+      srcs = [
+        (pkgs.writeText "argv0-test.lisp" ''
+          (defpackage :argv0-test (:use :common-lisp :uiop) (:export :main))
+          (in-package :argv0-test)
+
+          (defun main ()
+            (format t "~A~%" (uiop:argv0)))
+        '')
+      ];
+
+      deps = [
+        {
+          sbcl = depot.nix.buildLisp.bundled "uiop";
+          default = depot.nix.buildLisp.bundled "asdf";
+        }
+      ];
     };
-  };
-}
+
+  # Extract verify argv[0] output for given buildLisp program
+  checkImplementation = prog:
+    pkgs.runCommand "check-argv0" { } ''
+      set -eux
+
+      checkInvocation() {
+        invocation="$1"
+        test "$invocation" = "$("$invocation")"
+      }
+
+      checkInvocation "${prog}/bin/argv0-test"
+
+      cd ${prog}
+      checkInvocation "./bin/argv0-test"
+
+      cd bin
+      checkInvocation ./argv0-test
+
+      set +x
+
+      touch "$out"
+    '';
+
+  inherit (prog.meta.ci) targets;
+in
+
+(checkImplementation prog).overrideAttrs (_: {
+  # Wire up a subtarget all (active) non-default implementations
+  passthru = lib.genAttrs targets (name: checkImplementation prog.${name});
+
+  meta.ci = { inherit targets; };
+})