Skip to content

Commit aad026e

Browse files
committed
fix: various test discovery on Windows fixes
1 parent f476e6b commit aad026e

File tree

2 files changed

+32
-10
lines changed

2 files changed

+32
-10
lines changed

electron/spec-runner.ts

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import * as fs from "node:fs";
66
import * as path from "node:path";
77
import { pathToFileURL } from "node:url";
88

9-
export async function setupSpecRunner(electronRoot: string) {
9+
export async function setupSpecRunner(
10+
electronRoot: string,
11+
depotToolsDir: string,
12+
) {
1013
const { hashElement } = await import(
1114
pathToFileURL(
1215
path.resolve(electronRoot, "node_modules", "folder-hash", "index.js"),
@@ -23,7 +26,6 @@ export async function setupSpecRunner(electronRoot: string) {
2326
);
2427

2528
const BASE = path.resolve(electronRoot, "..");
26-
const NPX_CMD = process.platform === "win32" ? "npx.cmd" : "npx";
2729

2830
function generateTypeDefinitions() {
2931
const { status } = childProcess.spawnSync(
@@ -85,27 +87,43 @@ export async function setupSpecRunner(electronRoot: string) {
8587
...process.env,
8688
CXXFLAGS: process.env.CXXFLAGS,
8789
npm_config_nodedir: nodeDir,
88-
npm_config_msvs_version: "2019",
90+
npm_config_msvs_version: "2022",
8991
npm_config_yes: "true",
9092
};
93+
if (process.platform === "win32") {
94+
env.npm_config_python = path.resolve(depotToolsDir, "python3.bat");
95+
}
9196
if (fs.existsSync(path.resolve(dir, "node_modules"))) {
9297
await fs.promises.rm(path.resolve(dir, "node_modules"), {
9398
force: true,
9499
recursive: true,
95100
});
96101
}
97-
const { status } = childProcess.spawnSync(
98-
NPX_CMD,
99-
[`yarn@${YARN_VERSION}`, "install", "--frozen-lockfile"],
102+
const { status, stderr } = childProcess.spawnSync(
103+
"e",
104+
["d", "npx", `yarn@${YARN_VERSION}`, "install", "--frozen-lockfile"],
100105
{
101106
env,
102107
cwd: dir,
103-
stdio: "inherit",
108+
stdio: "pipe",
109+
shell: process.platform === "win32",
110+
encoding: "utf-8",
104111
},
105112
);
106113
if (status !== 0 && !process.env.IGNORE_YARN_INSTALL_ERROR) {
107-
console.log(`Failed to yarn install in '${dir}'`);
108-
process.exit(1);
114+
if (stderr.includes("missing any VC++ toolset")) {
115+
throw new Error(
116+
`Failed to yarn install in '${dir}': missing any VC++ toolset`,
117+
);
118+
}
119+
120+
if (stderr.includes("missing any Windows SDK")) {
121+
throw new Error(
122+
`Failed to yarn install in '${dir}': missing any Windows SDK`,
123+
);
124+
}
125+
126+
throw new Error(`Failed to yarn install in '${dir}': ${stderr}`);
109127
}
110128
}
111129

src/tests.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,12 @@ async function getElectronTests(
403403
);
404404
}
405405

406+
const depotToolsDir = await vscode.commands.executeCommand<string>(
407+
`${commandPrefix}.show.depotdir`,
408+
);
409+
406410
// This does things like install modules if they haven't been installed yet
407-
await setupSpecRunner(electronRoot.fsPath);
411+
await setupSpecRunner(electronRoot.fsPath, depotToolsDir);
408412

409413
const electronExe = await vscode.commands.executeCommand<string>(
410414
`${commandPrefix}.show.exec`,

0 commit comments

Comments
 (0)