Skip to content

Commit 8478964

Browse files
committed
test: clean LLVM installations after each test
1 parent c605e7f commit 8478964

File tree

1 file changed

+38
-36
lines changed

1 file changed

+38
-36
lines changed

src/llvm/__tests__/llvm.test.ts

+38-36
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@ const dirname = typeof __dirname === "string" ? __dirname : path.dirname(fileURL
1515
jest.setTimeout(400000)
1616

1717
describe("setup-llvm", () => {
18-
let directory: string
19-
beforeAll(async () => {
20-
directory = await setupTmpDir("llvm")
21-
})
22-
2318
it("Finds URL for ubuntu version", async () => {
2419
expect(
2520
await getLLVMAssetURL("linux", "x86_64", "13.0.0"),
@@ -65,22 +60,46 @@ describe("setup-llvm", () => {
6560
)
6661
})
6762

68-
it("should setup LLVM", async () => {
69-
const osVersion = await ubuntuVersion()
70-
const { binDir } = await setupLLVM(getVersion("llvm", "true", osVersion), directory, process.arch)
71-
await testBin("clang++", ["--version"], binDir)
63+
let directory: string
64+
beforeEach(async () => {
65+
directory = await setupTmpDir("llvm")
66+
})
7267

73-
expect(process.env.CC?.includes("clang")).toBeTruthy()
74-
expect(process.env.CXX?.includes("clang++")).toBeTruthy()
68+
afterEach(async () => {
69+
await io.rmRF(directory)
70+
}, 100000)
71+
72+
describe("should setup latest LLVM", () => {
73+
it("should download LLVM", async () => {
74+
const osVersion = await ubuntuVersion()
75+
const { binDir } = await setupLLVM(getVersion("llvm", "true", osVersion), directory, process.arch)
76+
await testBin("clang++", ["--version"], binDir)
7577

76-
// test compilation
77-
const file = join(dirname, "main.cpp")
78-
const main_exe = join(dirname, addExeExt("main"))
79-
execaSync("clang++", [file, "-o", main_exe], { cwd: dirname })
80-
if (process.platform !== "win32") {
81-
await chmod(main_exe, "755")
82-
}
83-
execaSync(main_exe, { cwd: dirname, stdio: "inherit" })
78+
expect(process.env.CC?.includes("clang")).toBeTruthy()
79+
expect(process.env.CXX?.includes("clang++")).toBeTruthy()
80+
81+
// test compilation
82+
const file = join(dirname, "main.cpp")
83+
const main_exe = join(dirname, addExeExt("main"))
84+
execaSync("clang++", [file, "-o", main_exe], { cwd: dirname })
85+
if (process.platform !== "win32") {
86+
await chmod(main_exe, "755")
87+
}
88+
execaSync(main_exe, { cwd: dirname, stdio: "inherit" })
89+
})
90+
91+
it("should setup clang-format", async () => {
92+
const osVersion = await ubuntuVersion()
93+
const { binDir } = await setupClangFormat(getVersion("llvm", "true", osVersion), directory, process.arch)
94+
await testBin("clang-format", ["--version"], binDir)
95+
})
96+
97+
it("should setup clang tools", async () => {
98+
const osVersion = await ubuntuVersion()
99+
const { binDir } = await setupClangTools(getVersion("llvm", "true", osVersion), directory, process.arch)
100+
await testBin("clang-tidy", ["--version"], binDir)
101+
await testBin("clang-format", ["--version"], binDir)
102+
})
84103
})
85104

86105
it("should setup LLVM 5 from llvm.org", async () => {
@@ -99,21 +118,4 @@ describe("setup-llvm", () => {
99118
}
100119
execaSync(main_exe, { cwd: dirname, stdio: "inherit" })
101120
})
102-
103-
it("should setup clang-format", async () => {
104-
const osVersion = await ubuntuVersion()
105-
const { binDir } = await setupClangFormat(getVersion("llvm", "true", osVersion), directory, process.arch)
106-
await testBin("clang-format", ["--version"], binDir)
107-
})
108-
109-
it("should setup clang tools", async () => {
110-
const osVersion = await ubuntuVersion()
111-
const { binDir } = await setupClangTools(getVersion("llvm", "true", osVersion), directory, process.arch)
112-
await testBin("clang-tidy", ["--version"], binDir)
113-
await testBin("clang-format", ["--version"], binDir)
114-
})
115-
116-
afterAll(async () => {
117-
await io.rmRF(directory)
118-
}, 100000)
119121
})

0 commit comments

Comments
 (0)