Rename xcodeVersionFromSdk and improve comments/log messages

This commit is contained in:
Michael B. Gale
2026-10-30 16:18:06 +00:00
parent efea0445d3
commit 80d7b74bf4
5 changed files with 46 additions and 44 deletions

View File

@@ -12,7 +12,7 @@ import {
darwinVersion,
XCODE_SELECT_LINK_PATH,
xcodeVersionFromLink,
xcodeVersionFromSdk,
xcodeSdkVersion,
xcodeVersionFromXcodeBuild,
} from "./platform";
import {
@@ -298,7 +298,7 @@ test.serial(
);
test.serial(
"xcodeVersionFromSdk returns undefined for non-zero exit code",
"xcodeSdkVersion returns undefined for non-zero exit code",
async (t) => {
const logger = new RecordingLogger();
@@ -308,7 +308,7 @@ test.serial(
const toolrunnerStub = sinon.stub(toolrunner, "ToolRunner").returns(runner);
await t.notThrowsAsync(async () => {
const result = await xcodeVersionFromSdk(logger);
const result = await xcodeSdkVersion(logger);
t.is(result, undefined);
@@ -325,41 +325,38 @@ test.serial(
},
);
test.serial(
"xcodeVersionFromSdk extracts version from xcrun stdout",
async (t) => {
const logger = new RecordingLogger();
test.serial("xcodeSdkVersion extracts version from xcrun stdout", async (t) => {
const logger = new RecordingLogger();
const which = sinon.stub(io, "which").resolves("/path/to/xcrun");
const which = sinon.stub(io, "which").resolves("/path/to/xcrun");
let stdoutListener: ((data: Buffer) => void) | undefined = undefined;
const exec = sinon.stub<[], Promise<number>>().callsFake(async () => {
if (stdoutListener !== undefined) {
stdoutListener(Buffer.from("26.5"));
}
return 0;
let stdoutListener: ((data: Buffer) => void) | undefined = undefined;
const exec = sinon.stub<[], Promise<number>>().callsFake(async () => {
if (stdoutListener !== undefined) {
stdoutListener(Buffer.from("26.5"));
}
return 0;
});
const runner = sinon.createStubInstance(toolrunner.ToolRunner, { exec });
const toolrunnerStub = sinon
.stub(toolrunner, "ToolRunner")
.callsFake((_cmd, _args, opts: ExecOptions) => {
stdoutListener = opts.listeners?.stdout;
return runner;
});
const runner = sinon.createStubInstance(toolrunner.ToolRunner, { exec });
const toolrunnerStub = sinon
.stub(toolrunner, "ToolRunner")
.callsFake((_cmd, _args, opts: ExecOptions) => {
stdoutListener = opts.listeners?.stdout;
return runner;
});
await t.notThrowsAsync(async () => {
const result = await xcodeSdkVersion(logger);
await t.notThrowsAsync(async () => {
const result = await xcodeVersionFromSdk(logger);
t.not(result, undefined);
t.is(result?.major, 26);
t.is(result?.minor, 5);
t.not(result, undefined);
t.is(result?.major, 26);
t.is(result?.minor, 5);
t.is(which.callCount, 1);
t.deepEqual(which.args[0], ["xcrun", true]);
t.is(which.callCount, 1);
t.deepEqual(which.args[0], ["xcrun", true]);
t.is(toolrunnerStub.callCount, 1);
t.is(exec.callCount, 1);
});
},
);
t.is(toolrunnerStub.callCount, 1);
t.is(exec.callCount, 1);
});
});