fix: fix vcpkg bootstrap test in home with spaces

This commit is contained in:
Amin Yahyaabadi 2025-03-16 00:30:37 -07:00
parent fb55d3cdfe
commit 6ef1af9182
7 changed files with 19 additions and 14 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -7,14 +7,17 @@ import { addExeExt } from "patha"
import { pathExists } from "path-exists"
export async function setupTmpDir(testName: string) {
const tempDirectory = path.join(tmpdir(), "setup cpp temp", testName)
export async function setupTmpDir(testName: string, useSpaces: boolean = false) {
const tempName = useSpaces ? "setup cpp temp" : "setup-cpp-temp"
const tempDirectory = path.join(tmpdir(), tempName, testName)
try {
await io.rmRF(tempDirectory)
await io.mkdirP(tempDirectory)
} catch {
console.log("Failed to remove test directories")
}
// eslint-disable-next-line require-atomic-updates
process.env.SETUP_CPP_DIR = tempDirectory
return tempDirectory
}

View File

@ -6,7 +6,9 @@ jest.setTimeout(300000)
describe("setup-vcpkg", () => {
let directory: string
beforeEach(async () => {
directory = await setupTmpDir("vcpkg")
// TODO setup-vcpkg bootstrap fails on Linux arm64 with spaces in the path
const noSpaces = process.platform === "linux" && process.arch === "arm64"
directory = await setupTmpDir("vcpkg", !noSpaces)
})
it("should setup vcpkg", async () => {

View File

@ -2,7 +2,7 @@ import { dirname, join } from "path"
import { grantUserWriteAccess } from "admina"
import { info, notice } from "ci-log"
import { addEnv, addPath } from "envosman"
import { execaSync } from "execa"
import { execa } from "execa"
import { pathExists } from "path-exists"
import { addShExt, addShRelativePrefix } from "patha"
import { installAptPack } from "setup-apt"
@ -57,17 +57,17 @@ export async function setupVcpkg(version: string, setupDir: string, arch: string
}
}
// clone if not already exists
if (!(await pathExists(join(setupDir, addShExt("bootstrap-vcpkg", ".bat"))))) {
execaSync("git", ["clone", "https://github.com/microsoft/vcpkg"], { cwd: dirname(setupDir), stdio: "inherit" })
} else {
if (await pathExists(join(setupDir, addShExt("bootstrap-vcpkg", ".bat")))) {
notice(`Vcpkg folder already exists at ${setupDir}. Skipping the clone`)
} else {
// clone if not already exists
await execa("git", ["clone", "https://github.com/microsoft/vcpkg"], { cwd: dirname(setupDir), stdio: "inherit" })
}
// if version specified, checkout the version
if (version !== "" && version !== "true") {
info(`Checking out vcpkg version ${version}`)
execaSync("git", ["checkout", version], {
await execa("git", ["checkout", version], {
cwd: setupDir,
stdio: "inherit",
})
@ -79,7 +79,7 @@ export async function setupVcpkg(version: string, setupDir: string, arch: string
}
// bootstrap vcpkg
execaSync(addShExt(addShRelativePrefix("bootstrap-vcpkg"), ".bat"), {
await execa(addShExt(addShRelativePrefix("bootstrap-vcpkg"), ".bat"), {
cwd: setupDir,
shell: true,
stdio: "inherit",