diff options
-rwxr-xr-x | lib/tests/modules.sh | 7 | ||||
-rw-r--r-- | lib/tests/modules/doRename-basic.nix | 11 | ||||
-rw-r--r-- | lib/tests/modules/doRename-warnings.nix | 14 |
3 files changed, 32 insertions, 0 deletions
diff --git a/lib/tests/modules.sh b/lib/tests/modules.sh index c9ea674ee10..6d2eb24db55 100755 --- a/lib/tests/modules.sh +++ b/lib/tests/modules.sh @@ -348,6 +348,13 @@ checkConfigOutput 'ok' config.freeformItems.foo.bar ./adhoc-freeformType-survive # because of an `extendModules` bug, issue 168767. checkConfigOutput '^1$' config.sub.specialisation.value ./extendModules-168767-imports.nix +# doRename works when `warnings` does not exist. +checkConfigOutput '^1234$' config.c.d.e ./doRename-basic.nix +# doRename adds a warning. +checkConfigOutput '^"The option `a\.b. defined in `.*/doRename-warnings\.nix. has been renamed to `c\.d\.e.\."$' \ + config.result \ + ./doRename-warnings.nix + cat <<EOF ====== module tests ====== $pass Pass diff --git a/lib/tests/modules/doRename-basic.nix b/lib/tests/modules/doRename-basic.nix new file mode 100644 index 00000000000..9d79fa4f26a --- /dev/null +++ b/lib/tests/modules/doRename-basic.nix @@ -0,0 +1,11 @@ +{ lib, ... }: { + imports = [ + (lib.doRename { from = ["a" "b"]; to = ["c" "d" "e"]; warn = true; use = x: x; visible = true; }) + ]; + options = { + c.d.e = lib.mkOption {}; + }; + config = { + a.b = 1234; + }; +} diff --git a/lib/tests/modules/doRename-warnings.nix b/lib/tests/modules/doRename-warnings.nix new file mode 100644 index 00000000000..6f0f1e87e3a --- /dev/null +++ b/lib/tests/modules/doRename-warnings.nix @@ -0,0 +1,14 @@ +{ lib, config, ... }: { + imports = [ + (lib.doRename { from = ["a" "b"]; to = ["c" "d" "e"]; warn = true; use = x: x; visible = true; }) + ]; + options = { + warnings = lib.mkOption { type = lib.types.listOf lib.types.str; }; + c.d.e = lib.mkOption {}; + result = lib.mkOption {}; + }; + config = { + a.b = 1234; + result = lib.concatStringsSep "%" config.warnings; + }; +} |