Repository navigation
Expand file tree
/
Copy pathllvm.test.ts
More file actions
152 lines (131 loc) · 4.59 KB
/
Copy pathllvm.test.ts
File metadata and controls
152 lines (131 loc) · 4.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
import path, { join } from "path"
import { fileURLToPath } from "url"
import * as io from "@actions/io"
import { execa } from "execa"
import { chmod } from "fs/promises"
import { addExeExt } from "patha"
import { ubuntuVersion } from "../../utils/env/ubuntu_version.js"
import { setupTmpDir, testBin } from "../../utils/tests/test-helpers.js"
import { getVersion } from "../../versions/versions.js"
import { setupClangFormat, setupClangTools, setupLLVM } from "../llvm.js"
import { getLLVMAssetURL } from "../llvm_url.js"
const dirname = typeof __dirname === "string" ? __dirname : path.dirname(fileURLToPath(import.meta.url))
jest.setTimeout(400000)
describe("setup-llvm", () => {
it("Finds URL for ubuntu version", async () => {
expect(
await getLLVMAssetURL("linux", "x86_64", "13.0.0"),
).toStrictEqual(
"https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04.tar.xz",
)
expect(
await getLLVMAssetURL("linux", "x86_64", "13.0.1"),
).toStrictEqual(
"https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.1/clang+llvm-13.0.1-x86_64-linux-gnu-ubuntu-18.04.tar.xz",
)
})
it("Finds valid LLVM URLs", async () => {
await Promise.all(
[
"21",
"20",
"19",
"18",
"17",
"16",
"15",
"15.0.2",
// "14.0.1",
"14.0.0",
"13.0.0",
"12.0.0",
"12",
"11",
"11.0.0",
"10",
"10.0.0",
"9.0.0",
"8",
"8.0.0",
"7.0.0",
"7",
"6",
"6.0.0",
"5",
"5.0.0",
"4",
].map((version) => getLLVMAssetURL("win32", "x64", version)),
)
})
it("should setup latest LLVM", async () => {
const directory = await setupTmpDir("llvm")
const osVersion = await ubuntuVersion()
{
const { binDir } = await setupLLVM({
version: getVersion("llvm", "true", osVersion),
setupDir: directory,
arch: process.arch,
})
await testBin("clang++", ["--version"], binDir)
expect(process.env.CC?.includes("clang")).toBeTruthy()
expect(process.env.CXX?.includes("clang++")).toBeTruthy()
// test compilation
const file = join(dirname, "main.cpp")
const main_exe = join(dirname, addExeExt("main"))
await execa("clang++", [file, "-o", main_exe], { cwd: dirname })
if (process.platform !== "win32") {
await chmod(main_exe, "755")
}
await execa(main_exe, { cwd: dirname, stdio: "inherit" })
}
{
const { binDir } = await setupClangFormat({
version: getVersion("llvm", "true", osVersion),
setupDir: directory,
arch: process.arch,
})
await testBin("clang-format", ["--version"], binDir)
}
{
const { binDir } = await setupClangTools({
version: getVersion("llvm", "true", osVersion),
setupDir: directory,
arch: process.arch,
})
await testBin("clang-tidy", ["--version"], binDir)
await testBin("clang-format", ["--version"], binDir)
}
await io.rmRF(directory)
})
it("should setup LLVM 5 from llvm.org", async () => {
const directory = await setupTmpDir("llvm")
const { binDir } = await setupLLVM({ version: "5", setupDir: directory, arch: process.arch })
await testBin("clang++", ["--version"], binDir)
expect(process.env.CC?.includes("clang")).toBeTruthy()
expect(process.env.CXX?.includes("clang++")).toBeTruthy()
if (process.platform === "linux") {
// test compilation
// the old clang doesn't work inside GitHub actions for other than linux due to system libraries and SDKs
const file = join(dirname, "main.cpp")
const main_exe = join(dirname, addExeExt("main"))
await execa("clang++", ["-std=c++17", file, "-o", main_exe], { cwd: dirname })
await chmod(main_exe, "755")
await execa(main_exe, { cwd: dirname, stdio: "inherit" })
}
await io.rmRF(directory)
})
// test installation of LLVM 10 to 19 on Linux
for (let version = 10; version <= 19; version++) {
if (process.platform !== "linux") {
continue
}
it(`should setup LLVM ${version} on Linux`, async () => {
const directory = await setupTmpDir("llvm")
const { binDir } = await setupLLVM({ version: `${version}`, setupDir: directory, arch: process.arch })
await testBin("clang++", ["--version"], binDir)
expect(process.env.CC?.includes("clang")).toBeTruthy()
expect(process.env.CXX?.includes("clang++")).toBeTruthy()
await io.rmRF(directory)
})
}
})