diff options
author | Silvan Mosberger | 2024-07-12 03:20:47 +0200 |
---|---|---|
committer | Silvan Mosberger | 2024-08-25 05:07:51 +0200 |
commit | 8f425c25adc365ccddab932cae96cdbed96c115b (patch) | |
tree | 63563d8976c51fda3ba18f8a200b3dc28b4386b9 /lib | |
parent | e6d45588ad829d825156d30b5b9c5642e45b37f9 (diff) |
lib/tests: Format a file with nixfmt
And fix locations to not break the test. This is a rare case where another change is required after formatting. We do this in a separate commit so that we don't need to do it in the treewide reformatting PR.
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/tests/modules.sh | 18 | ||||
-rw-r--r-- | lib/tests/modules/declaration-positions.nix | 30 |
2 files changed, 28 insertions, 20 deletions
diff --git a/lib/tests/modules.sh b/lib/tests/modules.sh index 3a23766a17f5..3301a3d987ee 100755 --- a/lib/tests/modules.sh +++ b/lib/tests/modules.sh @@ -542,21 +542,21 @@ checkConfigOutput '^"pear\\npear"$' config.twice.raw ./merge-module-with-key.nix # Declaration positions # Line should be present for direct options -checkConfigOutput '^10$' options.imported.line10.declarationPositions.0.line ./declaration-positions.nix -checkConfigOutput '/declaration-positions.nix"$' options.imported.line10.declarationPositions.0.file ./declaration-positions.nix +checkConfigOutput '^14$' options.imported.line14.declarationPositions.0.line ./declaration-positions.nix +checkConfigOutput '/declaration-positions.nix"$' options.imported.line14.declarationPositions.0.file ./declaration-positions.nix # Generated options may not have line numbers but they will at least get the # right file -checkConfigOutput '/declaration-positions.nix"$' options.generated.line18.declarationPositions.0.file ./declaration-positions.nix -checkConfigOutput '^null$' options.generated.line18.declarationPositions.0.line ./declaration-positions.nix +checkConfigOutput '/declaration-positions.nix"$' options.generated.line22.declarationPositions.0.file ./declaration-positions.nix +checkConfigOutput '^null$' options.generated.line22.declarationPositions.0.line ./declaration-positions.nix # Submodules don't break it -checkConfigOutput '^39$' config.submoduleLine34.submodDeclLine39.0.line ./declaration-positions.nix -checkConfigOutput '/declaration-positions.nix"$' config.submoduleLine34.submodDeclLine39.0.file ./declaration-positions.nix +checkConfigOutput '^45$' config.submoduleLine38.submodDeclLine45.0.line ./declaration-positions.nix +checkConfigOutput '/declaration-positions.nix"$' config.submoduleLine38.submodDeclLine45.0.file ./declaration-positions.nix # New options under freeform submodules get collected into the parent submodule # (consistent with .declarations behaviour, but weird; notably appears in system.build) -checkConfigOutput '^34|23$' options.submoduleLine34.declarationPositions.0.line ./declaration-positions.nix -checkConfigOutput '^34|23$' options.submoduleLine34.declarationPositions.1.line ./declaration-positions.nix +checkConfigOutput '^38|27$' options.submoduleLine38.declarationPositions.0.line ./declaration-positions.nix +checkConfigOutput '^38|27$' options.submoduleLine38.declarationPositions.1.line ./declaration-positions.nix # nested options work -checkConfigOutput '^30$' options.nested.nestedLine30.declarationPositions.0.line ./declaration-positions.nix +checkConfigOutput '^34$' options.nested.nestedLine34.declarationPositions.0.line ./declaration-positions.nix cat <<EOF ====== module tests ====== diff --git a/lib/tests/modules/declaration-positions.nix b/lib/tests/modules/declaration-positions.nix index cefd3b4e516f..b1f8acaecf83 100644 --- a/lib/tests/modules/declaration-positions.nix +++ b/lib/tests/modules/declaration-positions.nix @@ -1,13 +1,17 @@ { lib, options, ... }: -let discardPositions = lib.mapAttrs (k: v: v); +let + discardPositions = lib.mapAttrs (k: v: v); in # unsafeGetAttrPos is unspecified best-effort behavior, so we only want to consider this test on an evaluator that satisfies some basic assumptions about this function. assert builtins.unsafeGetAttrPos "a" { a = true; } != null; -assert builtins.unsafeGetAttrPos "a" (discardPositions { a = true; }) == null; +assert + builtins.unsafeGetAttrPos "a" (discardPositions { + a = true; + }) == null; { imports = [ { - options.imported.line10 = lib.mkOption { + options.imported.line14 = lib.mkOption { type = lib.types.int; }; @@ -15,35 +19,39 @@ assert builtins.unsafeGetAttrPos "a" (discardPositions { a = true; }) == null; # programs.firefox.nativeMessagingHosts.ff2mpv. We don't expect to get # line numbers for these, but we can fall back on knowing the file. options.generated = discardPositions { - line18 = lib.mkOption { + line22 = lib.mkOption { type = lib.types.int; }; }; - options.submoduleLine34.extraOptLine23 = lib.mkOption { + options.submoduleLine38.extraOptLine27 = lib.mkOption { default = 1; type = lib.types.int; }; } ]; - options.nested.nestedLine30 = lib.mkOption { + options.nested.nestedLine34 = lib.mkOption { type = lib.types.int; }; - options.submoduleLine34 = lib.mkOption { + options.submoduleLine38 = lib.mkOption { default = { }; type = lib.types.submoduleWith { modules = [ - ({ options, ... }: { - options.submodDeclLine39 = lib.mkOption { }; - }) + ( + { options, ... }: + { + options.submodDeclLine45 = lib.mkOption { }; + } + ) { freeformType = with lib.types; lazyAttrsOf (uniq unspecified); } ]; }; }; config = { - submoduleLine34.submodDeclLine39 = (options.submoduleLine34.type.getSubOptions [ ]).submodDeclLine39.declarationPositions; + submoduleLine38.submodDeclLine45 = + (options.submoduleLine38.type.getSubOptions [ ]).submodDeclLine45.declarationPositions; }; } |