fix: address several Windows-specific failures in npm run test#9694
Open
B-head wants to merge 4 commits intoRaspberryPiFoundation:mainfrom
Open
fix: address several Windows-specific failures in npm run test#9694B-head wants to merge 4 commits intoRaspberryPiFoundation:mainfrom
B-head wants to merge 4 commits intoRaspberryPiFoundation:mainfrom
Conversation
The generators and compile webdriver scripts built `file://` URLs by concatenating `__dirname` directly. On Windows `__dirname` contains backslashes, which yields a malformed URL like `file://S:\source\blockly\.../tests/compile/index.html` that Chrome refuses to load — making the `generators` and `advanced_compile_in_browser` test steps fail. Route both URLs through the existing `posixPath()` helper in `scripts/helpers.js`, matching the pattern already used in `tests/mocha/webdriver.js`. The helper is a no-op on POSIX so this keeps existing Linux/macOS behaviour unchanged. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
`eslint-plugin-prettier` inherits Prettier's `endOfLine: 'lf'` default, so any source file checked out with CRLF on a Windows machine that has `core.autocrlf=true` fails lint with `Delete \`␍\`` errors. Setting `* text=auto eol=lf` makes git always check out detected text files with LF regardless of the user's local autocrlf setting, removing the class of failures at its source. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
The renamings test step ran the `.mjs` file directly via execSync, relying on its `#!/usr/bin/env node` shebang. Windows `cmd.exe` does not honor shebangs and `.mjs` has no default file association, so the step failed with "is not recognized as an internal or external command". Prefix the invocation with `node` so it works on every platform. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
`tests/node/node_modules/blockly-test` is a git symlink (mode 120000) pointing at `../../../dist`. With `core.symlinks` disabled (the default on Windows) git checks it out as a 13-byte text file containing the link target literally, so `import 'blockly-test'` in `tests/node/run_node_test.mjs` fails with `ERR_MODULE_NOT_FOUND` and the `node` test step never runs. Add an `ensureBlocklyTestLink` helper that runs immediately before the node test step. It detects the broken state via `lstatSync`, replaces the file with a junction (which works on Windows without admin rights and is treated as a regular symlink on POSIX), then best-effort marks the path `skip-worktree` so the resulting "deleted symlink" diff stays out of `git status`. Unexpected failures of the skip-worktree step are surfaced as a warning rather than silently swallowed. The helper is idempotent and a no-op on Linux/macOS, where the git checkout already produces a usable symlink. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Contributor
There was a problem hiding this comment.
Welcome! It looks like this is your first pull request in Blockly, so here are a couple of tips:
- You can find tips about contributing to Blockly and how to validate your changes on our developer site.
- We use conventional commits to make versioning the package easier. Make sure your commit message is in the proper format or learn how to fix it.
- If any of the other checks on this PR fail, you can click on them to learn why. It might be that your change caused a test failure, or that you need to double-check the style guide.
Thank you for opening this PR! A member of the Blockly team will review it soon.
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.
The basics
The details
Resolves
Refs #5000 (partial — covers four
npm run testfailures on Windows; the umbrella issue should remain open).Proposed Changes
Make
npm run testpass on Windows 11 by fixing four POSIX-only assumptions in the test/build helpers. See individual commits for the per-bug rationale.Reason for Changes
Without these fixes
npm run testis unrunnable on Windows: it dies atrenamings,generators,node, andadvanced_compile_in_browser. None of the changes touch library code, public API, serialization, or generator output.Test Coverage
Manually verified on Windows 11 (Node 22, Chrome stable) that all 10 stages of
gulp testreachSUCCESS.npm run lint,npm run format:check, andnpx commitlint --from main --to HEAD --verboseare all clean.No automated tests were added — every change is to test/build infrastructure rather than library behaviour, and the current CI matrix (
ubuntu-latest/macos-latest) doesn't run Windows so a Windows regression test would need a CI matrix change first. POSIX behaviour is preserved by construction.