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-05-13 22:44:04 +0200
committerNicolas B. Pierron <nicolas.b.pierron@gmail.com>2015-07-14 15:07:54 +0200
commita6b455bbaecb42679e5d1ade51433d62ee21bd03 (patch)
tree7420ee8b005df891693d1fdfc49f1084c611d936 /lib/tests/modules.sh
parent2fa88f65eab650de535df838ae8cd0d633fa6aad (diff)
downloadnixpkgs-a6b455bbaecb42679e5d1ade51433d62ee21bd03.tar
nixpkgs-a6b455bbaecb42679e5d1ade51433d62ee21bd03.tar.gz
nixpkgs-a6b455bbaecb42679e5d1ade51433d62ee21bd03.tar.bz2
nixpkgs-a6b455bbaecb42679e5d1ade51433d62ee21bd03.tar.lz
nixpkgs-a6b455bbaecb42679e5d1ade51433d62ee21bd03.tar.xz
nixpkgs-a6b455bbaecb42679e5d1ade51433d62ee21bd03.tar.zst
nixpkgs-a6b455bbaecb42679e5d1ade51433d62ee21bd03.zip
NixOS modules: Add error context on module arguments evaluation.
Diffstat (limited to 'lib/tests/modules.sh')
-rwxr-xr-xlib/tests/modules.sh12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/tests/modules.sh b/lib/tests/modules.sh
index 66c6f560fbe..65de8e378c7 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 --timeout 1 -E "$script" -A "$attr" --eval-only
+    nix-instantiate --timeout 1 -E "$script" -A "$attr" --eval-only --show-trace
 }
 
 reportFailure() {
@@ -100,7 +100,15 @@ checkConfigOutput 'true' "$@" ./define-enable.nix ./define-loaOfSub-foo-if-enabl
 checkConfigOutput 'true' "$@" ./define-enable.nix ./define-loaOfSub-foo-enable-if.nix
 
 # Check _module.args.
-checkConfigOutput "true" config.enable ./declare-enable.nix ./custom-arg-define-enable.nix
+set -- config.enable ./declare-enable.nix ./define-enable-with-custom-arg.nix
+checkConfigError 'while evaluating the module argument .*custom.* in .*define-enable-with-custom-arg.nix.*:' "$@"
+checkConfigOutput "true" "$@" ./define-_module-args-custom.nix
+
+# Check that using _module.args on imports cause infinite recursions, with
+# the proper error context.
+set -- "$@" ./define-_module-args-custom.nix ./import-custom-arg.nix
+checkConfigError 'while evaluating the module argument .*custom.* in .*import-custom-arg.nix.*:' "$@"
+checkConfigError 'infinite recursion encountered' "$@"
 
 # Check _module.check.
 set -- config.enable ./declare-enable.nix ./define-enable.nix ./define-loaOfSub-foo.nix