diff options
author | Nicolas B. Pierron <nicolas.b.pierron@gmail.com> | 2015-03-16 22:38:41 +0100 |
---|---|---|
committer | Nicolas B. Pierron <nicolas.b.pierron@gmail.com> | 2015-03-16 22:38:41 +0100 |
commit | 7f1a782d91c537eb6972b8acd83e1957a65a93e4 (patch) | |
tree | 8abc7b9905c7eb54294702ef2d1d57faf123137a /lib/tests | |
parent | 05e8a48fb4af4c20134362c77ba6c5b4c6e49268 (diff) |
Add tests for the new module system improvements.
Diffstat (limited to 'lib/tests')
-rwxr-xr-x | lib/tests/modules.sh | 25 | ||||
-rw-r--r-- | lib/tests/modules/custom-arg-define-enable.nix | 8 | ||||
-rw-r--r-- | lib/tests/modules/define-if-loaOfSub-foo-enable.nix | 5 | ||||
-rw-r--r-- | lib/tests/modules/define-loaOfSub-foo-enable-if.nix | 5 | ||||
-rw-r--r-- | lib/tests/modules/define-loaOfSub-foo-if-enable.nix | 7 | ||||
-rw-r--r-- | lib/tests/modules/define-loaOfSub-if-foo-enable.nix | 7 | ||||
-rw-r--r-- | lib/tests/modules/define-module-check.nix | 3 |
7 files changed, 60 insertions, 0 deletions
diff --git a/lib/tests/modules.sh b/lib/tests/modules.sh index 58231a356369..66c6f560fbe8 100755 --- a/lib/tests/modules.sh +++ b/lib/tests/modules.sh @@ -57,13 +57,17 @@ checkConfigError() { fi } +# Check boolean option. checkConfigOutput "false" config.enable ./declare-enable.nix checkConfigError 'The option .* defined in .* does not exist.' config.enable ./define-enable.nix + +# Check mkForce without submodules. set -- config.enable ./declare-enable.nix ./define-enable.nix checkConfigOutput "true" "$@" checkConfigOutput "false" "$@" ./define-force-enable.nix checkConfigOutput "false" "$@" ./define-enable-force.nix +# Check mkForce with option and submodules. 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 @@ -73,6 +77,7 @@ checkConfigOutput 'false' "$@" ./define-loaOfSub-force-foo-enable.nix checkConfigOutput 'false' "$@" ./define-loaOfSub-foo-force-enable.nix checkConfigOutput 'false' "$@" ./define-loaOfSub-foo-enable-force.nix +# Check overriding effect of mkForce on submodule definitions. 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 @@ -82,6 +87,26 @@ checkConfigError 'attribute .*bar.* .* not found' "$@" ./define-loaOfSub-force-f checkConfigOutput 'true' "$@" ./define-loaOfSub-foo-force-enable.nix checkConfigOutput 'true' "$@" ./define-loaOfSub-foo-enable-force.nix +# Check mkIf with submodules. +checkConfigError 'attribute .*foo.* .* not found' config.loaOfSub.foo.enable ./declare-enable.nix ./declare-loaOfSub-any-enable.nix +set -- config.loaOfSub.foo.enable ./declare-enable.nix ./declare-loaOfSub-any-enable.nix +checkConfigError 'attribute .*foo.* .* not found' "$@" ./define-if-loaOfSub-foo-enable.nix +checkConfigError 'attribute .*foo.* .* not found' "$@" ./define-loaOfSub-if-foo-enable.nix +checkConfigError 'attribute .*foo.* .* not found' "$@" ./define-loaOfSub-foo-if-enable.nix +checkConfigOutput 'false' "$@" ./define-loaOfSub-foo-enable-if.nix +checkConfigOutput 'true' "$@" ./define-enable.nix ./define-if-loaOfSub-foo-enable.nix +checkConfigOutput 'true' "$@" ./define-enable.nix ./define-loaOfSub-if-foo-enable.nix +checkConfigOutput 'true' "$@" ./define-enable.nix ./define-loaOfSub-foo-if-enable.nix +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 + +# Check _module.check. +set -- config.enable ./declare-enable.nix ./define-enable.nix ./define-loaOfSub-foo.nix +checkConfigError 'The option .* defined in .* does not exist.' "$@" +checkConfigOutput "true" "$@" ./define-module-check.nix + cat <<EOF ====== module tests ====== $pass Pass diff --git a/lib/tests/modules/custom-arg-define-enable.nix b/lib/tests/modules/custom-arg-define-enable.nix new file mode 100644 index 000000000000..f04d30dd9b9f --- /dev/null +++ b/lib/tests/modules/custom-arg-define-enable.nix @@ -0,0 +1,8 @@ +{ lib, custom, ... }: + +{ + config = { + _module.args.custom = true; + enable = custom; + }; +} diff --git a/lib/tests/modules/define-if-loaOfSub-foo-enable.nix b/lib/tests/modules/define-if-loaOfSub-foo-enable.nix new file mode 100644 index 000000000000..4288d74dec00 --- /dev/null +++ b/lib/tests/modules/define-if-loaOfSub-foo-enable.nix @@ -0,0 +1,5 @@ +{ config, lib, ... }: + +lib.mkIf config.enable { + loaOfSub.foo.enable = true; +} diff --git a/lib/tests/modules/define-loaOfSub-foo-enable-if.nix b/lib/tests/modules/define-loaOfSub-foo-enable-if.nix new file mode 100644 index 000000000000..44b2c96cd021 --- /dev/null +++ b/lib/tests/modules/define-loaOfSub-foo-enable-if.nix @@ -0,0 +1,5 @@ +{ config, lib, ... }: + +{ + loaOfSub.foo.enable = lib.mkIf config.enable true; +} diff --git a/lib/tests/modules/define-loaOfSub-foo-if-enable.nix b/lib/tests/modules/define-loaOfSub-foo-if-enable.nix new file mode 100644 index 000000000000..236b2840ee51 --- /dev/null +++ b/lib/tests/modules/define-loaOfSub-foo-if-enable.nix @@ -0,0 +1,7 @@ +{ config, lib, ... }: + +{ + loaOfSub.foo = lib.mkIf config.enable { + enable = true; + }; +} diff --git a/lib/tests/modules/define-loaOfSub-if-foo-enable.nix b/lib/tests/modules/define-loaOfSub-if-foo-enable.nix new file mode 100644 index 000000000000..bd2d068d31a2 --- /dev/null +++ b/lib/tests/modules/define-loaOfSub-if-foo-enable.nix @@ -0,0 +1,7 @@ +{ config, lib, ... }: + +{ + loaOfSub = lib.mkIf config.enable { + foo.enable = true; + }; +} diff --git a/lib/tests/modules/define-module-check.nix b/lib/tests/modules/define-module-check.nix new file mode 100644 index 000000000000..5a0707c975fa --- /dev/null +++ b/lib/tests/modules/define-module-check.nix @@ -0,0 +1,3 @@ +{ + _module.check = false; +} |