tangled
alpha
login
or
join now
tjh.dev
/
nixpkgs
0
fork
atom
nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
0
fork
atom
overview
issues
pulls
pipelines
Add tests for the new module system improvements.
Nicolas B. Pierron
11 years ago
7f1a782d
05e8a48f
+60
7 changed files
expand all
collapse all
unified
split
lib
tests
modules
custom-arg-define-enable.nix
define-if-loaOfSub-foo-enable.nix
define-loaOfSub-foo-enable-if.nix
define-loaOfSub-foo-if-enable.nix
define-loaOfSub-if-foo-enable.nix
define-module-check.nix
modules.sh
+25
lib/tests/modules.sh
reviewed
···
57
57
fi
58
58
}
59
59
60
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
63
+
64
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
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
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
84
+
85
85
+
# Check mkIf with submodules.
86
86
+
checkConfigError 'attribute .*foo.* .* not found' config.loaOfSub.foo.enable ./declare-enable.nix ./declare-loaOfSub-any-enable.nix
87
87
+
set -- config.loaOfSub.foo.enable ./declare-enable.nix ./declare-loaOfSub-any-enable.nix
88
88
+
checkConfigError 'attribute .*foo.* .* not found' "$@" ./define-if-loaOfSub-foo-enable.nix
89
89
+
checkConfigError 'attribute .*foo.* .* not found' "$@" ./define-loaOfSub-if-foo-enable.nix
90
90
+
checkConfigError 'attribute .*foo.* .* not found' "$@" ./define-loaOfSub-foo-if-enable.nix
91
91
+
checkConfigOutput 'false' "$@" ./define-loaOfSub-foo-enable-if.nix
92
92
+
checkConfigOutput 'true' "$@" ./define-enable.nix ./define-if-loaOfSub-foo-enable.nix
93
93
+
checkConfigOutput 'true' "$@" ./define-enable.nix ./define-loaOfSub-if-foo-enable.nix
94
94
+
checkConfigOutput 'true' "$@" ./define-enable.nix ./define-loaOfSub-foo-if-enable.nix
95
95
+
checkConfigOutput 'true' "$@" ./define-enable.nix ./define-loaOfSub-foo-enable-if.nix
96
96
+
97
97
+
# Check _module.args.
98
98
+
checkConfigOutput "true" config.enable ./declare-enable.nix ./custom-arg-define-enable.nix
99
99
+
100
100
+
# Check _module.check.
101
101
+
set -- config.enable ./declare-enable.nix ./define-enable.nix ./define-loaOfSub-foo.nix
102
102
+
checkConfigError 'The option .* defined in .* does not exist.' "$@"
103
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
reviewed
···
1
1
+
{ lib, custom, ... }:
2
2
+
3
3
+
{
4
4
+
config = {
5
5
+
_module.args.custom = true;
6
6
+
enable = custom;
7
7
+
};
8
8
+
}
+5
lib/tests/modules/define-if-loaOfSub-foo-enable.nix
reviewed
···
1
1
+
{ config, lib, ... }:
2
2
+
3
3
+
lib.mkIf config.enable {
4
4
+
loaOfSub.foo.enable = true;
5
5
+
}
+5
lib/tests/modules/define-loaOfSub-foo-enable-if.nix
reviewed
···
1
1
+
{ config, lib, ... }:
2
2
+
3
3
+
{
4
4
+
loaOfSub.foo.enable = lib.mkIf config.enable true;
5
5
+
}
+7
lib/tests/modules/define-loaOfSub-foo-if-enable.nix
reviewed
···
1
1
+
{ config, lib, ... }:
2
2
+
3
3
+
{
4
4
+
loaOfSub.foo = lib.mkIf config.enable {
5
5
+
enable = true;
6
6
+
};
7
7
+
}
+7
lib/tests/modules/define-loaOfSub-if-foo-enable.nix
reviewed
···
1
1
+
{ config, lib, ... }:
2
2
+
3
3
+
{
4
4
+
loaOfSub = lib.mkIf config.enable {
5
5
+
foo.enable = true;
6
6
+
};
7
7
+
}
+3
lib/tests/modules/define-module-check.nix
reviewed
···
1
1
+
{
2
2
+
_module.check = false;
3
3
+
}