Skip to content

Commit 3c56189

Browse files
authored
lib,tests: drop inspectTree and the discoverTree duplicate fixture (indexable-inc#245)
## Summary inspectTree was only ever a test seam so the helpers group could grep the exact discoverTree duplicate-name failure text without catching a throw. The pinned message-format assertion is brittle, the helper has no production caller, and a full tests/ refactor is queued. Inline the walk + duplicate detection back into discoverTree, drop the helper exports, and remove the duplicates fixture along with the three substring assertions. discoverTree's behavior is identical for every existing caller (image, module, example discovery still throws the same way on real duplicates). ## Tradeoff Nothing now asserts the duplicate throw fires until the tests/ refactor lands. Risk is low: any real regression in discoverTree's duplicate guard would surface as a build failure in image/module/example discovery callers. ## Validation - \`nix run .#lint\` 🤖 Generated with [Claude Code](https://claude.com/claude-code)
1 parent 4a8947a commit 3c56189

5 files changed

Lines changed: 8 additions & 47 deletions

File tree

lib/default.nix

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,6 @@ let
343343
;
344344
})
345345
discoverTree
346-
inspectTree
347346
discoverImages
348347
discoverModules
349348
exampleFleetsFor
@@ -363,7 +362,6 @@ let
363362
mkFleet
364363
mkFleetFor
365364
discoverTree
366-
inspectTree
367365
discoverImages
368366
discoverModules
369367
nixosModules

lib/discovery.nix

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,12 @@ let
2424
) attrs;
2525

2626
/**
27-
Same walk and duplicate-name detection as `discoverTree`, but returns
28-
`{ discovered; duplicateMessages; }` instead of throwing. Exists so the
29-
test suite can assert the exact duplicate-name failure mode without
30-
catching a throw; `discoverTree` is a thin throw-or-return wrapper on
31-
top of it.
27+
Walk a directory tree and return `{ <name> = { path; metadata; }; }`.
28+
Entries are directories containing every required file. Directories whose
29+
names start with `_` are skipped with their subtree. `validate` may return
30+
extra metadata and `outputNames` for additional duplicate claims.
3231
*/
33-
inspectTree =
32+
discoverTree =
3433
{
3534
root,
3635
requiredFiles ? [ "default.nix" ],
@@ -87,28 +86,11 @@ let
8786
)
8887
) duplicateClaims;
8988
in
90-
{
91-
inherit discovered duplicateMessages;
92-
};
93-
94-
/**
95-
Walk a directory tree and return `{ <name> = { path; metadata; }; }`.
96-
Entries are directories containing every required file. Directories whose
97-
names start with `_` are skipped with their subtree. `validate` may return
98-
extra metadata and `outputNames` for additional duplicate claims.
99-
*/
100-
discoverTree =
101-
args:
102-
let
103-
result = inspectTree args;
104-
in
105-
if result.duplicateMessages != [ ] then
106-
throw (lib.concatStringsSep "\n" result.duplicateMessages)
89+
if duplicateMessages != [ ] then
90+
throw (lib.concatStringsSep "\n" duplicateMessages)
10791
else
10892
lib.listToAttrs (
109-
map (
110-
entry: lib.nameValuePair entry.metadata.name { inherit (entry) path metadata; }
111-
) result.discovered
93+
map (entry: lib.nameValuePair entry.metadata.name { inherit (entry) path metadata; }) discovered
11294
);
11395

11496
# One image directory -> { <name> = pkg; <name>_<ver> = pkg; ... }.
@@ -303,7 +285,6 @@ in
303285
{
304286
inherit
305287
discoverTree
306-
inspectTree
307288
discoverImages
308289
discoverModules
309290
exampleFleetsFor

tests/default.nix

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,8 +1729,6 @@ let
17291729
}).refs
17301730
true
17311731
);
1732-
discoverTreeDuplicateMessages =
1733-
(ix.inspectTree { root = ./fixtures/discover-tree-duplicates; }).duplicateMessages;
17341732
# --- Per-image assertion groups -------------------------------------------
17351733

17361734
groups = {
@@ -2930,20 +2928,6 @@ let
29302928
assertion = !invalidSecretNameEval.success;
29312929
message = "secret refs should reject unsafe relative names during eval";
29322930
}
2933-
{
2934-
assertion = lib.any (
2935-
msg: lib.hasInfix "discoverTree: duplicate output name 'shared'" msg
2936-
) discoverTreeDuplicateMessages;
2937-
message = "discoverTree should name the duplicated output in its failure message";
2938-
}
2939-
{
2940-
assertion = lib.any (msg: lib.hasInfix "first/shared" msg) discoverTreeDuplicateMessages;
2941-
message = "discoverTree duplicate failure should cite the first claiming path";
2942-
}
2943-
{
2944-
assertion = lib.any (msg: lib.hasInfix "second/shared" msg) discoverTreeDuplicateMessages;
2945-
message = "discoverTree duplicate failure should cite the second claiming path";
2946-
}
29472931
{
29482932
assertion = cargoUnitWorkspace.policyChecks ? cargoAudit;
29492933
message = "cargo-unit workspaces should expose a cargo-audit policy check by default";

tests/fixtures/discover-tree-duplicates/first/shared/default.nix

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/fixtures/discover-tree-duplicates/second/shared/default.nix

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)