commit a0380728a5d1cb838d3459e31b29bb3364886707 parent 3b1bc7eff8037fd21f5a4f6298efad4557845633 Author: Daniel Barlow <dan@telent.net> Date: Sun, 29 Jan 2023 21:39:34 +0000 convert test script to derivation Diffstat:
| C | tests/pseudofiles/test.nix -> tests/pseudofiles/fixture.nix | | | 0 | |
| D | tests/pseudofiles/run.sh | | | 16 | ---------------- |
| M | tests/pseudofiles/test.nix | | | 65 | +++++++++++++++++++---------------------------------------------- |
3 files changed, 19 insertions(+), 62 deletions(-)
diff --git a/tests/pseudofiles/test.nix b/tests/pseudofiles/fixture.nix diff --git a/tests/pseudofiles/run.sh b/tests/pseudofiles/run.sh @@ -1,16 +0,0 @@ -set -e - -expr=$(cat <<"EXPR" -let - overlay = import <liminix/overlay.nix>; - nixpkgs = import <nixpkgs> { overlays = [overlay]; }; -in nixpkgs.pkgs.callPackage ./test.nix {} -EXPR - ) - -NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 nix-build -E "${expr}" -o result $* -diff result result.expected -test -f /tmp/out.squashfs && rm /tmp/out.squashfs -nix-shell -p squashfsTools -p qprint --run "mksquashfs - /tmp/out.squashfs -p '/ d 755 0 0' -pf result -quiet -no-progress" -foo="$(nix-shell -p squashfsTools --run 'unsquashfs -cat /tmp/out.squashfs service/s6-linux-init-runleveld/run')" -test "$foo" = "$(printf "hello\nworld")" diff --git a/tests/pseudofiles/test.nix b/tests/pseudofiles/test.nix @@ -1,47 +1,20 @@ { - pseudofile -}: let - inherit (pseudofile) dir; - structure = { - service = dir { - s6-linux-init-runleveld = dir { - notification-fd = { file = "3"; }; - run = { - file = '' - hello - world - ''; - mode = "0755"; - }; - }; - s6-linux-init-shutdownd = dir { - fifo = { - type = "i"; - subtype = "f"; - mode = "0600"; - }; - run = { - file = '' - s6-linux-init/bin/s6-linux-init-shutdownd -c "/etc/s6-linux-init/current" -g 3000 - ''; - mode = "0755"; - }; - - }; - s6-svscan-log = dir { - fifo = { - type = "i"; - subtype = "f"; - mode = "0600"; - }; - notification-fd = { file = "3"; }; - run = { - file = '' - gdsgdfgsdgf - ''; - }; - }; - }; - uncaught-logs = (dir {}) // {mode = "2750";}; - }; -in pseudofile.write "pseudo.s6-init" structure + liminix +, nixpkgs +}: +let + overlay = import "${liminix}/overlay.nix"; + nixpkgs = import <nixpkgs> { overlays = [overlay]; }; + fixture = nixpkgs.callPackage ./fixture.nix {}; + check = nixpkgs.runCommand "check" { + nativeBuildInputs = with nixpkgs; [ squashfsTools qprint ] ; + } '' +set -e +diff ${fixture} ${./result.expected} +test -f /tmp/out.squashfs && rm /tmp/out.squashfs +mksquashfs - /tmp/out.squashfs -p '/ d 755 0 0' -pf ${fixture} -quiet -no-progress +foo="$(unsquashfs -cat /tmp/out.squashfs service/s6-linux-init-runleveld/run)" +test "$foo" = "$(printf "hello\nworld")" +date > $out +''; +in { inherit check; }