Avoid macOS CI CLI shim prompt in smoke test

This commit is contained in:
Mohamed Boudra
2026-03-10 11:49:35 +07:00
parent f3acdedfb1
commit f760255d50
@@ -394,6 +394,10 @@ function logStep(label) {
console.log(`\n[managed-smoke] ${label}`); console.log(`\n[managed-smoke] ${label}`);
} }
function shouldAttemptCliShimInstall(env) {
return !(process.platform === "darwin" && env.CI === "true");
}
const packagedBinary = resolvePackagedBinary(); const packagedBinary = resolvePackagedBinary();
await ensurePackagedArtifact(packagedBinary); await ensurePackagedArtifact(packagedBinary);
if (!(await pathExists(packagedBinary))) { if (!(await pathExists(packagedBinary))) {
@@ -539,23 +543,40 @@ try {
assert.equal(persistedManagedStatus.json.relayEnabled, true); assert.equal(persistedManagedStatus.json.relayEnabled, true);
assertNoForbiddenPathsOrPorts(persistedManagedStatus.json, forbiddenManagedReferences); assertNoForbiddenPathsOrPorts(persistedManagedStatus.json, forbiddenManagedReferences);
logStep("Installing CLI shim and verifying the bundled CLI target"); const attemptCliShimInstall = shouldAttemptCliShimInstall(managedEnv);
const cliInstall = await runBinary( const cliInstall = attemptCliShimInstall
packagedBinary, ? await (async () => {
["--managed-headless", "install-cli-shim"], logStep("Installing CLI shim and verifying the bundled CLI target");
managedEnv return await runBinary(
); packagedBinary,
["--managed-headless", "install-cli-shim"],
managedEnv
);
})()
: {
json: {
status: "skippedInCi",
installed: false,
path: null,
message: "Skipping privileged macOS CLI shim install in CI; verifying bundled CLI directly.",
},
};
const cliShimPath = cliInstall.json.path; const cliShimPath = cliInstall.json.path;
assert.ok(cliShimPath, "CLI shim path should be returned"); const cliShimInstalled =
const cliShimInstalled = cliInstall.json.installed === true && (await pathExists(cliShimPath)); Boolean(attemptCliShimInstall && cliShimPath) && cliInstall.json.installed === true && (await pathExists(cliShimPath));
if (!cliShimInstalled) { if (attemptCliShimInstall) {
assert.ok(cliInstall.json.manualInstructions, "manual CLI install instructions should be returned"); assert.ok(cliShimPath, "CLI shim path should be returned");
assert.match( if (!cliShimInstalled) {
cliInstall.json.manualInstructions.commands, assert.ok(cliInstall.json.manualInstructions, "manual CLI install instructions should be returned");
new RegExp(escapeForRegExp(runtimeStatus.json.runtimeRoot)), assert.match(
"manual CLI install instructions should point at the bundled runtime" cliInstall.json.manualInstructions.commands,
); new RegExp(escapeForRegExp(runtimeStatus.json.runtimeRoot)),
assertNoForbiddenPathsOrPorts(cliInstall.json.manualInstructions, forbiddenManagedReferences); "manual CLI install instructions should point at the bundled runtime"
);
assertNoForbiddenPathsOrPorts(cliInstall.json.manualInstructions, forbiddenManagedReferences);
}
} else {
logStep("Skipping privileged CLI shim install in CI and verifying the bundled CLI target directly");
} }
const cliVersion = cliShimInstalled const cliVersion = cliShimInstalled
? await execFileAsync(cliShimPath, ["--version"], { ? await execFileAsync(cliShimPath, ["--version"], {
@@ -707,7 +728,9 @@ try {
await runBinary(packagedBinary, ["--managed-headless", "stop-daemon"], managedEnv); await runBinary(packagedBinary, ["--managed-headless", "stop-daemon"], managedEnv);
} catch {} } catch {}
try { try {
await runBinary(packagedBinary, ["--managed-headless", "uninstall-cli-shim"], managedEnv); if (shouldAttemptCliShimInstall(managedEnv)) {
await runBinary(packagedBinary, ["--managed-headless", "uninstall-cli-shim"], managedEnv);
}
} catch {} } catch {}
try { try {
if (startedTemporaryExternalDaemon) { if (startedTemporaryExternalDaemon) {