From bf63dd58d33c175b9e8ccc7b5e5c437983c42d3e Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Thu, 16 Sep 2021 11:14:08 -0500 Subject: [PATCH] fix: return installation directory for pip packages --- src/conan/__tests__/conan.test.ts | 5 +++-- src/conan/conan.ts | 4 ++-- src/gcovr/__tests__/gcovr.test.ts | 6 +++--- src/meson/__tests__/meson.test.ts | 6 ++++-- src/meson/meson.ts | 4 ++-- src/utils/setup/setupPipPack.ts | 10 ++++++++-- 6 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/conan/__tests__/conan.test.ts b/src/conan/__tests__/conan.test.ts index 3b6c9cf4..ae190439 100644 --- a/src/conan/__tests__/conan.test.ts +++ b/src/conan/__tests__/conan.test.ts @@ -1,11 +1,12 @@ import { setupConan } from "../conan" import { testBin } from "../../utils/tests/test-helpers" +import { InstallationInfo } from "../../utils/setup/setupBin" jest.setTimeout(200000) describe("setup-conan", () => { it("should setup conan", async () => { - await setupConan("1.40.1", "", "") + const installInfo = await setupConan("", "", "") - await testBin("conan") + await testBin("conan", ["--version"], (installInfo as InstallationInfo | undefined)?.binDir) }) }) diff --git a/src/conan/conan.ts b/src/conan/conan.ts index 04510977..1b16eaf4 100644 --- a/src/conan/conan.ts +++ b/src/conan/conan.ts @@ -1,6 +1,6 @@ import { setupPipPack } from "../utils/setup/setupPipPack" // eslint-disable-next-line @typescript-eslint/no-unused-vars -export async function setupConan(version: string | undefined, _setupCppDir: string, _arch: string) { - await setupPipPack("conan", version) +export function setupConan(version: string | undefined, _setupCppDir: string, _arch: string) { + return setupPipPack("conan", version) } diff --git a/src/gcovr/__tests__/gcovr.test.ts b/src/gcovr/__tests__/gcovr.test.ts index 8df1f449..d91bae44 100644 --- a/src/gcovr/__tests__/gcovr.test.ts +++ b/src/gcovr/__tests__/gcovr.test.ts @@ -1,11 +1,11 @@ import { setupGcovr } from "../gcovr" import { testBin } from "../../utils/tests/test-helpers" +import { InstallationInfo } from "../../utils/setup/setupBin" jest.setTimeout(200000) describe("setup-gcovr", () => { it("should setup gcovr", async () => { - await setupGcovr("5.0", "", "") - - await testBin("gcovr") + const installInfo = await setupGcovr("", "", "") + await testBin("gcovr", ["--version"], (installInfo as InstallationInfo | undefined)?.binDir) }) }) diff --git a/src/meson/__tests__/meson.test.ts b/src/meson/__tests__/meson.test.ts index 35ce8d6e..6f43df50 100644 --- a/src/meson/__tests__/meson.test.ts +++ b/src/meson/__tests__/meson.test.ts @@ -1,10 +1,12 @@ import { setupMeson } from "../meson" import { testBin } from "../../utils/tests/test-helpers" +import { InstallationInfo } from "../../utils/setup/setupBin" jest.setTimeout(200000) describe("setup-meson", () => { it("should setup meson", async () => { - await setupMeson("0.59.1", "", "") - await testBin("meson") + const installInfo = await setupMeson("", "", "") + + await testBin("meson", ["--version"], (installInfo as InstallationInfo | undefined)?.binDir) }) }) diff --git a/src/meson/meson.ts b/src/meson/meson.ts index 963dab23..22856832 100644 --- a/src/meson/meson.ts +++ b/src/meson/meson.ts @@ -1,6 +1,6 @@ import { setupPipPack } from "../utils/setup/setupPipPack" // eslint-disable-next-line @typescript-eslint/no-unused-vars -export async function setupMeson(version: string | undefined, _setupCppDir: string, _arch: string) { - await setupPipPack("meson", version) +export function setupMeson(version: string | undefined, _setupCppDir: string, _arch: string) { + return setupPipPack("meson", version) } diff --git a/src/utils/setup/setupPipPack.ts b/src/utils/setup/setupPipPack.ts index 53ab8eb5..d8806410 100644 --- a/src/utils/setup/setupPipPack.ts +++ b/src/utils/setup/setupPipPack.ts @@ -26,12 +26,18 @@ export async function setupPipPack(name: string, version?: string) { throw new Error(`Failed to install ${name} ${version}`) } + let binDir: string | undefined if (process.platform === "linux") { try { - startGroup(`Add /home/runner/.local/bin to PATH`) - addPath("/home/runner/.local/bin/") + binDir = "/home/runner/.local/bin/" + startGroup(`${binDir} to PATH`) + addPath(binDir) } finally { endGroup() } + } else if (process.platform === "darwin") { + binDir = "/usr/local/bin/" } + + return binDir }