fix(reporters): include source code in blob to survive cross-OS merge (fix #10260)#10263
fix(reporters): include source code in blob to survive cross-OS merge (fix #10260)#10263dokson wants to merge 1 commit intovitest-dev:mainfrom
Conversation
…fix vitest-dev#10260) When `--merge-reports` combines blob files produced on different OSes (e.g. macOS + Windows + Linux runners on CI), the HTML reporter ran on the merger filesystem could not read the test sources for files whose paths lived on a different OS (`/Users/runner/...`, `C:\...` not present on the Linux merger). The "Code" tab in the merged HTML report ended up empty for those platforms. Embed the test sources in the blob output (read once on the runner that produces the blob) and surface them via `state.blobs.sources` during merge. The HTML reporter now prefers the merged sources and falls back to filesystem reads only when not available. Adds an e2e test that simulates the cross-OS scenario by renaming the fixture sources between the blob run and the merge run, then asserts the HTML report still contains source code.
|
Confirming ownership: I authored and reviewed this change myself. The marker is included per AGENTS.md guidelines for AI-assisted contributions, but the implementation and reasoning have been verified by me. |
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Hello @dokson. Your PR has been labeled If you're a real person behind this contribution, please:
If you believe this was flagged by mistake, leave a comment. These measures help us reduce maintenance burden and keep the team's work efficient. See our AI contributions policy for more context. |
|
Disclosure per the AI contribution policy:
|
Description
When sharded CI matrices produce blob reports on multiple OSes (e.g. macOS + Windows + Ubuntu) and they are then combined with `--merge-reports` on a single runner (typically Linux), the HTML reporter cannot read the test sources for paths that live on a different OS. The merger tries `fs.readFile('/Users/runner/...')` / `fs.readFile('C:...')` on its own filesystem, the read silently fails (caught by the existing `try/catch`), and the resulting `html.meta.json` ends up with no `sources` entries for those platforms. The "Code" tab in the merged HTML report is empty for any non-Linux runner.
I confirmed this on the artifact attached to #10260: out of the e2e merged report, 336 Linux files had source, 112 macOS and 112 Windows files had no source. Same pattern as the screenshots in the issue.
Fix
Test plan
Compatibility
The 7th tuple element is optional (`sources?`) and `readBlobs` defaults to `{}` when missing, so blobs produced by older versions can still be consumed (the version-equality check in `readBlobs` already prevents cross-version mixing in practice, but the optional field keeps the type permissive).
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
Documentation
Changesets