lib/tests/modules: Test doRename

Changed files
+32
lib
+7
lib/tests/modules.sh
···
# because of an `extendModules` bug, issue 168767.
checkConfigOutput '^1$' config.sub.specialisation.value ./extendModules-168767-imports.nix
cat <<EOF
====== module tests ======
$pass Pass
···
# 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
+11
lib/tests/modules/doRename-basic.nix
···
···
+
{ 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;
+
};
+
}
+14
lib/tests/modules/doRename-warnings.nix
···
···
+
{ 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;
+
};
+
}