Skip to content

Commit ae62783

Browse files
committed
fix test
1 parent a6b4a73 commit ae62783

File tree

20 files changed

+162
-73
lines changed

20 files changed

+162
-73
lines changed

.github/shared-actions/windows-bazel-test/action.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ runs:
2222

2323
- name: Initialize WSL
2424
id: init_wsl
25-
uses: angular/dev-infra/github-actions/setup-wsl@0b004688d62e0fff2dbbb98362ff1b484348116a
25+
uses: angular/dev-infra/github-actions/setup-wsl@574e50945ea191ebd1e1757fa7f6131cc9dbd7a9
26+
with:
27+
wsl_firewall_interface: 'vEthernet (WSL (Hyper-V firewall))'
28+
wsl_networking_mode: 'mirrored'
2629
- name: Install node modules in WSL (re-using from previous install/cache restore)
2730
run: yarn install --immutable
2831
shell: wsl-bash {0}
@@ -32,15 +35,13 @@ runs:
3235
# * symlink_prefix=/: Needed as otherwise we will create unix symlinks in the Windows host.
3336
- run: |
3437
${{inputs.command}} \
35-
--//e2e/legacy-cli:enable_native_windows_testing=true \
38+
--//tests/legacy-cli:enable_native_windows_testing=true \
3639
--test_env="NG_E2E_RUNNER_WSL_ROOT=${{steps.init_wsl.outputs.wsl_root_path}}" \
3740
--test_env="NG_E2E_RUNNER_WSL_UNC_BASE=${{steps.init_wsl.outputs.wsl_root_unc_path}}" \
3841
--test_env="NG_E2E_RUNNER_WINDOWS_CMD=${{steps.init_wsl.outputs.cmd_path}}" \
3942
--test_env="NG_E2E_RUNNER_WINDOWS_NPM=${{steps.init_wsl.outputs.npm_path}}" \
4043
--test_env="NG_E2E_RUNNER_WINDOWS_TMP_DIR=${{steps.init_wsl.outputs.tmp_path}}" \
4144
--test_env="NG_E2E_RUNNER_WINDOWS_GIT_BASH_BIN=${{steps.init_wsl.outputs.git_path}}" \
42-
--test_env="NG_E2E_RUNNER_WSL_HOST_ADDR=$(ip route show | grep -i default | awk '{ print $3}')" \
43-
--test_env="NG_E2E_RUNNER_WSL_VM_ADDR=$(hostname -I)" \
4445
--strategy=TestRunner=standalone \
4546
--symlink_prefix=/
4647
shell: wsl-bash {0}

.github/workflows/pr.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ jobs:
127127

128128
e2e-windows-subset:
129129
# needs: build
130-
runs-on: windows-latest
130+
runs-on: windows-2025
131131
steps:
132132
- name: Initialize environment
133133
uses: angular/dev-infra/github-actions/npm/checkout-and-setup-node@d16848fd2ed19fce59488b540fa26a3353c72ad4
@@ -143,7 +143,7 @@ jobs:
143143
strategy:
144144
fail-fast: false
145145
matrix:
146-
os: [windows-latest]
146+
os: [windows-2025]
147147
node: [22]
148148
subset: [npm, esbuild]
149149
shard: [0, 1, 2, 3, 4, 5]

packages/ngtools/webpack/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Use of this source code is governed by an MIT-style license that can be
44
# found in the LICENSE file at https://angular.dev/license
55

6-
load("@npm//@angular/build-tooling/bazel/api-golden:index.bzl", "api_golden_test_npm_package")
6+
load("@devinfra//bazel/api-golden:index_rjs.bzl", "api_golden_test_npm_package")
77
load("@npm2//:defs.bzl", "npm_link_all_packages")
88
load("//tools:defaults2.bzl", "jasmine_test", "npm_package", "ts_project")
99

test.sh

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
set -e
22

