Repository navigation
test: run hold-confirm tests concurrently so the file clears its timeout - #143
Merged
Merged
Conversation
hold-confirm.test.mjs is built from real-time waits (HOLD_MS 700, KEYARM_MS 4000) and took ~15 s run one test after another, against a 20 s --test-timeout that node --test applies to the whole file. A slow Windows runner ate the remaining headroom and turned main red. Each test builds its own jsdom page, so the tests share no timer state. Grouping them under one concurrent describe() leaves every assertion and wait as it was, and the file now costs only its longest wait: 5.9 s locally, under 10 s with every core busy. Closes #140
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #140
What changed
hold-confirm.test.mjstook ~15 s because its tests run one after another, each waiting in real time (HOLD_MS700,KEYARM_MS4000).node --testapplies--test-timeout=20000to each whole file, so only ~4 s of headroom was left.Every test already builds its own jsdom page, so the tests share no timer state.
They now sit under one
describe('hold-to-confirm', { concurrency: true }), and the file costs only its longest wait.No assertion, wait or constant changed:
git diff -wis the import, the wrapper and a comment explaining it.HOLD_MSstays 700, in step with the page constant and CSS fill.The timeout in
package.jsonandmutation-check.mjsstays 20000, so the two are still in step.AGENTS.md's "~15s" for the frontend suite is corrected to "~6s".
Why concurrency is safe here: jsdom's
window.setTimeoutis Node'ssetTimeoutunderneath (timerInitializationStepsinjsdom/browser/Window.js), and the harnesssleep()uses that same timer.So a page timer and the test's check fire in deadline order on one event loop.
A busy loop delays both alike and cannot reorder a hold against the check that follows it.
Verify
node --test tests/frontend/hold-confirm.test.mjs:duration_ms 15168before,duration_ms 5873after (19/19 pass).npm --prefix tests/frontend test:Stress run: 3 rounds of 6 parallel copies of the file, with all 32 cores pinned by busy loops. 18/18 green, slowest
duration_ms 9733(limit 20000).npm --prefix tests/frontend run test:mutations:Danger zone: negative assertions are still load-bearing
The standing mutation check covers only two of this file's guards (
e.repeat,e.button).To prove the time-based "does NOT clear" assertions don't pass vacuously under concurrency, I broke each timer and abort guard in a temporary copy of
app.jsand ran the concurrent file against it:"orphaned-timer" removes
clearTimeoutfrom_holdStopand lets the timer fire on the captured element."also failed" means a test outside the expected list also caught it.
Also green:
python -m unittest discover -s tests(377 OK, 1 skipped),-s tools/tests(14 OK),ruff check fetchforge tests tools.The Windows CI frontend step is verified by this PR's own
test (windows-latest, …)runs.