mirror of https://github.com/aminya/setup-cpp
fix: return default installation directory for apt and brew
This commit is contained in:
parent
596c9438b5
commit
8e56d264af
|
@ -1,11 +1,12 @@
|
||||||
import { setupCcache } from "../ccache"
|
import { setupCcache } from "../ccache"
|
||||||
import { testBin } from "../../utils/tests/test-helpers"
|
import { testBin } from "../../utils/tests/test-helpers"
|
||||||
|
import { InstallationInfo } from "../../utils/setup/setupBin"
|
||||||
|
|
||||||
jest.setTimeout(200000)
|
jest.setTimeout(200000)
|
||||||
describe("setup-ccache", () => {
|
describe("setup-ccache", () => {
|
||||||
it("should setup ccache", async () => {
|
it("should setup ccache", async () => {
|
||||||
await setupCcache("", "", "")
|
const installInfo = await setupCcache("", "", "")
|
||||||
|
|
||||||
await testBin("ccache")
|
await testBin("ccache", ["--version"], (installInfo as InstallationInfo | undefined)?.binDir)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
import { setupCppcheck } from "../cppcheck"
|
import { setupCppcheck } from "../cppcheck"
|
||||||
import { testBin } from "../../utils/tests/test-helpers"
|
import { testBin } from "../../utils/tests/test-helpers"
|
||||||
|
import { InstallationInfo } from "../../utils/setup/setupBin"
|
||||||
|
|
||||||
jest.setTimeout(200000)
|
jest.setTimeout(200000)
|
||||||
describe("setup-cppcheck", () => {
|
describe("setup-cppcheck", () => {
|
||||||
it("should setup cppcheck", async () => {
|
it("should setup cppcheck", async () => {
|
||||||
await setupCppcheck("", "", "")
|
const installInfo = await setupCppcheck("", "", "")
|
||||||
|
|
||||||
await testBin("cppcheck")
|
await testBin("cppcheck", ["--version"], (installInfo as InstallationInfo | undefined)?.binDir)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -9,7 +9,7 @@ export async function setupCppcheck(version: string | undefined, _setupCppDir: s
|
||||||
case "win32": {
|
case "win32": {
|
||||||
await setupChocoPack("cppcheck", version)
|
await setupChocoPack("cppcheck", version)
|
||||||
addPath("C:\\Program Files\\Cppcheck")
|
addPath("C:\\Program Files\\Cppcheck")
|
||||||
break
|
return undefined
|
||||||
}
|
}
|
||||||
case "darwin": {
|
case "darwin": {
|
||||||
return setupBrewPack("cppcheck", version)
|
return setupBrewPack("cppcheck", version)
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
import { setupDoxygen } from "../doxygen"
|
import { setupDoxygen } from "../doxygen"
|
||||||
import { testBin } from "../../utils/tests/test-helpers"
|
import { testBin } from "../../utils/tests/test-helpers"
|
||||||
|
import { InstallationInfo } from "../../utils/setup/setupBin"
|
||||||
|
|
||||||
jest.setTimeout(200000)
|
jest.setTimeout(200000)
|
||||||
describe("setup-doxygen", () => {
|
describe("setup-doxygen", () => {
|
||||||
it("should setup doxygen", async () => {
|
it("should setup doxygen", async () => {
|
||||||
await setupDoxygen("", "", "")
|
const installInfo = await setupDoxygen("", "", "")
|
||||||
|
|
||||||
await testBin("doxygen")
|
await testBin("doxygen", ["--version"], (installInfo as InstallationInfo | undefined)?.binDir)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -11,7 +11,7 @@ export async function setupDoxygen(version: string | undefined, _setupCppDir: st
|
||||||
await setupChocoPack("doxygen.install", version)
|
await setupChocoPack("doxygen.install", version)
|
||||||
addPath("C:\\Program Files\\Graphviz\\bin")
|
addPath("C:\\Program Files\\Graphviz\\bin")
|
||||||
addPath("C:\\Program Files\\doxygen\\bin")
|
addPath("C:\\Program Files\\doxygen\\bin")
|
||||||
break
|
return undefined
|
||||||
}
|
}
|
||||||
case "darwin": {
|
case "darwin": {
|
||||||
setupBrewPack("graphviz", version)
|
setupBrewPack("graphviz", version)
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
|
import { InstallationInfo } from "../../utils/setup/setupBin"
|
||||||
import { testBin } from "../../utils/tests/test-helpers"
|
import { testBin } from "../../utils/tests/test-helpers"
|
||||||
import { setupGcc } from "../gcc"
|
import { setupGcc } from "../gcc"
|
||||||
|
|
||||||
jest.setTimeout(200000)
|
jest.setTimeout(200000)
|
||||||
describe("setup-gcc", () => {
|
describe("setup-gcc", () => {
|
||||||
it("should setup gcc", async () => {
|
it("should setup gcc", async () => {
|
||||||
await setupGcc("", "", "")
|
const installInfo = await setupGcc("", "", "")
|
||||||
|
|
||||||
await testBin("g++")
|
await testBin("g++", ["--version"], (installInfo as InstallationInfo | undefined)?.binDir)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -16,7 +16,7 @@ export async function setupGcc(version: string, _setupCppDir: string, arch: stri
|
||||||
} else if (arch === "ia32") {
|
} else if (arch === "ia32") {
|
||||||
addPath("C:\\tools\\mingw32\\bin")
|
addPath("C:\\tools\\mingw32\\bin")
|
||||||
}
|
}
|
||||||
break
|
return undefined
|
||||||
}
|
}
|
||||||
case "darwin": {
|
case "darwin": {
|
||||||
return setupBrewPack("gcc", version)
|
return setupBrewPack("gcc", version)
|
||||||
|
|
|
@ -1,11 +1,16 @@
|
||||||
/* eslint-disable require-atomic-updates */
|
/* eslint-disable require-atomic-updates */
|
||||||
import { exec } from "@actions/exec"
|
import { exec } from "@actions/exec"
|
||||||
|
import { InstallationInfo } from "./setupBin"
|
||||||
import { mightSudo } from "./sudo"
|
import { mightSudo } from "./sudo"
|
||||||
|
|
||||||
let didUpdate: boolean = false
|
let didUpdate: boolean = false
|
||||||
|
|
||||||
/** A function that installs a package using apt */
|
/** A function that installs a package using apt */
|
||||||
export async function setupAptPack(name: string, version?: string, repository: boolean | string = true) {
|
export async function setupAptPack(
|
||||||
|
name: string,
|
||||||
|
version?: string,
|
||||||
|
repository: boolean | string = true
|
||||||
|
): Promise<InstallationInfo> {
|
||||||
const apt = mightSudo("apt-get")
|
const apt = mightSudo("apt-get")
|
||||||
|
|
||||||
let exit = 0
|
let exit = 0
|
||||||
|
@ -22,4 +27,6 @@ export async function setupAptPack(name: string, version?: string, repository: b
|
||||||
if (exit !== 0) {
|
if (exit !== 0) {
|
||||||
throw new Error(`Failed to install ${name} ${version}`)
|
throw new Error(`Failed to install ${name} ${version}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return { binDir: "/usr/bin/" }
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ export type PackageInfo = {
|
||||||
|
|
||||||
export type InstallationInfo = {
|
export type InstallationInfo = {
|
||||||
/** The top install dir */
|
/** The top install dir */
|
||||||
installDir: string
|
installDir?: string
|
||||||
binDir: string
|
binDir: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,11 +2,12 @@
|
||||||
import { execFileSync } from "child_process"
|
import { execFileSync } from "child_process"
|
||||||
import which from "which"
|
import which from "which"
|
||||||
import { setupBrew } from "../../brew/brew"
|
import { setupBrew } from "../../brew/brew"
|
||||||
|
import { InstallationInfo } from "./setupBin"
|
||||||
|
|
||||||
let hasBrew = false
|
let hasBrew = false
|
||||||
|
|
||||||
/** A function that installs a package using brew */
|
/** A function that installs a package using brew */
|
||||||
export function setupBrewPack(name: string, version?: string) {
|
export function setupBrewPack(name: string, version?: string): InstallationInfo {
|
||||||
if (!hasBrew || which.sync("brew", { nothrow: true }) === null) {
|
if (!hasBrew || which.sync("brew", { nothrow: true }) === null) {
|
||||||
setupBrew("", "", "")
|
setupBrew("", "", "")
|
||||||
hasBrew = true
|
hasBrew = true
|
||||||
|
@ -16,4 +17,6 @@ export function setupBrewPack(name: string, version?: string) {
|
||||||
execFileSync("brew", ["install", version !== undefined && version !== "" ? `${name}@${version}` : name], {
|
execFileSync("brew", ["install", version !== undefined && version !== "" ? `${name}@${version}` : name], {
|
||||||
stdio: "inherit",
|
stdio: "inherit",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
return { binDir: "/usr/local/bin/" }
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ export async function cleanupTmpDir(testName: string) {
|
||||||
|
|
||||||
export async function testBin(name: string, args: string[] = ["--version"], binDir: string | undefined = undefined) {
|
export async function testBin(name: string, args: string[] = ["--version"], binDir: string | undefined = undefined) {
|
||||||
let bin = name
|
let bin = name
|
||||||
if (binDir !== undefined) {
|
if (typeof binDir === "string") {
|
||||||
expect(binDir).toBeDefined()
|
expect(binDir).toBeDefined()
|
||||||
expect(binDir).not.toHaveLength(0)
|
expect(binDir).not.toHaveLength(0)
|
||||||
bin = join(binDir, addBinExtension(name))
|
bin = join(binDir, addBinExtension(name))
|
||||||
|
|
Loading…
Reference in New Issue