Skip to content

fix: address several Windows-specific failures in npm run test#9694

Open
B-head wants to merge 4 commits intoRaspberryPiFoundation:mainfrom
B-head:fix/windows-test-environment
Open

fix: address several Windows-specific failures in npm run test#9694
B-head wants to merge 4 commits intoRaspberryPiFoundation:mainfrom
B-head:fix/windows-test-environment

Conversation

@B-head
Copy link
Copy Markdown

@B-head B-head commented Apr 8, 2026

The basics

The details

Resolves

Refs #5000 (partial — covers four npm run test failures on Windows; the umbrella issue should remain open).

Proposed Changes

Make npm run test pass 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 test is unrunnable on Windows: it dies at renamings, generators, node, and advanced_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 test reach SUCCESS. npm run lint, npm run format:check, and npx commitlint --from main --to HEAD --verbose are 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.

B-head and others added 4 commits April 9, 2026 04:57
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) <noreply@anthropic.com>
`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) <noreply@anthropic.com>
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) <noreply@anthropic.com>
`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) <noreply@anthropic.com>
@B-head B-head requested a review from a team as a code owner April 8, 2026 20:39
@B-head B-head requested a review from mikeharv April 8, 2026 20:39
@github-actions github-actions bot added the PR: fix Fixes a bug label Apr 8, 2026
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@mikeharv mikeharv requested review from maribethb and removed request for mikeharv April 9, 2026 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: fix Fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants