test: use testBin in all the tests

This commit is contained in:
Amin Yahyaabadi 2021-09-16 10:15:43 -05:00
parent dde8036194
commit 596c9438b5
12 changed files with 29 additions and 76 deletions

View File

@ -1,5 +1,5 @@
import { setupBrew } from "../brew"
import { spawnSync as spawn } from "child_process"
import { testBin } from "../../utils/tests/test-helpers"
jest.setTimeout(200000)
describe("setup-brew", () => {
@ -7,11 +7,7 @@ describe("setup-brew", () => {
if (process.platform !== "darwin") {
return
}
await setupBrew("", "", "")
const { status } = spawn("brew", ["--version"], {
encoding: "utf8",
})
expect(status).toBe(0)
setupBrew("", "", "")
await testBin("brew")
})
})

View File

@ -1,14 +1,11 @@
import { setupCcache } from "../ccache"
import { spawnSync as spawn } from "child_process"
import { testBin } from "../../utils/tests/test-helpers"
jest.setTimeout(200000)
describe("setup-ccache", () => {
it("should setup ccache", async () => {
await setupCcache("", "", "")
const { status } = spawn("ccache", ["--version"], {
encoding: "utf8",
})
expect(status).toBe(0)
await testBin("ccache")
})
})

View File

@ -1,5 +1,5 @@
import { testBin } from "../../utils/tests/test-helpers"
import { setupChocolatey } from "../chocolatey"
import { spawnSync as spawn } from "child_process"
jest.setTimeout(200000)
describe("setup-chocolatey", () => {
@ -8,10 +8,6 @@ describe("setup-chocolatey", () => {
return
}
await setupChocolatey("", "", "")
const { status } = spawn("choco", ["--version"], {
encoding: "utf8",
})
expect(status).toBe(0)
await testBin("choco")
})
})

View File

@ -1,14 +1,11 @@
import { setupConan } from "../conan"
import { spawnSync as spawn } from "child_process"
import { testBin } from "../../utils/tests/test-helpers"
jest.setTimeout(200000)
describe("setup-conan", () => {
it("should setup conan", async () => {
await setupConan("1.40.1", "", "")
const { status } = spawn("conan", ["--version"], {
encoding: "utf8",
})
expect(status).toBe(0)
await testBin("conan")
})
})

View File

@ -1,14 +1,11 @@
import { setupCppcheck } from "../cppcheck"
import { spawnSync as spawn } from "child_process"
import { testBin } from "../../utils/tests/test-helpers"
jest.setTimeout(200000)
describe("setup-cppcheck", () => {
it("should setup cppcheck", async () => {
await setupCppcheck("", "", "")
const { status } = spawn("cppcheck", ["--version"], {
encoding: "utf8",
})
expect(status).toBe(0)
await testBin("cppcheck")
})
})

View File

@ -1,14 +1,11 @@
import { setupDoxygen } from "../doxygen"
import { spawnSync as spawn } from "child_process"
import { testBin } from "../../utils/tests/test-helpers"
jest.setTimeout(200000)
describe("setup-doxygen", () => {
it("should setup doxygen", async () => {
await setupDoxygen("", "", "")
const { status } = spawn("doxygen", ["--version"], {
encoding: "utf8",
})
expect(status).toBe(0)
await testBin("doxygen")
})
})

View File

@ -1,4 +1,4 @@
import { spawnSync as spawn } from "child_process"
import { testBin } from "../../utils/tests/test-helpers"
import { setupGcc } from "../gcc"
jest.setTimeout(200000)
@ -6,9 +6,6 @@ describe("setup-gcc", () => {
it("should setup gcc", async () => {
await setupGcc("", "", "")
const { status } = spawn("g++", ["--version"], {
encoding: "utf8",
})
expect(status).toBe(0)
await testBin("g++")
})
})

View File

@ -1,14 +1,11 @@
import { setupGcovr } from "../gcovr"
import { spawnSync as spawn } from "child_process"
import { testBin } from "../../utils/tests/test-helpers"
jest.setTimeout(200000)
describe("setup-gcovr", () => {
it("should setup gcovr", async () => {
await setupGcovr("5.0", "", "")
const { status } = spawn("gcovr", ["--version"], {
encoding: "utf8",
})
expect(status).toBe(0)
await testBin("gcovr")
})
})

View File

@ -1,11 +1,7 @@
import { setupLLVM, VERSIONS, getUrl } from "../llvm"
import { getSpecificVersionAndUrl } from "../../utils/setup/version"
import { isValidUrl } from "../../utils/http/validate_url"
import { setupTmpDir, cleanupTmpDir } from "../../utils/tests/test-helpers"
import { addBinExtension } from "../../utils/setup/setupBin"
import { join } from "path"
import { spawnSync as spawn } from "child_process"
import { which } from "@actions/io"
import { setupTmpDir, cleanupTmpDir, testBin } from "../../utils/tests/test-helpers"
jest.setTimeout(200000)
async function testUrl(version: string) {
@ -47,17 +43,7 @@ describe("setup-llvm", () => {
it("should setup LLVM", async () => {
const { binDir } = await setupLLVM("11.0.0", directory, "")
expect(binDir).toBeDefined()
expect(binDir).not.toHaveLength(0)
const clangBin = join(binDir, addBinExtension("clang"))
const { status } = spawn(clangBin, ["--version"], {
encoding: "utf8",
})
expect(status).toBe(0)
expect(await which("clang", true)).toBe(clangBin)
await testBin("clang++", ["--version"], binDir)
})
afterAll(async () => {

View File

@ -1,14 +1,10 @@
import { setupMeson } from "../meson"
import { spawnSync as spawn } from "child_process"
import { testBin } from "../../utils/tests/test-helpers"
jest.setTimeout(200000)
describe("setup-meson", () => {
it("should setup meson", async () => {
await setupMeson("0.59.1", "", "")
const { status } = spawn("meson", ["--version"], {
encoding: "utf8",
})
expect(status).toBe(0)
await testBin("meson")
})
})

View File

@ -1,5 +1,5 @@
import { testBin } from "../../utils/tests/test-helpers"
import { setupMSVC } from "../msvc"
import { spawnSync as spawn } from "child_process"
jest.setTimeout(200000)
describe("setup-msvc", () => {
@ -9,10 +9,10 @@ describe("setup-msvc", () => {
}
await setupMSVC("2019", "", "")
spawn("cl", {
encoding: "utf8",
})
try {
await testBin("cl", [])
} catch (err) {
// TODO see #1
// expect(status).toBe(0)
}
})
})

View File

@ -1,5 +1,5 @@
import { setupOpencppcoverage } from "../opencppcoverage"
import { spawnSync as spawn } from "child_process"
import { testBin } from "../../utils/tests/test-helpers"
jest.setTimeout(200000)
describe("setup-OpenCppCoverage", () => {
@ -9,9 +9,6 @@ describe("setup-OpenCppCoverage", () => {
}
await setupOpencppcoverage("", "", "")
const { status } = spawn("OpenCppCoverage", ["--version"], {
encoding: "utf8",
})
expect(status).toBe(0)
await testBin("OpenCppCoverage")
})
})