nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix

Add tests for the new module system improvements.

+60
+25
lib/tests/modules.sh
··· 57 57 fi 58 58 } 59 59 60 + # Check boolean option. 60 61 checkConfigOutput "false" config.enable ./declare-enable.nix 61 62 checkConfigError 'The option .* defined in .* does not exist.' config.enable ./define-enable.nix 63 + 64 + # Check mkForce without submodules. 62 65 set -- config.enable ./declare-enable.nix ./define-enable.nix 63 66 checkConfigOutput "true" "$@" 64 67 checkConfigOutput "false" "$@" ./define-force-enable.nix 65 68 checkConfigOutput "false" "$@" ./define-enable-force.nix 66 69 70 + # Check mkForce with option and submodules. 67 71 checkConfigError 'attribute .*foo.* .* not found' config.loaOfSub.foo.enable ./declare-loaOfSub-any-enable.nix 68 72 checkConfigOutput 'false' config.loaOfSub.foo.enable ./declare-loaOfSub-any-enable.nix ./define-loaOfSub-foo.nix 69 73 set -- config.loaOfSub.foo.enable ./declare-loaOfSub-any-enable.nix ./define-loaOfSub-foo-enable.nix ··· 77 73 checkConfigOutput 'false' "$@" ./define-loaOfSub-foo-force-enable.nix 78 74 checkConfigOutput 'false' "$@" ./define-loaOfSub-foo-enable-force.nix 79 75 76 + # Check overriding effect of mkForce on submodule definitions. 80 77 checkConfigError 'attribute .*bar.* .* not found' config.loaOfSub.bar.enable ./declare-loaOfSub-any-enable.nix ./define-loaOfSub-foo.nix 81 78 checkConfigOutput 'false' config.loaOfSub.bar.enable ./declare-loaOfSub-any-enable.nix ./define-loaOfSub-foo.nix ./define-loaOfSub-bar.nix 82 79 set -- config.loaOfSub.bar.enable ./declare-loaOfSub-any-enable.nix ./define-loaOfSub-foo.nix ./define-loaOfSub-bar-enable.nix ··· 86 81 checkConfigError 'attribute .*bar.* .* not found' "$@" ./define-loaOfSub-force-foo-enable.nix 87 82 checkConfigOutput 'true' "$@" ./define-loaOfSub-foo-force-enable.nix 88 83 checkConfigOutput 'true' "$@" ./define-loaOfSub-foo-enable-force.nix 84 + 85 + # Check mkIf with submodules. 86 + checkConfigError 'attribute .*foo.* .* not found' config.loaOfSub.foo.enable ./declare-enable.nix ./declare-loaOfSub-any-enable.nix 87 + set -- config.loaOfSub.foo.enable ./declare-enable.nix ./declare-loaOfSub-any-enable.nix 88 + checkConfigError 'attribute .*foo.* .* not found' "$@" ./define-if-loaOfSub-foo-enable.nix 89 + checkConfigError 'attribute .*foo.* .* not found' "$@" ./define-loaOfSub-if-foo-enable.nix 90 + checkConfigError 'attribute .*foo.* .* not found' "$@" ./define-loaOfSub-foo-if-enable.nix 91 + checkConfigOutput 'false' "$@" ./define-loaOfSub-foo-enable-if.nix 92 + checkConfigOutput 'true' "$@" ./define-enable.nix ./define-if-loaOfSub-foo-enable.nix 93 + checkConfigOutput 'true' "$@" ./define-enable.nix ./define-loaOfSub-if-foo-enable.nix 94 + checkConfigOutput 'true' "$@" ./define-enable.nix ./define-loaOfSub-foo-if-enable.nix 95 + checkConfigOutput 'true' "$@" ./define-enable.nix ./define-loaOfSub-foo-enable-if.nix 96 + 97 + # Check _module.args. 98 + checkConfigOutput "true" config.enable ./declare-enable.nix ./custom-arg-define-enable.nix 99 + 100 + # Check _module.check. 101 + set -- config.enable ./declare-enable.nix ./define-enable.nix ./define-loaOfSub-foo.nix 102 + checkConfigError 'The option .* defined in .* does not exist.' "$@" 103 + checkConfigOutput "true" "$@" ./define-module-check.nix 89 104 90 105 cat <<EOF 91 106 ====== module tests ======
+8
lib/tests/modules/custom-arg-define-enable.nix
··· 1 + { lib, custom, ... }: 2 + 3 + { 4 + config = { 5 + _module.args.custom = true; 6 + enable = custom; 7 + }; 8 + }
+5
lib/tests/modules/define-if-loaOfSub-foo-enable.nix
··· 1 + { config, lib, ... }: 2 + 3 + lib.mkIf config.enable { 4 + loaOfSub.foo.enable = true; 5 + }
+5
lib/tests/modules/define-loaOfSub-foo-enable-if.nix
··· 1 + { config, lib, ... }: 2 + 3 + { 4 + loaOfSub.foo.enable = lib.mkIf config.enable true; 5 + }
+7
lib/tests/modules/define-loaOfSub-foo-if-enable.nix
··· 1 + { config, lib, ... }: 2 + 3 + { 4 + loaOfSub.foo = lib.mkIf config.enable { 5 + enable = true; 6 + }; 7 + }
+7
lib/tests/modules/define-loaOfSub-if-foo-enable.nix
··· 1 + { config, lib, ... }: 2 + 3 + { 4 + loaOfSub = lib.mkIf config.enable { 5 + foo.enable = true; 6 + }; 7 + }
+3
lib/tests/modules/define-module-check.nix
··· 1 + { 2 + _module.check = false; 3 + }