|
1 | 1 | import fs from "fs"; |
2 | 2 |
|
| 3 | +import * as io from "@actions/io"; |
3 | 4 | import test from "ava"; |
4 | 5 | import * as sinon from "sinon"; |
5 | 6 |
|
@@ -426,6 +427,61 @@ test.serial( |
426 | 427 | }), |
427 | 428 | ); |
428 | 429 |
|
| 430 | +test.serial( |
| 431 | + "checkRunnerSupportsTracedAnalysis uses Xcode SDK version as fallback", |
| 432 | + async (t) => |
| 433 | + withTmpDir(async (tmpDir) => { |
| 434 | + const logger = new RecordingLogger(); |
| 435 | + const env = getTestEnv(); |
| 436 | + env.set(ActionsEnvVars.RUNNER_TEMP, tmpDir); |
| 437 | + const features = createFeatures([Feature.CheckUnsupportedTracedAnalysis]); |
| 438 | + |
| 439 | + const readlinkSync = sinon |
| 440 | + .stub(fs, "readlinkSync") |
| 441 | + .throws(new Error("Not found")); |
| 442 | + const which = sinon.stub(io, "which").throws(new Error("Tool not found")); |
| 443 | + |
| 444 | + const codeql = await getCodeQLWithTracedStub( |
| 445 | + "codeql-for-testing", |
| 446 | + logger, |
| 447 | + env, |
| 448 | + ); |
| 449 | + sinon.stub(codeql, "getVersion").resolves(makeVersionInfo("2.27.0")); |
| 450 | + |
| 451 | + const addDiagnostic = sinon.stub(diagnostics, "addDiagnostic"); |
| 452 | + |
| 453 | + const config = createTestConfig({ |
| 454 | + tempDir: tmpDir, |
| 455 | + languages: [BuiltInLanguage.swift], |
| 456 | + }); |
| 457 | + await checkRunnerSupportsTracedAnalysis( |
| 458 | + initAllState({ |
| 459 | + logger, |
| 460 | + platform: "darwin", |
| 461 | + osRelease: "26.0.0", |
| 462 | + env, |
| 463 | + features, |
| 464 | + }), |
| 465 | + config, |
| 466 | + codeql, |
| 467 | + ); |
| 468 | + |
| 469 | + t.is(readlinkSync.callCount, 1); |
| 470 | + t.deepEqual(readlinkSync.args[0], [XCODE_SELECT_LINK_PATH]); |
| 471 | + t.is(which.callCount, 1); |
| 472 | + t.deepEqual(which.args[0], ["xcrun", true]); |
| 473 | + |
| 474 | + checkExpectedLogMessages(t, logger.messages, [ |
| 475 | + "Unable to determine Xcode version: Tool not found", |
| 476 | + ]); |
| 477 | + checkUnexpectedLogMessages(t, logger.messages, [ |
| 478 | + "Traced analysis is not supported on Xcode 27", |
| 479 | + ]); |
| 480 | + |
| 481 | + t.is(addDiagnostic.callCount, 0); |
| 482 | + }), |
| 483 | +); |
| 484 | + |
429 | 485 | // `addDiagnostic` changes global state and we must stub it, so this test must be serial. |
430 | 486 | test.serial( |
431 | 487 | "checkRunnerSupportsTracedAnalysis logs and adds diagnostic if Xcode version is unsupported", |
|
0 commit comments