diff --git a/src/gcc/__tests__/gcc.test.ts b/src/gcc/__tests__/gcc.test.ts index 0a1a3692..1aef619f 100644 --- a/src/gcc/__tests__/gcc.test.ts +++ b/src/gcc/__tests__/gcc.test.ts @@ -1,6 +1,7 @@ import { execaSync } from "execa" import { chmod } from "fs/promises" import { addExeExt, join } from "patha" +import { isUbuntu } from "../../utils/env/isUbuntu.js" import { ubuntuVersion } from "../../utils/env/ubuntu_version.js" import { cleanupTmpDir, setupTmpDir, testBin } from "../../utils/tests/test-helpers.js" import { getVersion } from "../../versions/versions.js" @@ -14,13 +15,40 @@ describe("setup-gcc", () => { }) it("should setup gcc", async () => { - const version = getVersion("gcc", undefined, await ubuntuVersion()) + const ubuntuVersionOutput = await ubuntuVersion() + const version = getVersion("gcc", undefined, ubuntuVersionOutput) const installInfo = await setupGcc(version, directory, process.arch) let gpp = "g++" - if (process.platform !== "win32") { - gpp = `g++-${version}` + if (isUbuntu()) { + const ubuntuMajorVersion = ubuntuVersionOutput?.[0] + // https://packages.ubuntu.com/search?keywords=gcc + switch (ubuntuMajorVersion) { + case 26: + case 25: + gpp = "g++-14" + break + case 24: + case 23: + gpp = "g++-13" + break + case 22: + case 21: + gpp = "g++-11" + break + case 20: + gpp = "g++-9" + break + default: { + // ignore + } + } + } else if (process.platform === "darwin") { + // https://formulae.brew.sh/formula/gcc + // As of 3, Sep, 2024 + gpp = "g++-14" } + await testBin(gpp, ["--version"], installInfo?.binDir) expect(process.env.CC?.includes("gcc")).toBeTruthy()