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 5c0c766
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 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,12 +15,34 @@ 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
}
}
}
await testBin(gpp, ["--version"], installInfo?.binDir)

Expand Down

0 comments on commit 5c0c766

Please sign in to comment.