3-
yarn bazel build \
4-
--config=e2e //tests/legacy-cli:e2e_node22
5-
63
yarn bazel test \
7-
--config=e2e //tests/legacy-cli:e2e_node22 \
8-
--spawn_strategy=local \
9-
--test_filter="tests/basic/{build,rebuild}.ts" \
4+
--define=E2E_SHARD_TOTAL=6 --define=E2E_SHARD_INDEX=1 \
5+
--//tests/legacy-cli:enable_native_windows_testing=true \
6+
--config=e2e //tests/legacy-cli:e2e.esbuild_node22 \
107
--test_arg="--esbuild" \
118
--test_env="NG_E2E_RUNNER_WSL_ROOT=C:\wsl_root" \
129
--test_env="NG_E2E_RUNNER_WSL_UNC_BASE=\\\\wsl.localhost\Debian" \
@@ -17,4 +14,5 @@ yarn bazel test \
1714
--test_env="NG_E2E_RUNNER_WSL_HOST_ADDR=$(ip route show | grep -i default | awk '{ print $3}')" \
1815
--test_env="NG_E2E_RUNNER_WSL_VM_ADDR=$(hostname -I)" \
1916
--test_output=streamed \
20-
--flaky_test_attempts=1
17+
--flaky_test_attempts=1 \
18+
--strategy=TestRunner=standalone

tests/legacy-cli/e2e.bzl

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,23 +126,18 @@ def _e2e_tests(name, runner, windows_node_repo, **kwargs):
126126
toolchains = toolchains + ["@npm//@angular/build-tooling/bazel/browsers/chromium:toolchain_alias"]
127127
data = data + ["@npm//@angular/build-tooling/bazel/browsers/chromium"]
128128

129-
windows_node_files = [
129+
windows_test_files = [
130130
"@%s//:node_files" % windows_node_repo,
131131
"@%s//:npm_files" % windows_node_repo,
132132
"@%s//:bin/npm.cmd" % windows_node_repo,
133+
"@org_chromium_chromedriver_windows//:metadata",
134+
"@org_chromium_chromium_windows//:metadata",
133135
]
134136

135137
# In Windows native testing mode, add Windows dependencies. Those are not
136138
# available by default as we technically execute inside Linux/WSL.
137-
toolchains = select({
138-
"//e2e/legacy-cli:native_windows_testing": toolchains + [
139-
"@org_chromium_chromedriver_windows//:metadata",
140-
"@org_chromium_chromium_windows//:metadata",
141-
],
142-
"//conditions:default": toolchains,
143-
})
144139
data = select({
145-
"//e2e/legacy-cli:native_windows_testing": data + windows_node_files,
140+
"//tests/legacy-cli:native_windows_testing": data + windows_test_files,
146141
"//conditions:default": data,
147142
})
148143

tests/legacy-cli/e2e/initialize/300-log-environment.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ export default async function () {
1515
console.log(` ${envName}: ${process.env[envName]!.replace(/[\n\r]+/g, '\n ')}`);
1616
});
1717

