Repository navigation
Conversation
LeafYeh1
left a comment
There was a problem hiding this comment.
Checked out 3a81851 on macOS 26.2 arm64 with Node v26.10.0, Python 3.9.6 and Playwright Chromium:
python3 tests/test_check_test_timing.py: 24 tests OKnode --test --test-name-pattern="paints syntax colours and line numbers" tests/browser/task-workspace.test.js: 1 pass, 0 fail (1140 ms)node scripts/check-test-timing.mjs: no findings, exit 0
The test fix works for me. The two inline comments are about the new rule: forms of the same bound that it does not see, and a message that does not name the property.
Jonathas2127
left a comment
There was a problem hiding this comment.
Reviewed 3a81851 against #654. On WSL with Node 22.22.1, Python 3.14.4, and Playwright 1.65.0:
python3 tests/test_check_test_timing.py— 24 passed.CI=1 node --test --test-name-pattern="paints syntax colours and line numbers" tests/browser/task-workspace.test.js— 1 passed, 0 skipped.node scripts/check-test-timing.mjs— exit 0 on the repository's browser suite.node scripts/check-test-timing.mjs ../pr793-timing-fixtures— exit 1. The separate-tests fixture produced one false positive, and the duplicate-diagnostic fixture printed the same diagnostic twice.
Ericko00o
left a comment
There was a problem hiding this comment.
Reviewed 3a81851c on Windows with Node v24.22.1 and Python 3.14.7. The timing checker’s Python suite passed all 24 tests. I also ran node scripts/check-test-timing.mjs <fixture-dir> on the small fixtures described in the inline comments.
The scroll check in the task editor test set the textarea to 900 and then waited until the highlight layer's scrollTop passed 0. The fill before it leaves the caret at the end of 120 lines, so the textarea has already scrolled to the bottom, and when a frame lands between the fill and the assignment the layers have followed it there. The wait then holds at once and the assertion reads [900, 2276, 2276], as it did in CI. Whether that frame lands depends on how busy the runner is, which is why the failure was intermittent. Waiting for the layers to follow the fill first makes every run take that path, and with the old wait it then fails every run; waiting for both layers to reach 900 passes on every run. The check that the layers follow the fill also catches a paint that forgets to resync them, which the old test let through on two runs out of three. Change-Id: I1d5cb112fa597fa816bd4150685279488a4556c6
3a81851 to
b91cf43
Compare
liehcheng
left a comment
There was a problem hiding this comment.
Reviewed b91cf43 on Windows with Node.js v22.17.0 and Python 3.13.5.
All 32 tests in python tests/test_check_test_timing.py passed. Running node scripts/check-test-timing.mjs produced no diagnostics (exit 0).
I left two inline comments with additional fixtures and reproduction results.
There was a problem hiding this comment.
Reviewed b91cf43 on Windows 10 (WSL, Ubuntu 26.04.1 LTS, x86_64) with Node.js v26.13.1 and Python 3.14.4.
Verified results:
python3 tests/test_check_test_timing.py: all 32 tests passed.node scripts/check-test-timing.mjs: exit 0 on the existing browser test directory.- Additional fixtures reproduced one false negative and two false positives in the new bound-wait rule.
I left three inline comments below. One is related to an issue raised by another reviewer but covers a different edge case.
b91cf43 to
5cd2ef5
Compare
5cd2ef5 to
3fdd9fb
Compare
3fdd9fb to
514d9c8
Compare
The previous commit fixed a test that set a textarea's scrollTop to 900 and then waited for a layer's scrollTop to pass 0: a layer that had followed an earlier scroll met that bound before it followed this one, so the wait returned at once on one runner and held on another, and nothing stopped the next wait of that shape from landing. The gate now refuses a wait that bounds, with >, <, != or their kin and the property on either side, a property the statement right before it set, and asks for the value set; === and == are the exact comparisons. An exact comparison beside the bound does not exempt it, since `code.scrollTop === 900 && layer.scrollTop > 0` holds as soon as the textarea is set, and neither does `=== 1` or `== 1` after `= 900`, which the stale value can meet just the same; where both values are written out as literals, signed numbers included, the two are compared. Only the argument the wait polls is read, and only an assignment that runs before the wait is tied to it: in the statement right before it, its result kept or not, at its level or in a callback of a call that statement awaits, and on the same page as far as the names tell, the page being the receiver of the .evaluate that runs the assignment, inside Promise.all or t.test too. So a function stored for later, a step between the two, a wait on another page or an assertion after the wait is left alone; that short reach keeps the rule to the wait replaced here over tests/browser and the open pull requests. It leaves a property read into a local first, brackets two deep and a value that is not a literal as limits the header states. A reset the bound cannot meet is deliberate and carries timing-ok:. Close sysprog21#654 Change-Id: Ifa16fe0c70ab66bccf01e6ab1adfb8bedb58be05
514d9c8 to
4370221
Compare
| // kept with `var`, a destructuring, a plain reassignment or inside another | ||
| // call, none of which the tests write. | ||
| const tied = | ||
| /^[^;]*;[\s)}\];,]*(?:(?:const|let)\s+[\w$]+\s*=\s*)?(?:await\s+)?(?:[\w$]+\s*\.\s*)*$/; |
There was a problem hiding this comment.
An assignment in a block-bodied callback that is passed an argument is never tied to the wait after it: [^;]*; stops at the first ; inside the callback, and the , 900) after its } is not among what may follow. So await page.locator("#code").evaluate((node, top) => { node.scrollTop = top; }, 900); followed by await page.waitForFunction(() => layer.scrollTop > 0); exits 0 (as does the same with node.scrollTop = 900; }, undefined)), while the expression form (node, top) => (node.scrollTop = top), 900 is refused, and the browser tests already pass arguments to evaluate this way (tests/browser/test-results-filter.test.js, tests/browser/candidate-cases.test.js). Let the arguments after the callback stand between the two as well, for instance by testing what follows the outermost bracket setOn finds rather than what follows the first ;, with an assertRejected case for the block form.
Problem and behavior
The task editor scroll check failed in CI with
[900, 2276, 2276]because its wait could be met before the layers followed the scroll it waits for.page.fillleaves the caret at the end of the 120 lines, so the textarea scrolls to 2276 and the layers follow it there on the next frame, through thescrolllistener and the paint inweb/editor-view.js. When that frame lands between the fill andscrollTop = 900, the layers already sit at 2276,scrollTop > 0holds at once, and the assertion reads them before the scroll event for 900 arrives. Locally the frame usually lands after the assignment, which is why the test passed here and only sometimes failed on a loaded runner.The product side is not at fault: in a listener registered after the editor's own, both layers equalled the textarea on every scroll event (8 of 8), so they move before the page paints. The defect is the wait, and nothing stopped the next wait of that shape from landing, since
scripts/check-test-timing.mjsonly knew deadlines and fixed sleeps.Approach
The test now waits for the layers to follow the fill before it scrolls, so every run starts from the state CI failed in, and then waits until both layers reach 900. The first wait is also a check: removing the paint-time
syncScroll()leaves the layers at 0 after the fill, which the old test let pass on two runs out of three.scripts/check-test-timing.mjsgains a third rule: a wait right after an assignment is refused when the condition it polls compares the property just set with anything but===or==(>,<,>=,<=,!=,!==, with the property on either side), or with either of those two against another literal than the one set (=== 1or== 1after= 900, signed numbers included), and the message names the property and asks for the value set. An===beside the bound does not exempt it:code.scrollTop === 900 && layer.scrollTop > 0holds as soon as the textarea is set, while the layer still sits where it was.The rule reads the same blanked code as the other two and only the argument the wait polls: the first, or the second for
reaches(page, predicate). It ties a wait to an assignment only when the assignment runs before it: in the statement right before it, whether or not the wait's result is kept (const reachable = await reaches(...)), at the wait's own level or in a callback of a call that statement awaits, and on the same page as far as the names tell, the page being the receiver of the.evaluatethat runs the assignment, insidePromise.allort.testtoo. A step between the two, a function stored for later, a wait on another page or an assignment in another test is left alone. A deliberate bound, such as a counter reset below its threshold, carriestiming-ok:.The reach is kept short on purpose: over
tests/browser, upstreammainand every open pull request that touches it, the rule flags only the wait replaced here. What it does not see is stated in the file's header: a property read into a local before the comparison, a property on the right behind brackets two deep, a value set or compared that is not written out as a number,true,falseornull, an assignment in a call that is not awaited where it is written (such as a barepage.evaluate(...)withoutawait), a wait kept withvar, a destructuring or a plain reassignment, or wrapped in another call, and a wait that does not directly follow the assignment.Validation
node --test --test-name-pattern='paints syntax colours and line numbers' tests/browser/task-workspace.test.js: failed 5 of 5,actual: [ 900, 2276, 2276 ]. New wait: passed 10 of 10, about 1.4 s each.web/editor-view.js, each reverted after: without thescrolllistener the test fails after the 30 s wait with[ 900, 2276, 2276 ]; without the paint-timesyncScroll()it fails with the layers at[ 0, 0 ]after the fill.node scripts/check-test-timing.mjswith both commits applied: no findings intests/browser. Run on the test as it was before the fix, it flags the wait Task editor scroll-sync test fails intermittently in CI #654 is about:task-workspace.test.js:596: wait bounds .scrollTop, which the test just set; wait for the value set.tests/browserof upstreammain(f728575, and 498d1c0 after it moved on) and of each of the 15 open pull requests that touch it, at the heads fetched for this review: each reports onlytask-workspace.test.js:596, the line this change fixes, and Synchronize browser test request assertions #789, the one that also edits that file, merges with this branch without conflict.python3 tests/test_check_test_timing.py: 39 tests OK, 22 of them for this rule. Each condition of the rule fails a test when broken: the tie to the next statement, the deduplication, the polled argument and the commas inside it, the awaited call and the stored function, the brackets around the assignment and nested call arguments on both sides, the page on each side and the.evaluatethat names it, the reversed and bracketed operands, the literal comparison with its sign and the expressions it leaves alone, and===or==counted as a bound. Two mutants survive: reading the brackets around the assignment outermost first is equivalent, since no statement nests one.evaluatein another; letting any text stand before the wait'sawaitdiffers only for a wait wrapped in another call, such asassert.ok(await reaches(...)), which the header names as a limit rather than a test pinning it. Removing<=from the operators fails nothing, since<still matches<= 1.ruff check scripts tests .claude/skillsis clean with 0.15.2, the version CI pins.until's message, the deferredresetScroll, and the wait onsecondPage, directly or afterPromise.all, pass;=== 1and== 1after= 900,=== 0after= -1,const reachable = await reaches(page, () => layer.scrollTop > 0),0 < document.querySelector(selectorFor("layer")).scrollTop,2000 > (await top()).scrollTopand an awaitedpage.locator(sel("#code")).evaluate(...)are refused../scripts/test.sh browseron macOS, at an earlier head with the same browser test: 3653 tests, 3651 pass, 1 skipped (no ffmpeg), 1 fail,lobby.test.js"the picker keeps the page's classic scrollbar", which asserts a classic scrollbar that macOS overlay scrollbars never give; this branch does not touch that test orweb/../scripts/test.sh portableat this head on this macOS machine fails three gates, the same three that fail on the base commit and none in a file this branch touches:git-hooks(10 of 488 checks):commentflow,shfmtandtimeoutare not installed here.interactive-review-hook-tests: the test expects a/var/...path where macOS resolves/private/var/....run-budget-tests: the sampler records no resident memory for the process tree on macOS.task-authoring-tests, a wall-clock check of the rubik starter, passed in this run; under the lane's parallel load it has missed its margin on earlier heads of this branch, and neither the test nor the code it times is touched here.Close #654