|
1 | 1 | import which from "which"
|
2 | 2 | import { setupMSVC } from "../msvc"
|
| 3 | +import { runnerWindowsVersion } from "../../utils/tests/test-helpers" |
| 4 | +import { warning } from "ci-log" |
3 | 5 |
|
4 | 6 | jest.setTimeout(300000)
|
5 | 7 | describe("setup-msvc", () => {
|
| 8 | + const isWindows = process.platform === "win32" |
| 9 | + |
6 | 10 | it("should setup the pre-installed msvc", async () => {
|
7 | 11 | try {
|
8 |
| - if (process.platform !== "win32") { |
| 12 | + if (!isWindows) { |
9 | 13 | return
|
10 | 14 | }
|
11 | 15 | await setupMSVC("", "", process.arch)
|
12 | 16 | 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()) |
36 | 20 | }
|
37 |
| - await setupMSVC("2019", "", process.arch) |
38 |
| - console.log(which.sync("cl")) |
39 |
| - } catch (e) { |
40 |
| - // TODO |
41 |
| - console.error(e) |
42 | 21 | }
|
43 | 22 | })
|
44 | 23 |
|
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)) { |
48 | 27 | return
|
49 | 28 | }
|
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 | + } |
62 | 36 | }
|
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 | + } |
70 | 39 | })
|
0 commit comments