From 77d8c00c535ddb9e76c16374327a39aaf9666d8e Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Wed, 8 Dec 2021 04:07:31 +0100 Subject: [PATCH] run-tests.sh: extract `checkFlakeSupport` Required by the following commit. --- test/run-tests.sh | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/test/run-tests.sh b/test/run-tests.sh index 22d8803..c052079 100755 --- a/test/run-tests.sh +++ b/test/run-tests.sh @@ -246,12 +246,25 @@ vmTestNixExpr() { EOF } -flake() { - if [[ $(nix flake 2>&1) != *"requires a sub-command"* ]]; then - echo "Skipping flake test. Nix flake support is not enabled." - else - nix flake check "$scriptDir/.." +checkFlakeSupport() { + testName=$1 + if [[ ! -v hasFlakes ]]; then + if [[ $(nix flake 2>&1) == *"requires a sub-command"* ]]; then + hasFlakes=1 + else + hasFlakes= + fi fi + if [[ ! $hasFlakes ]]; then + echo "Skipping test '$testName'. Nix flake support is not enabled." + return 1 + fi +} + +flake() { + if ! checkFlakeSupport "flake"; then return; fi + + nix flake check "$scriptDir/.." } # A basic subset of tests to keep the total runtime within