mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-11 20:25:32 +03:00
lib.types: improve tests for deprecation warning on all migrated types
This commit is contained in:
parent
64a1c1da3e
commit
fb79705bca
2 changed files with 61 additions and 3 deletions
|
@ -398,9 +398,23 @@ checkConfigError 'infinite recursion encountered' config.nonLazyResult ./lazy-at
|
|||
checkConfigOutput '^"mergedName.<id>.nested"$' config.result ./name-merge-attrsWith-1.nix
|
||||
checkConfigError 'The option .mergedName. in .*\.nix. is already declared in .*\.nix' config.mergedName ./name-merge-attrsWith-2.nix
|
||||
|
||||
# Test the attrsOf functor.wrapped warning
|
||||
# shellcheck disable=2016
|
||||
NIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `type.functor.wrapped` attribute of the option `mergedLazyLazy` is accessed, use `type.nestedTypes.elemType` instead.' options.mergedLazyLazy.type.functor.wrapped ./lazy-attrsWith.nix
|
||||
# Test type.functor.wrapped deprecation warning
|
||||
# should emit the warning on:
|
||||
# - merged types
|
||||
# - non-merged types
|
||||
# - nestedTypes elemType
|
||||
# attrsWith
|
||||
NIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.attrsWith.type.functor.wrapped ./deprecated-wrapped.nix
|
||||
NIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.mergedAttrsWith.type.functor.wrapped ./deprecated-wrapped.nix
|
||||
|
||||
NIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.attrsWith.type.nestedTypes.elemType.functor.wrapped ./deprecated-wrapped.nix
|
||||
NIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.mergedAttrsWith.type.nestedTypes.elemType.functor.wrapped ./deprecated-wrapped.nix
|
||||
# listOf
|
||||
NIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.listOf.type.functor.wrapped ./deprecated-wrapped.nix
|
||||
NIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.mergedListOf.type.functor.wrapped ./deprecated-wrapped.nix
|
||||
|
||||
NIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.listOf.type.nestedTypes.elemType.functor.wrapped ./deprecated-wrapped.nix
|
||||
NIX_ABORT_ON_WARN=1 checkConfigError 'The deprecated `.*functor.wrapped` attribute .*is accessed, use `.*nestedTypes.elemType` instead.' options.mergedListOf.type.nestedTypes.elemType.functor.wrapped ./deprecated-wrapped.nix
|
||||
|
||||
# Even with multiple assignments, a type error should be thrown if any of them aren't valid
|
||||
checkConfigError 'A definition for option .* is not of type .*' \
|
||||
|
|
44
lib/tests/modules/deprecated-wrapped.nix
Normal file
44
lib/tests/modules/deprecated-wrapped.nix
Normal file
|
@ -0,0 +1,44 @@
|
|||
{ lib, ... }:
|
||||
let
|
||||
inherit (lib) types mkOption;
|
||||
|
||||
inherit (types)
|
||||
# attrsOf uses attrsWith internally
|
||||
attrsOf
|
||||
listOf
|
||||
;
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
# Module A
|
||||
(
|
||||
{ ... }:
|
||||
{
|
||||
options.attrsWith = mkOption {
|
||||
type = attrsOf (listOf types.str);
|
||||
};
|
||||
options.mergedAttrsWith = mkOption {
|
||||
type = attrsOf (listOf types.str);
|
||||
};
|
||||
options.listOf = mkOption {
|
||||
type = listOf (listOf types.str);
|
||||
};
|
||||
options.mergedListOf = mkOption {
|
||||
type = listOf (listOf types.str);
|
||||
};
|
||||
}
|
||||
)
|
||||
# Module B
|
||||
(
|
||||
{ ... }:
|
||||
{
|
||||
options.mergedAttrsWith = mkOption {
|
||||
type = attrsOf (listOf types.str);
|
||||
};
|
||||
options.mergedListOf = mkOption {
|
||||
type = listOf (listOf types.str);
|
||||
};
|
||||
}
|
||||
)
|
||||
];
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue