lol

Merge pull request #272709 from hercules-ci/module-system-test-pr-131205

lib/modules: Test optionless module errors from #131205

authored by

Maximilian Bosch and committed by
GitHub
d56f942e d826a919

+36
+2
lib/modules.nix
··· 275 275 "The option `${optText}' does not exist. Definition values:${defText}"; 276 276 in 277 277 if attrNames options == [ "_module" ] 278 + # No options were declared at all (`_module` is built in) 279 + # but we do have unmatched definitions, and no freeformType (earlier conditions) 278 280 then 279 281 let 280 282 optionName = showOption prefix;
+8
lib/tests/modules.sh
··· 94 94 # gvariant 95 95 checkConfigOutput '^true$' config.assertion ./gvariant.nix 96 96 97 + # https://github.com/NixOS/nixpkgs/pull/131205 98 + # We currently throw this error already in `config`, but throwing in `config.wrong1` would be acceptable. 99 + checkConfigError 'It seems as if you.re trying to declare an option by placing it into .config. rather than .options.' config.wrong1 ./error-mkOption-in-config.nix 100 + # We currently throw this error already in `config`, but throwing in `config.nest.wrong2` would be acceptable. 101 + checkConfigError 'It seems as if you.re trying to declare an option by placing it into .config. rather than .options.' config.nest.wrong2 ./error-mkOption-in-config.nix 102 + checkConfigError 'The option .sub.wrong2. does not exist. Definition values:' config.sub ./error-mkOption-in-submodule-config.nix 103 + checkConfigError '.*This can happen if you e.g. declared your options in .types.submodule.' config.sub ./error-mkOption-in-submodule-config.nix 104 + 97 105 # types.pathInStore 98 106 checkConfigOutput '".*/store/0lz9p8xhf89kb1c1kk6jxrzskaiygnlh-bash-5.2-p15.drv"' config.pathInStore.ok1 ./types.nix 99 107 checkConfigOutput '".*/store/0fb3ykw9r5hpayd05sr0cizwadzq1d8q-bash-5.2-p15"' config.pathInStore.ok2 ./types.nix
+14
lib/tests/modules/error-mkOption-in-config.nix
··· 1 + { lib, ... }: 2 + let 3 + inherit (lib) mkOption; 4 + in 5 + { 6 + wrong1 = mkOption { 7 + }; 8 + # This is not actually reported separately, so could be omitted from the test 9 + # but it makes the example more realistic. 10 + # Making it parse this _config_ as options would too risky. What if it's not 11 + # options but other values, that abort, throw, diverge, etc? 12 + nest.wrong2 = mkOption { 13 + }; 14 + }
+12
lib/tests/modules/error-mkOption-in-submodule-config.nix
··· 1 + { lib, ... }: 2 + let 3 + inherit (lib) mkOption; 4 + in 5 + { 6 + options.sub = lib.mkOption { 7 + type = lib.types.submodule { 8 + wrong2 = mkOption {}; 9 + }; 10 + default = {}; 11 + }; 12 + }