Skip to content

Commit 4e9255b

Browse files
committed
test: test the default GCC version correctly
1 parent 6cf096c commit 4e9255b

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

src/gcc/__tests__/gcc.test.ts

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { execaSync } from "execa"
22
import { chmod } from "fs/promises"
33
import { addExeExt, join } from "patha"
4+
import { isUbuntu } from "../../utils/env/isUbuntu.js"
45
import { ubuntuVersion } from "../../utils/env/ubuntu_version.js"
56
import { cleanupTmpDir, setupTmpDir, testBin } from "../../utils/tests/test-helpers.js"
67
import { getVersion } from "../../versions/versions.js"
@@ -14,13 +15,40 @@ describe("setup-gcc", () => {
1415
})
1516

1617
it("should setup gcc", async () => {
17-
const version = getVersion("gcc", undefined, await ubuntuVersion())
18+
const ubuntuVersionOutput = await ubuntuVersion()
19+
const version = getVersion("gcc", undefined, ubuntuVersionOutput)
1820
const installInfo = await setupGcc(version, directory, process.arch)
1921

2022
let gpp = "g++"
21-
if (process.platform !== "win32") {
22-
gpp = `g++-${version}`
23+
if (isUbuntu()) {
24+
const ubuntuMajorVersion = ubuntuVersionOutput?.[0]
25+
// https://packages.ubuntu.com/search?keywords=gcc
26+
switch (ubuntuMajorVersion) {
27+
case 26:
28+
case 25:
29+
gpp = "g++-14"
30+
break
31+
case 24:
32+
case 23:
33+
gpp = "g++-13"
34+
break
35+
case 22:
36+
case 21:
37+
gpp = "g++-11"
38+
break
39+
case 20:
40+
gpp = "g++-9"
41+
break
42+
default: {
43+
// ignore
44+
}
45+
}
46+
} else if (process.platform === "darwin") {
47+
// https://formulae.brew.sh/formula/gcc
48+
// As of 3, Sep, 2024
49+
gpp = "g++-14"
2350
}
51+
2452
await testBin(gpp, ["--version"], installInfo?.binDir)
2553

2654
expect(process.env.CC?.includes("gcc")).toBeTruthy()

0 commit comments

Comments
 (0)