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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,11 +1,7 @@
import { setupLLVM, VERSIONS, getUrl } from "../llvm" import { setupLLVM, VERSIONS, getUrl } from "../llvm"
import { getSpecificVersionAndUrl } from "../../utils/setup/version" import { getSpecificVersionAndUrl } from "../../utils/setup/version"
import { isValidUrl } from "../../utils/http/validate_url" import { isValidUrl } from "../../utils/http/validate_url"
import { setupTmpDir, cleanupTmpDir } from "../../utils/tests/test-helpers" import { setupTmpDir, cleanupTmpDir, testBin } 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"
jest.setTimeout(200000) jest.setTimeout(200000)
async function testUrl(version: string) { async function testUrl(version: string) {
@ -47,17 +43,7 @@ describe("setup-llvm", () => {
it("should setup LLVM", async () => { it("should setup LLVM", async () => {
const { binDir } = await setupLLVM("11.0.0", directory, "") const { binDir } = await setupLLVM("11.0.0", directory, "")
expect(binDir).toBeDefined() await testBin("clang++", ["--version"], binDir)
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)
}) })
afterAll(async () => { afterAll(async () => {

View File

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

View File

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

View File

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