Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ jobs:
shell: pwsh
run: |
npm run build:platform-native-helpers
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
npx tsc
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
npx vite build
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
npx electron-builder --win dir nsis --x64 --publish never
- name: Smoke test packaged Windows paths
Expand Down
66 changes: 66 additions & 0 deletions electron/windowsCmakeGenerators.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { describe, expect, it, vi } from "vitest";

import {
configureWithWindowsCmakeGenerator,
WINDOWS_CMAKE_GENERATORS,
WINDOWS_VISUAL_STUDIO_INSTALL_DIRS,
} from "../scripts/windows-cmake-generators.mjs";

describe("configureWithWindowsCmakeGenerator", () => {
it("uses Visual Studio 2026 first", () => {
const configure = vi.fn();
const clearCache = vi.fn();

const selected = configureWithWindowsCmakeGenerator({
prefix: "test",
configure,
clearCache,
});

expect(selected).toBe("Visual Studio 18 2026");
expect(WINDOWS_VISUAL_STUDIO_INSTALL_DIRS[0]).toBe("18");
expect(configure).toHaveBeenCalledWith("Visual Studio 18 2026", "v143");
expect(clearCache).toHaveBeenCalledTimes(1);
});

it("falls back in supported-version order and clears stale CMake state", () => {
const attempted = [];
const clearCache = vi.fn();
const log = vi.fn();

const selected = configureWithWindowsCmakeGenerator({
prefix: "test",
clearCache,
log,
configure: (generator, toolset) => {
attempted.push({ name: generator, toolset });
if (generator !== "Visual Studio 16 2019") {
throw new Error(`${generator} unavailable`);
}
},
});

expect(attempted).toEqual(
WINDOWS_CMAKE_GENERATORS.map(({ name, toolset }) => ({ name, toolset })),
);
expect(clearCache).toHaveBeenCalledTimes(3);
expect(log).toHaveBeenCalledTimes(2);
expect(selected).toBe("Visual Studio 16 2019");
});

it("rethrows the final configure error when no supported generator exists", () => {
const finalError = new Error("VS 2019 unavailable");

expect(() =>
configureWithWindowsCmakeGenerator({
prefix: "test",
clearCache: vi.fn(),
log: vi.fn(),
configure: (generator) => {
if (generator === "Visual Studio 16 2019") throw finalError;
throw new Error(`${generator} unavailable`);
},
}),
).toThrow(finalError);
});
});
Loading
Loading