summary refs log tree commit diff
path: root/lib/tests/modules.sh
diff options
context:
space:
mode:
authorNicolas B. Pierron <nicolas.b.pierron@gmail.com>2015-02-08 22:51:20 +0100
committerNicolas B. Pierron <nicolas.b.pierron@gmail.com>2015-02-09 00:07:44 +0100
commitde0f122b016c88ffdfa092a2acc0d6bd81e32613 (patch)
tree655b7fb13fbbb720cf8ece266d5383c4b43d0277 /lib/tests/modules.sh
parent6d15e32536abbcef919b706f073c7fea46cf9229 (diff)
downloadnixpkgs-de0f122b016c88ffdfa092a2acc0d6bd81e32613.tar
nixpkgs-de0f122b016c88ffdfa092a2acc0d6bd81e32613.tar.gz
nixpkgs-de0f122b016c88ffdfa092a2acc0d6bd81e32613.tar.bz2
nixpkgs-de0f122b016c88ffdfa092a2acc0d6bd81e32613.tar.lz
nixpkgs-de0f122b016c88ffdfa092a2acc0d6bd81e32613.tar.xz
nixpkgs-de0f122b016c88ffdfa092a2acc0d6bd81e32613.tar.zst
nixpkgs-de0f122b016c88ffdfa092a2acc0d6bd81e32613.zip
Issue #6161 - Register lib tests as release blockers.
Diffstat (limited to 'lib/tests/modules.sh')
-rwxr-xr-xlib/tests/modules.sh31
1 files changed, 16 insertions, 15 deletions
diff --git a/lib/tests/modules.sh b/lib/tests/modules.sh
index 9c69df2bd9b..58231a35636 100755
--- a/lib/tests/modules.sh
+++ b/lib/tests/modules.sh
@@ -12,7 +12,7 @@ evalConfig() {
     local attr=$1
     shift;
     local script="import ./default.nix { modules = [ $@ ];}"
-    nix-instantiate -E "$script" -A "$attr" --eval-only
+    nix-instantiate --timeout 1 -E "$script" -A "$attr" --eval-only
 }
 
 reportFailure() {
@@ -39,31 +39,32 @@ checkConfigOutput() {
 
 checkConfigError() {
     local errorContains=$1
+    local err=""
     shift;
-    if evalConfig "$@" 1>/dev/null 2>&1; then
+    if err==$(evalConfig "$@" 2>&1 >/dev/null); then
         echo 2>&1 "error: Expected error code, got exit code 0, while evaluating"
         reportFailure "$@"
         return 1
-    fi
-
-    if evalConfig "$@" 2>&1 >/dev/null | grep --silent "$errorContains" ; then
-        pass=$((pass + 1))
-        return 0;
     else
-        echo 2>&1 "error: Expected error matching '$errorContains', while evaluating"
-        reportFailure "$@"
-        return 1
+        if echo "$err" | grep --silent "$errorContains" ; then
+            pass=$((pass + 1))
+            return 0;
+        else
+            echo 2>&1 "error: Expected error matching '$errorContains', while evaluating"
+            reportFailure "$@"
+            return 1
+        fi
     fi
 }
 
-checkConfigOutput "false" config.enable 
+checkConfigOutput "false" config.enable ./declare-enable.nix
 checkConfigError 'The option .* defined in .* does not exist.' config.enable ./define-enable.nix
 set -- config.enable ./declare-enable.nix ./define-enable.nix
 checkConfigOutput "true" "$@"
 checkConfigOutput "false" "$@" ./define-force-enable.nix
 checkConfigOutput "false" "$@" ./define-enable-force.nix
 
-checkConfigError 'attribute .foo. .* not found' config.loaOfSub.foo.enable ./declare-loaOfSub-any-enable.nix
+checkConfigError 'attribute .*foo.* .* not found' config.loaOfSub.foo.enable ./declare-loaOfSub-any-enable.nix
 checkConfigOutput 'false' config.loaOfSub.foo.enable ./declare-loaOfSub-any-enable.nix ./define-loaOfSub-foo.nix
 set -- config.loaOfSub.foo.enable ./declare-loaOfSub-any-enable.nix ./define-loaOfSub-foo-enable.nix
 checkConfigOutput 'true' "$@"
@@ -72,12 +73,12 @@ checkConfigOutput 'false' "$@" ./define-loaOfSub-force-foo-enable.nix
 checkConfigOutput 'false' "$@" ./define-loaOfSub-foo-force-enable.nix
 checkConfigOutput 'false' "$@" ./define-loaOfSub-foo-enable-force.nix
 
-checkConfigError 'attribute .bar. .* not found' config.loaOfSub.bar.enable ./declare-loaOfSub-any-enable.nix ./define-loaOfSub-foo.nix
+checkConfigError 'attribute .*bar.* .* not found' config.loaOfSub.bar.enable ./declare-loaOfSub-any-enable.nix ./define-loaOfSub-foo.nix
 checkConfigOutput 'false' config.loaOfSub.bar.enable ./declare-loaOfSub-any-enable.nix ./define-loaOfSub-foo.nix ./define-loaOfSub-bar.nix
 set -- config.loaOfSub.bar.enable ./declare-loaOfSub-any-enable.nix ./define-loaOfSub-foo.nix ./define-loaOfSub-bar-enable.nix
 checkConfigOutput 'true' "$@"
-checkConfigError 'attribute .bar. .* not found' "$@" ./define-force-loaOfSub-foo-enable.nix
-checkConfigError 'attribute .bar. .* not found' "$@" ./define-loaOfSub-force-foo-enable.nix
+checkConfigError 'attribute .*bar.* .* not found' "$@" ./define-force-loaOfSub-foo-enable.nix
+checkConfigError 'attribute .*bar.* .* not found' "$@" ./define-loaOfSub-force-foo-enable.nix
 checkConfigOutput 'true' "$@" ./define-loaOfSub-foo-force-enable.nix
 checkConfigOutput 'true' "$@" ./define-loaOfSub-foo-enable-force.nix