diff --git a/.github/workflows/coverage-windows.yml b/.github/workflows/coverage-windows.yml index b282f03ccb7b..d79d2af23eea 100644 --- a/.github/workflows/coverage-windows.yml +++ b/.github/workflows/coverage-windows.yml @@ -82,7 +82,7 @@ jobs: run: choco install nasm - name: Install Rust ${{ env.RUSTC_VERSION }} run: | - rustup override set "$RUSTC_VERSION" + rustup override set ${{ env.RUSTC_VERSION }} rustup --version - name: Build run: ./vcbuild.bat clang-cl v8temporal diff --git a/.github/workflows/test-windows.yml b/.github/workflows/test-windows.yml new file mode 100644 index 000000000000..30a48c13b81f --- /dev/null +++ b/.github/workflows/test-windows.yml @@ -0,0 +1,99 @@ +name: Test Windows + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + paths-ignore: + - '**.md' + - '**.nix' + - eslint.config.mjs + - '**/eslint.config_partial.mjs' + - android-configure + - android-configure.py + - android-patches/** + - benchmarks/** + - doc/** + - pyproject.yml + - tsconfig.json + - test/internet/** + - tools/actions/** + - tools/bootstrap/** + - tools/dep_updaters/** + - tools/doc/** + - tools/eslint-rules/** + - tools/eslint/** + - tools/lint-md/** + - typings/** + - .** + - '!.github/workflows/test-windows.yml' + push: + branches: + - main + paths-ignore: + - '**.md' + - '**.nix' + - eslint.config.mjs + - '**/eslint.config_partial.mjs' + - android-configure + - android-configure.py + - android-patches/** + - benchmarks/** + - doc/** + - pyproject.yml + - tsconfig.json + - test/internet/** + - tools/actions/** + - tools/bootstrap/** + - tools/dep_updaters/** + - tools/doc/** + - tools/eslint-rules/** + - tools/eslint/** + - tools/lint-md/** + - typings/** + - .** + - '!.github/workflows/test-windows.yml' + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +env: + PYTHON_VERSION: '3.14' + FLAKY_TESTS: keep_retrying + RUSTC_VERSION: '1.86' + +permissions: + contents: read + +jobs: + test-windows: + if: github.event.pull_request.draft == false + strategy: + matrix: + autocrlf: [true, false] + name: Windows tests (${{ matrix.autocrlf && 'with' || 'without' }} autocrlf) + runs-on: windows-2025 + steps: + - name: Set git config core.autocrlf + run: git config --global core.autocrlf ${{ matrix.autocrlf }} + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + persist-credentials: false + - name: Set up Python ${{ env.PYTHON_VERSION }} + uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 + with: + python-version: ${{ env.PYTHON_VERSION }} + allow-prereleases: true + - name: Install deps + run: choco install nasm + - name: Install Rust ${{ env.RUSTC_VERSION }} + run: | + rustup override set ${{ env.RUSTC_VERSION }} + rustup --version + - name: Build + run: ./vcbuild.bat clang-cl v8temporal cctest + - name: Test + # after the test "test-child-process-exec-any-shells-windows" is fixed change to `./vcbuild.bat noprojgen nobuild test` + run: | + ./vcbuild.bat noprojgen nobuild build-addons build-js-native-api-tests build-node-api-tests build-ffi-tests + python3 tools/test.py -p tap --logfile test.tap --mode=release --flaky-tests=keep_retrying --measure-flakiness 9 default pummel addons ffi js-native-api node-api embedding benchmark --skip-tests="test-child-process-exec-any-shells-windows" diff --git a/test/README.md b/test/README.md index 02359ca68265..61f5b8bda918 100644 --- a/test/README.md +++ b/test/README.md @@ -8,9 +8,6 @@ directory, see [the guide on writing tests](../doc/contributing/writing-tests.md On how to run tests in this directory, see [the contributing guide](../doc/contributing/pull-requests.md#step-6-test). -For the tests to run on Windows, be sure to clone Node.js source code with the -`autocrlf` git config flag set to true. - ## Test Directories | Directory | Runs on CI | Purpose | diff --git a/test/parallel/test-child-process-exec-any-shells-windows.js b/test/parallel/test-child-process-exec-any-shells-windows.js index 5c34bc77308c..6a9714e39bd2 100644 --- a/test/parallel/test-child-process-exec-any-shells-windows.js +++ b/test/parallel/test-child-process-exec-any-shells-windows.js @@ -59,9 +59,25 @@ cp.exec('where bash', common.mustCall((error, stdout) => { return; } const lines = stdout.trim().split(/[\r\n]+/g); - for (let i = 0; i < lines.length; ++i) { - const bashPath = lines[i].trim(); - test(bashPath); - testCopy(`bash_${i}.exe`, bashPath); - } + + cp.exec('wsl.exe -l -q', (err, out) => { + const hasWSLDistro = !err && out.trim().length > 0; + + for (let i = 0; i < lines.length; ++i) { + const bashPath = lines[i].trim().replace(/^"+|"+$/g, ''); + const bashPathLower = bashPath.toLowerCase(); + + const isWSLBash = + bashPathLower.includes('windowsapps') || + bashPathLower.includes('\\system32\\bash.exe'); + + // Skip WSL bash tests if no WSL distro is installed + if (isWSLBash && !hasWSLDistro) continue; + + test(bashPath); + + // Skip symlink tests for WSL bash always + if (!isWSLBash) testCopy(`bash_${i}.exe`, bashPath); + } + }); })); diff --git a/test/parallel/test-snapshot-typescript.js b/test/parallel/test-snapshot-typescript.js index 98502ccebedf..bed1e1e79dfa 100644 --- a/test/parallel/test-snapshot-typescript.js +++ b/test/parallel/test-snapshot-typescript.js @@ -9,12 +9,13 @@ const { spawnSync } = require('child_process'); const tmpdir = require('../common/tmpdir'); const fixtures = require('../common/fixtures'); const fs = require('fs'); +const os = require('os'); tmpdir.refresh(); const blobPath = tmpdir.resolve('snapshot.blob'); // Concat test/fixtures/snapshot/typescript.js with -// test/fixtures/snapshot/typescript.js into +// test/fixtures/snapshot/typescript-main.js into // tmpdir/snapshot.js. const file = tmpdir.resolve('snapshot.js'); fs.copyFileSync(fixtures.path('snapshot', 'typescript.js'), file); @@ -57,7 +58,8 @@ fs.appendFileSync(file, assert.strictEqual(child.status, 0); const result = fs.readFileSync(outPath, 'utf8'); - const expected = fs.readFileSync( - fixtures.path('snapshot', 'ts-example.js'), 'utf8'); + const expected = fs + .readFileSync(fixtures.path('snapshot', 'ts-example.js'), 'utf8') + .replace(/\r?\n/g, os.EOL); assert.strictEqual(result, expected); }