Skip to content

Commit

Permalink
test: test the default GCC version correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Sep 3, 2024
1 parent 6cf096c commit 4e9255b
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions src/gcc/__tests__/gcc.test.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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()
Expand Down

0 comments on commit 4e9255b

Please sign in to comment.