18+
console.log(`----`);
19+
1820
// On Windows, `which` might not be available.
1921
if (isWindowsTestMode()) {
2022
console.log(
21-
`Skipping "$(which ng ${getActivePackageManager})" on Windows ` +
23+
`Skipping "$(which ng ${getActivePackageManager()})" on Windows ` +
2224
`as the command may not be available.`,
2325
);
2426
} else {
Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { cp, realpath, symlink } from 'node:fs/promises';
2-
import { isWindowsTestMode, windowsTmpDir } from '../utils/wsl';
1+
import { cp, mkdir, realpath } from 'node:fs/promises';
32
import path from 'node:path';
3+
import { getGlobalVariable } from '../utils/env';
4+
import { interopWslPathForOutsideIfNecessary, isWindowsTestMode } from '../utils/wsl';
45

56
/**
67
* Configure Windows WSL test setup, if needed.
@@ -11,15 +12,42 @@ export default async function () {
1112
return;
1213
}
1314

14-
// Unwrap the symlink of Windows. Windows will otherwise not be able to execute the binary.
15+
// Expose Git binary in path. Node is already exposes via the NPM directory.
16+
// These global tools are used by e2e tests.
17+
process.env['PATH'] = [process.env.PATH, windowsMode.gitBinaryDirForWindows].join(path.delimiter);
18+
19+
// Unwrap the symlinks by Bazel. Windows will otherwise not be able to execute the binary.
1520
// Trick: We use the promises-variant as that one is not patched by Aspect and can resolve outside sandbox/runfiles.
16-
const downloadedNodeBinary = await realpath(windowsMode.nodeBinaryForWindowsInsideWslPath);
21+
const downloadedNodeBinary = await realpath(windowsMode.wslRootBinariesNeedingCopy.nodePath);
22+
const downloadedChromium = await realpath(windowsMode.wslRootBinariesNeedingCopy.chromiumPath);
23+
const downloadedChromedriver = await realpath(
24+
windowsMode.wslRootBinariesNeedingCopy.chromedriverPath,
25+
);
1726

1827
// We will copy the Node version outside of WSL, as otherwise junctions to inside WSL,
1928
// or the UNC path system messes up npm.
20-
await cp(downloadedNodeBinary, windowsMode.nodeBinaryForWindowsPath);
29+
await cp(downloadedNodeBinary, windowsMode.copiedWindowsBinaries.nodePath);
2130

22-
// Expose Git binary in path. Node is already exposes via the NPM directory.
23-
// These global tools are used by e2e tests.
24-
process.env['PATH'] = [process.env.PATH, windowsMode.gitBinaryDirForWindows].join(path.delimiter);
31+
const tmpRoot = getGlobalVariable('tmp-root');
32+
const chromeTestingTmpDir = path.join(tmpRoot, 'chrome-testing-tools');
33+
const chromiumDestDir = path.join(tmpRoot, 'chromium');
34+
const chromedriverDestDir = path.join(tmpRoot, 'chromedriver');
35+
36+
await mkdir(chromeTestingTmpDir);
37+
await cp(path.dirname(downloadedChromium), chromiumDestDir, { recursive: true });
38+
await cp(path.dirname(downloadedChromedriver), chromedriverDestDir, { recursive: true });
39+
40+
const chromiumBinDestPath = path.join(chromiumDestDir, path.basename(downloadedChromium));
41+
const chromedriverBinDestPath = path.join(
42+
chromedriverDestDir,
43+
path.basename(downloadedChromedriver),
44+
);
45+
46+
process.env.CHROME_BIN = interopWslPathForOutsideIfNecessary(chromiumBinDestPath);
47+
process.env.CHROME_PATH = interopWslPathForOutsideIfNecessary(chromiumBinDestPath);
48+
process.env.CHROMEDRIVER_BIN = interopWslPathForOutsideIfNecessary(chromedriverBinDestPath);
49+
50+
// Update `TEMP` to the Windows tmp root that we configure in 001-create-tmp-dir.
51+
// Otherwise we'd spawn Node processes outside WSL with a temp dir in the WSL VM.
52+
process.env.TEMP = tmpRoot;
2553
}

tests/legacy-cli/e2e/tests/build/assets.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import * as fs from 'node:fs';
2-
import { expectFileToExist, expectFileToMatch, writeFile } from '../../utils/fs';
2+
import {
3+
crossPlatformSymlink,
4+
expectFileToExist,
5+
expectFileToMatch,
6+
writeFile,
7+
} from '../../utils/fs';
38
import { ng } from '../../utils/process';
49
import { updateJsonFile } from '../../utils/project';
510
import { expectToFail } from '../../utils/utils';
@@ -28,7 +33,8 @@ export default async function () {
2833
fs.writeFileSync('dirToSymlink/subdir1/b.txt', '');
2934
fs.writeFileSync('dirToSymlink/subdir2/c.txt', '');
3035
fs.writeFileSync('dirToSymlink/subdir2/subsubdir1/d.txt', '');
31-
fs.symlinkSync(process.cwd() + '/dirToSymlink', 'public/symlinkDir');
36+
37+
await crossPlatformSymlink(process.cwd() + '/dirToSymlink', 'public/symlinkDir');
3238

3339
await ng('build', '--configuration=development');
3440

tests/legacy-cli/e2e/tests/build/material.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,5 +89,7 @@ export default async function () {
8989
`,
9090
);
9191

92+
console.error(process.env);
93+
9294
await ng('e2e', '--configuration=production');
9395
}

tests/legacy-cli/e2e/tests/build/rebuild-dot-dirname.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { appendToFile, createDir, rimraf } from '../../utils/fs';
44
import { installWorkspacePackages } from '../../utils/packages';
55
import { killAllProcesses, ng, waitForAnyProcessOutputToMatch } from '../../utils/process';
66
import { ngServe, updateJsonFile, useSha } from '../../utils/project';
7+
import { rm } from 'node:fs/promises';
78

89
const goodRegEx = getGlobalVariable('argv')['esbuild']
910
? /Application bundle generation complete\./
@@ -53,6 +54,6 @@ export default async function () {
5354
} finally {
5455
process.chdir(originalCwd);
5556
await killAllProcesses();
56-
await setTimeout(100);
57+
await setTimeout(500);
5758
}
5859
}

0 commit comments

Comments
 (0)