mirror of https://github.com/aminya/setup-cpp
fix: fix the kcov download link
This commit is contained in:
parent
15070ee637
commit
43d199d290
|
@ -2,14 +2,27 @@ import { setupKcov } from "../kcov"
|
||||||
import { setupTmpDir, cleanupTmpDir, testBin } from "../../utils/tests/test-helpers"
|
import { setupTmpDir, cleanupTmpDir, testBin } from "../../utils/tests/test-helpers"
|
||||||
import { InstallationInfo } from "../../utils/setup/setupBin"
|
import { InstallationInfo } from "../../utils/setup/setupBin"
|
||||||
import which from "which"
|
import which from "which"
|
||||||
|
import { info } from "@actions/core"
|
||||||
|
|
||||||
jest.setTimeout(300000)
|
jest.setTimeout(300000)
|
||||||
describe("setup-Kcov", () => {
|
describe("setup-Kcov", () => {
|
||||||
if (process.platform !== "linux") {
|
if (process.platform === "win32") {
|
||||||
it.todo("should setup kcov on non-linux")
|
it.todo("should setup kcov on windows")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
it("should setup Kcov v40", async () => {
|
||||||
|
const directory = await setupTmpDir("kcov-v40")
|
||||||
|
const { binDir } = (await setupKcov("40-binary", directory, "")) as InstallationInfo
|
||||||
|
// the prebuild binary only works on ubuntu 20.04
|
||||||
|
try {
|
||||||
|
await testBin("kcov", ["--version"], binDir)
|
||||||
|
} catch (err) {
|
||||||
|
info((err as Error).message)
|
||||||
|
}
|
||||||
|
await cleanupTmpDir("kcov-v40")
|
||||||
|
})
|
||||||
|
|
||||||
it("should setup Kcov v40", async () => {
|
it("should setup Kcov v40", async () => {
|
||||||
const directory = await setupTmpDir("kcov-v40")
|
const directory = await setupTmpDir("kcov-v40")
|
||||||
const { binDir } = (await setupKcov("40", directory, "")) as InstallationInfo
|
const { binDir } = (await setupKcov("40", directory, "")) as InstallationInfo
|
||||||
|
|
|
@ -14,7 +14,8 @@ import { isArch } from "../utils/env/isArch"
|
||||||
import { hasDnf } from "../utils/env/hasDnf"
|
import { hasDnf } from "../utils/env/hasDnf"
|
||||||
import { setupDnfPack } from "../utils/setup/setupDnfPack"
|
import { setupDnfPack } from "../utils/setup/setupDnfPack"
|
||||||
import { isUbuntu } from "../utils/env/isUbuntu"
|
import { isUbuntu } from "../utils/env/isUbuntu"
|
||||||
import { removeVPrefix } from "../utils/setup/version"
|
import { addVPrefix, removeVPrefix } from "../utils/setup/version"
|
||||||
|
import { info } from "../utils/io/io"
|
||||||
|
|
||||||
function getDownloadKcovPackageInfo(version_number: string): PackageInfo {
|
function getDownloadKcovPackageInfo(version_number: string): PackageInfo {
|
||||||
return {
|
return {
|
||||||
|
@ -62,11 +63,14 @@ async function buildKcov(file: string, dest: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function setupKcov(versionGiven: string, setupDir: string, arch: string) {
|
export async function setupKcov(versionGiven: string, setupDir: string, arch: string) {
|
||||||
switch (process.platform) {
|
if (process.platform === "win32") {
|
||||||
case "linux": {
|
info("Kcov is not supported on Windows")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// parse version
|
// parse version
|
||||||
const versionSplit = versionGiven.split("-")
|
const versionSplit = versionGiven.split("-")
|
||||||
let version = versionSplit[0]
|
let version = addVPrefix(versionSplit[0])
|
||||||
const installMethod = versionSplit[1] as "binary" | undefined
|
const installMethod = versionSplit[1] as "binary" | undefined
|
||||||
const version_number = removeVPrefix(version)
|
const version_number = removeVPrefix(version)
|
||||||
// fix inconsistency in tagging
|
// fix inconsistency in tagging
|
||||||
|
@ -89,9 +93,4 @@ export async function setupKcov(versionGiven: string, setupDir: string, arch: st
|
||||||
installationInfo = await setupBin("kcov", version, getBuildKcovPackageInfo, setupDir, arch)
|
installationInfo = await setupBin("kcov", version, getBuildKcovPackageInfo, setupDir, arch)
|
||||||
}
|
}
|
||||||
return installationInfo
|
return installationInfo
|
||||||
}
|
|
||||||
default: {
|
|
||||||
throw new Error(`Unsupported platform for ${arch}`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,3 +119,10 @@ export function semverCoerceIfInvalid(version: string) {
|
||||||
export function removeVPrefix(version: string) {
|
export function removeVPrefix(version: string) {
|
||||||
return parseInt(version.replace(/^v/, ""), 10)
|
return parseInt(version.replace(/^v/, ""), 10)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function addVPrefix(version: string) {
|
||||||
|
if (!version.match(/^v/)) {
|
||||||
|
return `v${version}`
|
||||||
|
}
|
||||||
|
return version
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue