11import { execaSync } from "execa"
22import { chmod } from "fs/promises"
33import { addExeExt , join } from "patha"
4+ import { isUbuntu } from "../../utils/env/isUbuntu.js"
45import { ubuntuVersion } from "../../utils/env/ubuntu_version.js"
56import { cleanupTmpDir , setupTmpDir , testBin } from "../../utils/tests/test-helpers.js"
67import { 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