test: do not print version of apt-fast

This commit is contained in:
Amin Yahyaabadi 2025-05-20 12:56:59 -07:00
parent 988b5fd210
commit 3fd1b0b32c
2 changed files with 17 additions and 22 deletions

View File

@ -9,6 +9,6 @@ describe("setup-apt-fast", () => {
}
it("should setup apt-fast", async () => {
const installInfo = await setupAptFast()
await testBin("apt-fast", ["--version"], installInfo?.binDir)
await testBin("apt-fast", null, installInfo?.binDir)
})
})

View File

@ -1,7 +1,6 @@
import spawn from "cross-spawn"
import { pathExists } from "path-exists"
import { join } from "path/posix"
import { addExeExt } from "patha"
import { addExeExt, join } from "patha"
import which from "which"
export async function testBin(
@ -9,24 +8,20 @@ export async function testBin(
args: string[] | null = ["--version"],
binDir: string | undefined = undefined,
) {
try {
let bin = name
if (typeof binDir === "string") {
console.log(`Testing the existence of ${binDir}`)
expect(binDir).toBeDefined()
expect(binDir).not.toHaveLength(0)
expect(await pathExists(binDir)).toBeTruthy()
bin = join(binDir, addExeExt(name))
}
if (args !== null) {
console.log(`Running ${bin} ${args.join(" ")}`)
const { status } = spawn.sync(bin, args, { stdio: "inherit" })
expect(status).toBe(0)
}
expect((await which(name, { nothrow: true }))?.includes(bin))
} catch (err) {
throw new Error(`Failed to test bin ${name}: ${err}`)
let bin = name
if (typeof binDir === "string") {
console.log(`Testing the existence of ${binDir}`)
expect(binDir).toBeDefined()
expect(binDir).not.toHaveLength(0)
expect(await pathExists(binDir)).toBeTruthy()
bin = join(binDir, addExeExt(name))
}
if (args !== null) {
console.log(`Running ${bin} ${args.join(" ")}`)
const { status } = spawn.sync(bin, args, { stdio: "inherit" })
expect(status).toBe(0)
}
expect((await which(name, { nothrow: true }))?.includes(bin))
}