Skip to content

🧪✨:test the glob helper, and run tests at all - #1809

Merged
DerekNonGeneric merged 3 commits into
livefrom
test/unit-tests-for-glob
Aug 13, 2026
Merged

🧪✨:test the glob helper, and run tests at all#1809
DerekNonGeneric merged 3 commits into
livefrom
test/unit-tests-for-glob

Conversation

@DerekNonGeneric

Copy link
Copy Markdown
Member

There are no tests in this repository. nps test runs thirteen linters and nothing else, in a workflow named "lint and test".

Stacked on #1804, because three of these tests assert the dot-matching behaviour that PR introduces — on live they fail, which is the point.

Where to start

glob() in build/utils.mts has produced two real bugs in the last few days:

  • directory entries reaching shell commands, where a directory argument makes the tool recurse and quietly undo the exclusions
  • * and ** never matching a dot name, which left eighteen files unchecked across five tasks

Both are three lines to pin down. Ten tests cover exclusions, trailing-slash expansion, extension discrimination, the string-or-array parameter, dot files, dot directories, the standing .git exclusion, and pruning dot entries out of an excluded directory.

Node's own runner, so nothing is added to install. The fixture is a temporary tree that the suite makes its working directory, since every pattern a task writes is relative to where the task runs.

Proof they bite

Each past bug reintroduced deliberately, in the manner of the rest of the pipeline:

reintroduced result
drop .filter((entry) => entry.isFile()) 2 fail — "a trailing slash covers a whole subtree", "never returns a directory"
drop expandDotPattern from the include path 2 fail — "matches a dot file that a bare wildcard would skip", "descends into a dot directory"
all ten, on live 3 fail, for the same dot-matching reason

The runner counts before it trusts

node --test handed a pattern matching nothing exits 0:

$ node --test 'build/**/*.nonexistent.mts'; echo $?
0

A task that only forwarded the pattern would report success having run no tests — the exact failure this session has been full of. So verify-unit.mts resolves the file list first and fails if it is empty. Probed by moving the test file aside:

No test files matched `**/*.test.mts`.
exit=1

There is a mild circularity in using glob() to find the tests for glob(). The count guard is what makes it safe: a helper that finds nothing fails loudly rather than passing quietly, and a helper that finds the wrong things fails in the tests themselves.

Registered under verify, deliberately

verify.all iterates build/tasks/verify/*.mts, so adding the task there puts the tests in CI without touching the workflow, and nps test becomes true to its name. nps verify.unit runs them alone.

Verification

  • nps test — 14/14 tasks, 10/10 tests
  • nps build unchanged
  • I did not test exec; it is a two-line wrapper over @yarnpkg/shell and testing it means running shell commands for little return. The tests it would need are integration tests of the tasks themselves, which is a larger question than this PR.

Note

Same trivial conflict as #1808: this reworks the verify.all comment to stop counting the tasks, with identical wording, so the two merge cleanly together. #1274 changes that line to "fourteen" and wants the reworded version kept instead.

@DerekNonGeneric
DerekNonGeneric force-pushed the fix/glob-skips-dotfiles branch from e225678 to 53120f6 Compare August 13, 2026 00:49
@DerekNonGeneric
DerekNonGeneric force-pushed the test/unit-tests-for-glob branch from 79ca308 to 3c2b074 Compare August 13, 2026 00:49
@DerekNonGeneric
DerekNonGeneric force-pushed the fix/glob-skips-dotfiles branch from 53120f6 to 0fc7a98 Compare August 13, 2026 01:20
@DerekNonGeneric
DerekNonGeneric force-pushed the test/unit-tests-for-glob branch from 3c2b074 to e7f33b6 Compare August 13, 2026 01:20
@DerekNonGeneric
DerekNonGeneric force-pushed the fix/glob-skips-dotfiles branch from 0fc7a98 to efff2f3 Compare August 13, 2026 02:35
@DerekNonGeneric
DerekNonGeneric force-pushed the test/unit-tests-for-glob branch 2 times, most recently from 9487f49 to bf48347 Compare August 13, 2026 03:10
@DerekNonGeneric
DerekNonGeneric force-pushed the fix/glob-skips-dotfiles branch from 4682b48 to 6663a82 Compare August 13, 2026 03:23
@DerekNonGeneric
DerekNonGeneric changed the base branch from fix/glob-skips-dotfiles to live August 13, 2026 03:25
The first tests in this repository, aimed at the function that has
produced two real bugs: directory entries reaching shell commands, and
wildcards never matching a dot name. Both are three lines to pin down.

Node's own test runner, so nothing is added to install. The fixture is a
temporary tree the suite becomes the working directory of, since every
pattern a task writes is relative to where the task runs.

Assisted-by: Claude-Code:claude-opus-5
`nps test` has run thirteen linters and no tests, while the workflow
that calls it is named "lint and test". Registering the runner under
verify puts it in `verify.all`, and so in CI, without touching the
workflow.

`node --test` given a pattern that matches nothing exits 0, so the task
counts the files it found rather than forwarding the pattern and
trusting the exit code.

Assisted-by: Claude-Code:claude-opus-5
The test named for covering a whole subtree had no dot file in its
fixture, so it passed while never exercising the thing this branch is
about -- and it went on passing when the bug it should have caught was
put back. It fails now without the fix.

Assisted-by: Claude-Code:claude-opus-5
@DerekNonGeneric
DerekNonGeneric force-pushed the test/unit-tests-for-glob branch from bf48347 to 1837a6e Compare August 13, 2026 03:26
@netlify

netlify Bot commented Aug 13, 2026

Copy link
Copy Markdown

Deploy Preview for gh-pages-openinf ready!

Name Link
🔨 Latest commit 1837a6e
🔍 Latest deploy log https://app.netlify.com/projects/gh-pages-openinf/deploys/6a7d397276b3290008a79e8d
😎 Deploy Preview https://deploy-preview-1809--gh-pages-openinf.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@DerekNonGeneric
DerekNonGeneric merged commit 60a4c71 into live Aug 13, 2026
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant