From d8008dee9f9cc9faffda122bf17cbb7531021889 Mon Sep 17 00:00:00 2001 From: Tomo <68489118+Tomodachi94@users.noreply.github.com> Date: Sat, 25 May 2024 14:32:31 -0700 Subject: [PATCH] sanjuuni: add run-on-nixos-artwork test Tests the program by running it on a handful of entries from the `nixos-artwork` attrset, and then test that the resulting Lua files can be evaluated with `loadfile` in standard Lua. --- pkgs/by-name/sa/sanjuuni/package.nix | 5 +++ .../sanjuuni/tests/run-on-nixos-artwork.nix | 34 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 pkgs/by-name/sa/sanjuuni/tests/run-on-nixos-artwork.nix diff --git a/pkgs/by-name/sa/sanjuuni/package.nix b/pkgs/by-name/sa/sanjuuni/package.nix index e43efa771b57..a3806052f900 100644 --- a/pkgs/by-name/sa/sanjuuni/package.nix +++ b/pkgs/by-name/sa/sanjuuni/package.nix @@ -8,6 +8,7 @@ poco, ocl-icd, opencl-clhpp, + callPackage, }: stdenv.mkDerivation rec { @@ -38,6 +39,10 @@ stdenv.mkDerivation rec { runHook postInstall ''; + passthru.tests = { + run-on-nixos-artwork = callPackage ./tests/run-on-nixos-artwork.nix { }; + }; + meta = with lib; { homepage = "https://github.com/MCJack123/sanjuuni"; description = "Command-line tool that converts images and videos into a format that can be displayed in ComputerCraft"; diff --git a/pkgs/by-name/sa/sanjuuni/tests/run-on-nixos-artwork.nix b/pkgs/by-name/sa/sanjuuni/tests/run-on-nixos-artwork.nix new file mode 100644 index 000000000000..e64c6c563df4 --- /dev/null +++ b/pkgs/by-name/sa/sanjuuni/tests/run-on-nixos-artwork.nix @@ -0,0 +1,34 @@ +{ + runCommand, + sanjuuni, + nixos-artwork, + lua5_2, +}: +let + makeCommand = derivation: baseFilename: '' + echo "sanjuuni-test-run-on-nixos-artwork: Running Sanjuuni on ${derivation}/share/backgrounds/nixos/${baseFilename}.png" + sanjuuni --lua --disable-opencl \ + --input ${derivation}/share/backgrounds/nixos/${baseFilename}.png \ + --output $out/${baseFilename}.lua + echo "sanjuuni-test-run-on-nixos-artwork: Checking syntax on $out/${baseFilename}.lua" + lua -e "loadfile(\"$out/${baseFilename}.lua\")" + ''; +in +runCommand "sanjuuni-test-run-on-nixos-artwork" + { + nativeBuildInputs = [ + sanjuuni + lua5_2 + nixos-artwork.wallpapers.simple-blue + nixos-artwork.wallpapers.simple-red + nixos-artwork.wallpapers.simple-dark-gray + nixos-artwork.wallpapers.stripes + ]; + } + '' + mkdir -p $out + ${makeCommand nixos-artwork.wallpapers.simple-blue "nix-wallpaper-simple-blue"} + ${makeCommand nixos-artwork.wallpapers.simple-red "nix-wallpaper-simple-red"} + ${makeCommand nixos-artwork.wallpapers.simple-dark-gray "nix-wallpaper-simple-dark-gray"} + ${makeCommand nixos-artwork.wallpapers.stripes "nix-wallpaper-stripes"} + ''