mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-11 20:25:32 +03:00
lib/modules: Rename _module.assertions to _module.checks
This commit is contained in:
parent
3e39d6efdf
commit
c9cc8969b4
16 changed files with 108 additions and 76 deletions
|
@ -277,9 +277,9 @@ checkConfigOutput baz config.value.nested.bar.baz ./types-anything/mk-mods.nix
|
|||
|
||||
## Module assertions
|
||||
# Check that assertions are triggered by default for just evaluating config
|
||||
checkConfigError 'Failed assertions:\n- \[test\] Assertion failed' config ./assertions/simple.nix
|
||||
checkConfigError 'Failed checks:\n- \[test\] Assertion failed' config ./assertions/simple.nix
|
||||
# Check that assertions are only triggered if they have a triggerPath that's evaluated
|
||||
checkConfigError 'Failed assertions:\n- \[test\] Assertion failed' config.foo ./assertions/trigger-lazy.nix
|
||||
checkConfigError 'Failed checks:\n- \[test\] Assertion failed' config.foo ./assertions/trigger-lazy.nix
|
||||
checkConfigOutput true config.bar ./assertions/trigger-lazy.nix
|
||||
|
||||
# The assertions enable condition should only be evaluated if the trigger is evaluated
|
||||
|
@ -294,23 +294,23 @@ checkConfigCodeOutErr 0 '{ }' 'warning: \[test\] Warning message' config ./asser
|
|||
|
||||
# A triggerPath can be set to a submodule path
|
||||
checkConfigOutput '{ baz = <CODE>; }' config.foo.bar ./assertions/trigger-submodule.nix
|
||||
checkConfigError 'Failed assertions:\n- \[test\] Assertion failed' config.foo.bar.baz ./assertions/trigger-submodule.nix
|
||||
checkConfigError 'Failed checks:\n- \[test\] Assertion failed' config.foo.bar.baz ./assertions/trigger-submodule.nix
|
||||
|
||||
# Check that multiple assertions and warnings can be triggered at once
|
||||
checkConfigError 'Failed assertions:\n- \[test1\] Assertion 1 failed\n- \[test2\] Assertion 2 failed' config ./assertions/multi.nix
|
||||
checkConfigError 'Failed checks:\n- \[test1\] Assertion 1 failed\n- \[test2\] Assertion 2 failed' config ./assertions/multi.nix
|
||||
checkConfigError 'trace: warning: \[test3\] Warning 3 failed\ntrace: warning: \[test4\] Warning 4 failed' config ./assertions/multi.nix
|
||||
|
||||
# Submodules should be able to trigger assertions and display the submodule prefix in their error
|
||||
checkConfigError 'Failed assertions:\n- \[foo/test\] Assertion failed' config.foo ./assertions/submodule.nix
|
||||
checkConfigError 'Failed assertions:\n- \[foo.bar/test\] Assertion failed' config.foo.bar ./assertions/submodule-attrsOf.nix
|
||||
checkConfigError 'Failed assertions:\n- \[foo.bar.baz/test\] Assertion failed' config.foo.bar.baz ./assertions/submodule-attrsOf-attrsOf.nix
|
||||
checkConfigError 'Failed checks:\n- \[foo/test\] Assertion failed' config.foo ./assertions/submodule.nix
|
||||
checkConfigError 'Failed checks:\n- \[foo.bar/test\] Assertion failed' config.foo.bar ./assertions/submodule-attrsOf.nix
|
||||
checkConfigError 'Failed checks:\n- \[foo.bar.baz/test\] Assertion failed' config.foo.bar.baz ./assertions/submodule-attrsOf-attrsOf.nix
|
||||
|
||||
# Assertions aren't triggered when the trigger path is only evaluated from within the same module evaluation
|
||||
# This behavior is necessary to allow assertions to depend on config values. This could potentially be changed in the future if all of NixOS' assertions are rewritten to not depend on any config values
|
||||
checkConfigOutput true config.bar ./assertions/non-cascading.nix
|
||||
|
||||
# Assertions with an attribute starting with _ shouldn't have their name displayed
|
||||
checkConfigError 'Failed assertions:\n- Assertion failed' config ./assertions/underscore-attributes.nix
|
||||
checkConfigError 'Failed checks:\n- Assertion failed' config ./assertions/underscore-attributes.nix
|
||||
|
||||
cat <<EOF
|
||||
====== module tests ======
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue