Skip to content

Commit e51091e

Browse files
cdervclaude
andcommitted
Use detected platform in CfT test directory names
Tests hardcoded `linux64` or `win64` subdirectory names, so `findCftExecutable` only hit the fast path on that one platform and silently fell through to the walk fallback elsewhere. Use `detectCftPlatform().platform` so the fast path is exercised on every OS. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4a25207 commit e51091e

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

tests/unit/tools/chrome-for-testing.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ unitTest("fetchLatestCftRelease - download URLs are valid", async () => {
7878
unitTest("findCftExecutable - finds binary in CfT directory structure", async () => {
7979
const tempDir = Deno.makeTempDirSync();
8080
try {
81-
const subdir = join(tempDir, "chrome-headless-shell-linux64");
81+
const { platform } = detectCftPlatform();
82+
const subdir = join(tempDir, `chrome-headless-shell-${platform}`);
8283
Deno.mkdirSync(subdir);
8384
const binaryName = isWindows
8485
? "chrome-headless-shell.exe"
@@ -110,7 +111,8 @@ unitTest("findCftExecutable - returns undefined for empty directory", async () =
110111
unitTest("findCftExecutable - finds binary in nested structure", async () => {
111112
const tempDir = Deno.makeTempDirSync();
112113
try {
113-
const nested = join(tempDir, "chrome-headless-shell-win64", "subfolder");
114+
const { platform } = detectCftPlatform();
115+
const nested = join(tempDir, `chrome-headless-shell-${platform}`, "subfolder");
114116
Deno.mkdirSync(nested, { recursive: true });
115117
const binaryName = isWindows
116118
? "chrome-headless-shell.exe"

tests/unit/tools/chrome-headless-shell.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { existsSync, safeRemoveSync } from "../../../src/deno_ral/fs.ts";
1111
import { isWindows } from "../../../src/deno_ral/platform.ts";
1212
import { runningInCI } from "../../../src/core/ci-info.ts";
1313
import { InstallContext } from "../../../src/tools/types.ts";
14-
import { findCftExecutable } from "../../../src/tools/impl/chrome-for-testing.ts";
14+
import { detectCftPlatform, findCftExecutable } from "../../../src/tools/impl/chrome-for-testing.ts";
1515
import { installableTool, installableTools } from "../../../src/tools/tools.ts";
1616
import {
1717
chromeHeadlessShellInstallable,
@@ -91,7 +91,8 @@ unitTest("isInstalled - returns false when only version file exists", async () =
9191
unitTest("isInstalled - returns false when only binary exists (no version file)", async () => {
9292
const tempDir = Deno.makeTempDirSync();
9393
try {
94-
const subdir = join(tempDir, "chrome-headless-shell-win64");
94+
const { platform } = detectCftPlatform();
95+
const subdir = join(tempDir, `chrome-headless-shell-${platform}`);
9596
Deno.mkdirSync(subdir);
9697
const binaryName = isWindows ? "chrome-headless-shell.exe" : "chrome-headless-shell";
9798
Deno.writeTextFileSync(join(subdir, binaryName), "fake");
@@ -105,7 +106,8 @@ unitTest("isInstalled - returns true when version file and binary exist", async
105106
const tempDir = Deno.makeTempDirSync();
106107
try {
107108
noteInstalledVersion(tempDir, "145.0.0.0");
108-
const subdir = join(tempDir, "chrome-headless-shell-win64");
109+
const { platform } = detectCftPlatform();
110+
const subdir = join(tempDir, `chrome-headless-shell-${platform}`);
109111
Deno.mkdirSync(subdir);
110112
const binaryName = isWindows ? "chrome-headless-shell.exe" : "chrome-headless-shell";
111113
Deno.writeTextFileSync(join(subdir, binaryName), "fake");

0 commit comments

Comments
 (0)