diff --git a/src/gcc/__tests__/gcc.test.ts b/src/gcc/__tests__/gcc.test.ts index d3eba8e2..68551c69 100644 --- a/src/gcc/__tests__/gcc.test.ts +++ b/src/gcc/__tests__/gcc.test.ts @@ -1,6 +1,10 @@ import { testBin } from "../../utils/tests/test-helpers" import { setupGcc } from "../gcc" import { getVersion } from "../../default_versions" +import path from "path" +import execa from "execa" +import { addBinExtension } from "../../utils/extension/extension" +import { chmodSync } from "fs" jest.setTimeout(3000000) describe("setup-gcc", () => { @@ -16,5 +20,14 @@ describe("setup-gcc", () => { expect(process.env.CC?.includes("gcc")).toBeTruthy() expect(process.env.CXX?.includes("g++")).toBeTruthy() + + // test compilation + const file = path.join(__dirname, "main.cpp") + const main_exe = path.join(__dirname, addBinExtension("main")) + execa.sync("g++", [file, "-o", main_exe], { cwd: __dirname }) + if (process.platform !== "win32") { + chmodSync(main_exe, "755") + } + execa.sync(main_exe, { cwd: __dirname, stdio: "inherit" }) }) }) diff --git a/src/gcc/__tests__/main.cpp b/src/gcc/__tests__/main.cpp new file mode 100644 index 00000000..f3ac3e8a --- /dev/null +++ b/src/gcc/__tests__/main.cpp @@ -0,0 +1,18 @@ +// test std libraries +#include +#include + +// test c libraries +#include +#include +#include +#include +#include + +int main() { + const auto x = 10.0; + std::cout << "Testing " << x << '\n'; + + const auto y = std::to_string(x); + std::cout << "Testing " << y << '\n'; +} diff --git a/src/llvm/__tests__/llvm.test.ts b/src/llvm/__tests__/llvm.test.ts index 8131b355..c526494d 100644 --- a/src/llvm/__tests__/llvm.test.ts +++ b/src/llvm/__tests__/llvm.test.ts @@ -3,6 +3,10 @@ import { getSpecificVersionAndUrl } from "../../utils/setup/version" import { isValidUrl } from "../../utils/http/validate_url" import { setupTmpDir, cleanupTmpDir, testBin } from "../../utils/tests/test-helpers" import { isGitHubCI } from "../../utils/env/isci" +import execa from "execa" +import path from "path" +import { addBinExtension } from "../../utils/extension/extension" +import { chmodSync } from "fs" jest.setTimeout(400000) async function testUrl(version: string) { @@ -22,6 +26,7 @@ describe("setup-llvm", () => { it("Finds valid LLVM URLs", async () => { await Promise.all( [ + "13.0.0", "12.0.0", "12", "11", @@ -43,15 +48,24 @@ describe("setup-llvm", () => { }) it("should setup LLVM", async () => { - const { binDir } = await setupLLVM("11.0.0", directory, process.arch) + const { binDir } = await setupLLVM("13.0.0", directory, 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 = path.join(__dirname, "main.cpp") + const main_exe = path.join(__dirname, addBinExtension("main")) + execa.sync("clang++", [file, "-o", main_exe], { cwd: __dirname }) + if (process.platform !== "win32") { + chmodSync(main_exe, "755") + } + execa.sync(main_exe, { cwd: __dirname, stdio: "inherit" }) }) it("should find llvm in the cache", async () => { - const { binDir } = await setupLLVM("11.0.0", directory, process.arch) + const { binDir } = await setupLLVM("13.0.0", directory, process.arch) await testBin("clang++", ["--version"], binDir) if (isGitHubCI()) { @@ -68,7 +82,7 @@ describe("setup-llvm", () => { }) it("should setup clang-tidy and clang-format", async () => { - const { binDir } = await setupClangTools("11.0.0", directory, process.arch) + const { binDir } = await setupClangTools("13.0.0", directory, process.arch) await testBin("clang-tidy", ["--version"], binDir) await testBin("clang-format", ["--version"], binDir) }) diff --git a/src/llvm/__tests__/main.cpp b/src/llvm/__tests__/main.cpp new file mode 100644 index 00000000..f3ac3e8a --- /dev/null +++ b/src/llvm/__tests__/main.cpp @@ -0,0 +1,18 @@ +// test std libraries +#include +#include + +// test c libraries +#include +#include +#include +#include +#include + +int main() { + const auto x = 10.0; + std::cout << "Testing " << x << '\n'; + + const auto y = std::to_string(x); + std::cout << "Testing " << y << '\n'; +}