test: keep browser-run temp dirs in the OS temp dir - #476
Open
Agnik47 wants to merge 1 commit into
Open
Conversation
Two browser-run tests seed a persistent context with
`fs.mkdtempSync('/tmp/webcmd-persistent-browser-run-')`. Off POSIX that
POSIX-absolute path is not the OS temp dir: on Windows it resolves against the
current drive, so the tests write to `<drive>:\tmp` when that directory happens
to exist and fail with ENOENT when it does not. Use `path.join(os.tmpdir(),
...)`, which the same file already uses for its artifact temp dir.
Both tests also launch their own Chromium persistent context inside the test
body while still on Vitest's 5s default, so they time out under a loaded full
suite run even when the launch itself succeeds. Give them the 20s budget this
repo already uses for process-launching tests.
`stepDownload` gets the same treatment: its cookie test passed a hardcoded
`/tmp/webcmd-download-test` and created that directory in the drive root, while
the sibling test above it already resolved the same name through `os.tmpdir()`.
CI does not install Playwright browsers for the unit job, so
`describeWithChromium` skips this block there; the failures only show up on a
contributor machine that has Chromium.
Contributor
🟢 No documentation gap found — high confidenceThe pull request only changes tests, lockfiles, generated metadata, or dependency metadata. This review is advisory and does not block merging. |
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.
Two unit tests fail on my Windows box against
main, and the cause turned out to be a POSIX-absolute path used where the OS temp dir was meant.What happens
src/browser/run/runner.test.tsseeds its persistent-context tests with:/tmpis not the OS temp dir off POSIX. On Windows it resolves against the current drive, so the tests either write into<drive>:\tmpwhen that directory happens to exist, or fail outright withENOENTwhen it does not. I found a staleD:\tmp\on my machine that these runs had created.The same file already gets this right ~350 lines further down:
so this looks like a slip rather than a deliberate choice.
osandpathare already imported at the top of the file.On top of that, both tests call
chromium.launchPersistentContext()inside the test body while still on Vitest's 5s default. A cold persistent-context launch does not reliably fit in that budget, and under a full-suite run they time out:Run on their own with a wider budget, the same two tests finish in ~3.5s — the launch is fine, the 5s allowance is not.
src/pipeline/steps/download.test.tshas the same slip: the cookie test passes a hardcodeddir: '/tmp/webcmd-download-test'and really does create that directory in the drive root, while the sibling test right above it already resolves the identical name throughos.tmpdir().Change
path.join(os.tmpdir(), ...).20_000, matching the per-test budget already used for process-launching tests insrc/hosted/main-lifecycle.test.ts.Five lines, tests only, no production code touched.
Why CI is green today
The unit job does not install Playwright browsers, so
describeWithChromium(runner.test.ts:35) skips this whole block on CI. The failures only surface for a contributor who has Chromium locally — which is exactly where they are most annoying.Verification
On Windows, against
main:runner.test.tsfailures are gone. The other 30 are pre-existing and unrelated to this change — 26 need Windows symlink privileges (EPERM: operation not permitted, symlink), and 4 are separate hosted-path and timeout issues that also fail on unmodifiedmain.runner.test.tsalone: 89/89 pass. Together withdownload.test.ts: 92/92.npm run typecheckclean.webcmd-download-testis recreated in the drive root after a run.Left out on purpose
session-manager.test.tsandprovider.test.tspassbaseDir: '/tmp/webcmd-test'in ~40 places and do create<drive>:\tmp\webcmd-test\cloak\profiles. Those tests currently pass, and converting them is mechanical churn that would bury this diff, so I left them for a separate change. Happy to do that one next if you want it.