test: pass the install directory for powershell

This commit is contained in:
Amin Yahyaabadi 2024-08-21 15:29:27 -07:00
parent 20c025d4d7
commit c2afe421b0
No known key found for this signature in database
GPG Key ID: F52AF77F636088F0
9 changed files with 20 additions and 10 deletions

View File

@ -84,7 +84,7 @@ jobs:
- windows-2022 - windows-2022
- ubuntu-24.04 - ubuntu-24.04
- macos-13 - macos-13
- macos-12 # - macos-12
node: node:
- 22 - 22
pnpm: pnpm:

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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,18 +1,28 @@
import { GITHUB_ACTIONS } from "ci-info" import { GITHUB_ACTIONS } from "ci-info"
import { testBin } from "../../utils/tests/test-helpers.js" import { cleanupTmpDir, setupTmpDir, testBin } from "../../utils/tests/test-helpers.js"
import { getVersion } from "../../versions/versions.js" import { getVersion } from "../../versions/versions.js"
import { setupPowershell } from "../powershell.js" import { setupPowershell } from "../powershell.js"
jest.setTimeout(300000) jest.setTimeout(300000)
describe("setup-powershell", () => { describe("setup-powershell", () => {
let directory: string
beforeEach(async () => {
directory = await setupTmpDir("powershell")
process.env.CACHE_TOOLS = "true"
})
it("should setup powershell", async () => { it("should setup powershell", async () => {
if (process.platform === "win32" && GITHUB_ACTIONS) { if (process.platform === "win32" && GITHUB_ACTIONS) {
// results in errors // results in errors
return return
} }
const installInfo = await setupPowershell(getVersion("powershell", undefined), "", process.arch) const installInfo = await setupPowershell(getVersion("powershell", undefined), directory, process.arch)
await testBin("pwsh", ["--version"], installInfo.binDir) await testBin("pwsh", ["--version"], installInfo.binDir)
}) })
afterEach(async () => {
await cleanupTmpDir("ninja")
}, 100000)
}) })

View File

@ -137,7 +137,7 @@ async function tryDownload(name: string, version: string, url: string) {
info(`Download ${name} ${version}`) info(`Download ${name} ${version}`)
// try to download the package 4 times with 2 seconds delay // try to download the package 4 times with 2 seconds delay
const downloaded = await retry( const downloaded = await retry(
async () => { () => {
const downloadedFilePath = join(process.env.RUNNER_TEMP ?? tmpdir(), `${Date.now()}-${basename(url)}`) const downloadedFilePath = join(process.env.RUNNER_TEMP ?? tmpdir(), `${Date.now()}-${basename(url)}`)
return downloadTool(url, downloadedFilePath) return downloadTool(url, downloadedFilePath)