Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: skip some msvc installation tests based on the Windows version #192

Merged
merged 1 commit into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ jobs:
- name: Tests
run: |
pnpm run test
env:
RUNNER_OS_NAME: ${{ matrix.os }}

- name: Setup Node 12
uses: actions/setup-node@v3
Expand Down
71 changes: 20 additions & 51 deletions src/msvc/__tests__/msvc.test.ts
Original file line number Diff line number Diff line change
@@ -1,70 +1,39 @@
import which from "which"
import { setupMSVC } from "../msvc"
import { runnerWindowsVersion } from "../../utils/tests/test-helpers"
import { warning } from "ci-log"

jest.setTimeout(300000)
describe("setup-msvc", () => {
const isWindows = process.platform === "win32"

it("should setup the pre-installed msvc", async () => {
try {
if (process.platform !== "win32") {
if (!isWindows) {
return
}
await setupMSVC("", "", process.arch)
console.log(which.sync("cl"))
} catch (e) {
// TODO
console.error(e)
}
})

it("should setup msvc 2022", async () => {
try {
if (process.platform !== "win32") {
return
}
await setupMSVC("2022", "", process.arch)
console.log(which.sync("cl"))
} catch (e) {
// TODO
console.error(e)
}
})

it("should setup msvc 2019", async () => {
try {
if (process.platform !== "win32") {
return
} catch (err) {
if ("toString" in (err as any)) {
warning((err as any).toString())
}
await setupMSVC("2019", "", process.arch)
console.log(which.sync("cl"))
} catch (e) {
// TODO
console.error(e)
}
})

it("should setup msvc 2017", async () => {
try {
if (process.platform !== "win32") {
for (const version of [2022, 2019, 2017, 2015]) {
it(`should setup msvc ${version}`, async () => {
if (!isWindows || (runnerWindowsVersion() !== undefined && runnerWindowsVersion()! > version)) {
return
}
await setupMSVC("2017", "", process.arch)
console.log(which.sync("cl"))
} catch (e) {
// TODO
console.error(e)
}
})

it("should setup msvc 2015", async () => {
try {
if (process.platform !== "win32") {
return
try {
await setupMSVC(`${version}`, "", process.arch)
console.log(which.sync("cl"))
} catch (err) {
if ("toString" in (err as any)) {
warning((err as any).toString())
}
}
await setupMSVC("2015", "", process.arch)
console.log(which.sync("cl"))
} catch (e) {
// TODO
console.error(e)
}
})
})
}
})
12 changes: 12 additions & 0 deletions src/utils/tests/test-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,15 @@ export async function testBin(
throw new Error(`Failed to test bin ${name}: ${err}`)
}
}

export function runnerWindowsVersion() {
if (process.platform !== "win32") {
return undefined
}
const maybeVersionString = process.env.RUNNER_OS_NAME?.split("-")[1]
if (maybeVersionString === undefined) {
return undefined
}

return parseInt(maybeVersionString, 10)
}
Loading