1
1
import { execaSync } from "execa"
2
2
import { chmod } from "fs/promises"
3
3
import { addExeExt , join } from "patha"
4
+ import { isUbuntu } from "../../utils/env/isUbuntu.js"
4
5
import { ubuntuVersion } from "../../utils/env/ubuntu_version.js"
5
6
import { cleanupTmpDir , setupTmpDir , testBin } from "../../utils/tests/test-helpers.js"
6
7
import { getVersion } from "../../versions/versions.js"
@@ -14,13 +15,40 @@ describe("setup-gcc", () => {
14
15
} )
15
16
16
17
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 )
18
20
const installInfo = await setupGcc ( version , directory , process . arch )
19
21
20
22
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"
23
50
}
51
+
24
52
await testBin ( gpp , [ "--version" ] , installInfo ?. binDir )
25
53
26
54
expect ( process . env . CC ?. includes ( "gcc" ) ) . toBeTruthy ( )
0 commit comments