Skip to content

Commit 62674fb

Browse files
committed
tests: skip some msvc installation tests based on the Windows version
1 parent 7c677b6 commit 62674fb

File tree

3 files changed

+34
-51
lines changed

3 files changed

+34
-51
lines changed

.github/workflows/CI.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ jobs:
193193
- name: Tests
194194
run: |
195195
pnpm run test
196+
env:
197+
RUNNER_OS_NAME: ${{ matrix.os }}
196198

197199
- name: Setup Node 12
198200
uses: actions/setup-node@v3

src/msvc/__tests__/msvc.test.ts

Lines changed: 20 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,39 @@
11
import which from "which"
22
import { setupMSVC } from "../msvc"
3+
import { runnerWindowsVersion } from "../../utils/tests/test-helpers"
4+
import { warning } from "ci-log"
35

46
jest.setTimeout(300000)
57
describe("setup-msvc", () => {
8+
const isWindows = process.platform === "win32"
9+
610
it("should setup the pre-installed msvc", async () => {
711
try {
8-
if (process.platform !== "win32") {
12+
if (!isWindows) {
913
return
1014
}
1115
await setupMSVC("", "", process.arch)
1216
console.log(which.sync("cl"))
13-
} catch (e) {
14-
// TODO
15-
console.error(e)
16-
}
17-
})
18-
19-
it("should setup msvc 2022", async () => {
20-
try {
21-
if (process.platform !== "win32") {
22-
return
23-
}
24-
await setupMSVC("2022", "", process.arch)
25-
console.log(which.sync("cl"))
26-
} catch (e) {
27-
// TODO
28-
console.error(e)
29-
}
30-
})
31-
32-
it("should setup msvc 2019", async () => {
33-
try {
34-
if (process.platform !== "win32") {
35-
return
17+
} catch (err) {
18+
if ("toString" in (err as any)) {
19+
warning((err as any).toString())
3620
}
37-
await setupMSVC("2019", "", process.arch)
38-
console.log(which.sync("cl"))
39-
} catch (e) {
40-
// TODO
41-
console.error(e)
4221
}
4322
})
4423

45-
it("should setup msvc 2017", async () => {
46-
try {
47-
if (process.platform !== "win32") {
24+
for (const version of [2022, 2019, 2017, 2015]) {
25+
it(`should setup msvc ${version}`, async () => {
26+
if (!isWindows || (runnerWindowsVersion() !== undefined && runnerWindowsVersion()! > version)) {
4827
return
4928
}
50-
await setupMSVC("2017", "", process.arch)
51-
console.log(which.sync("cl"))
52-
} catch (e) {
53-
// TODO
54-
console.error(e)
55-
}
56-
})
57-
58-
it("should setup msvc 2015", async () => {
59-
try {
60-
if (process.platform !== "win32") {
61-
return
29+
try {
30+
await setupMSVC(`${version}`, "", process.arch)
31+
console.log(which.sync("cl"))
32+
} catch (err) {
33+
if ("toString" in (err as any)) {
34+
warning((err as any).toString())
35+
}
6236
}
63-
await setupMSVC("2015", "", process.arch)
64-
console.log(which.sync("cl"))
65-
} catch (e) {
66-
// TODO
67-
console.error(e)
68-
}
69-
})
37+
})
38+
}
7039
})

src/utils/tests/test-helpers.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,15 @@ export async function testBin(
5656
throw new Error(`Failed to test bin ${name}: ${err}`)
5757
}
5858
}
59+
60+
export function runnerWindowsVersion() {
61+
if (process.platform !== "win32") {
62+
return undefined
63+
}
64+
const maybeVersionString = process.env.RUNNER_OS_NAME?.split("-")[1]
65+
if (maybeVersionString === undefined) {
66+
return undefined
67+
}
68+
69+
return parseInt(maybeVersionString, 10)
70+
}

0 commit comments

Comments
 (0)