From 5f8841c7941f86b8b1eb1b8bab366efbc0e12496 Mon Sep 17 00:00:00 2001 From: DavHau Date: Sat, 23 Apr 2022 15:09:55 +0200 Subject: [PATCH] optimize tests for examples --- examples/mattermost-webapp/flake.nix | 3 ++- examples/ripgrep/flake.nix | 2 +- tests/examples/default.nix | 35 ++++++++++++++++++++-------- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/examples/mattermost-webapp/flake.nix b/examples/mattermost-webapp/flake.nix index 1f49918a..cc53ac63 100644 --- a/examples/mattermost-webapp/flake.nix +++ b/examples/mattermost-webapp/flake.nix @@ -19,6 +19,7 @@ source = src; }) // { - checks = self.packages; + # checks are too expensive + # checks = self.packages; }; } diff --git a/examples/ripgrep/flake.nix b/examples/ripgrep/flake.nix index da858fe8..0514d3d3 100644 --- a/examples/ripgrep/flake.nix +++ b/examples/ripgrep/flake.nix @@ -25,6 +25,6 @@ ]; }) // { - checks = self.packages; + checks.x86_64-linux.ripgrep = self.packages.x86_64-linux.ripgrep; }; } diff --git a/tests/examples/default.nix b/tests/examples/default.nix index f7ef4b3c..529d88a6 100644 --- a/tests/examples/default.nix +++ b/tests/examples/default.nix @@ -1,6 +1,8 @@ { self, lib, + async, + bash, coreutils, git, nix, @@ -13,6 +15,8 @@ in utils.writePureShellScript [ + async + bash coreutils git nix @@ -24,16 +28,27 @@ in examples=$1 fi + S=$(mktemp) + async -s=$S server --start -j$(nproc) + sleep 1 + for dir in $examples; do - echo -e "\ntesting example for $dir" - mkdir tmp - cp ${examples}/$dir/* ./tmp/ - chmod -R +w ./tmp - cd ./tmp - nix flake lock --override-input dream2nix ${../../.} - nix run .#resolveImpure - nix flake check - cd - - rm -r tmp + async -s=$S cmd -- bash -c " + echo -e \"\ntesting example for $dir\" + tmp=\$(mktemp -d) + echo \"tempdir: \$tmp\" + mkdir \$tmp + cp ${examples}/$dir/* \$tmp/ + chmod -R +w \$tmp + cd \$tmp + nix flake lock --override-input dream2nix ${../../.} + nix run .#resolveImpure + nix flake check + cd - + rm -r \$tmp + " done + + async -s=$S wait + rm $S ''