mirror of https://github.com/aminya/setup-cpp
test: test the default GCC version correctly
This commit is contained in:
parent
6cf096c7bf
commit
4e9255bbdf
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue