Skip to content

Commit 6c5db51

Browse files
committed
test: add tests for cross-compilation
1 parent d18636e commit 6c5db51

File tree

2 files changed

+36
-7
lines changed

2 files changed

+36
-7
lines changed

src/download.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ async function download(url: string, opts: DownloadOptions) {
5050
downloader.on("error", (err) => {
5151
reject(err)
5252
})
53-
53+
5454
downloader.on("end", () => {
5555
resolve()
5656
})

test/zeromq.test.ts

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,34 @@ suite("zeromq", { timeout: 300_000 }, async () => {
4848
test("cmake-ts legacy nativeonly --logger debug", async () => {
4949
await testZeromqBuild("legacy", zeromqPath, "nativeonly", "--logger", "debug")
5050
})
51+
52+
test("cmake-ts cross-compile cross-linux-arm64", async (t) => {
53+
if (process.platform !== "linux" || process.arch !== "x64") {
54+
t.skip()
55+
}
56+
await testZeromqBuild("modern", zeromqPath, "build", "--configs", "cross-linux-arm64", "--logger", "debug")
57+
})
58+
59+
test("cmake-ts cross-compile cross-win32-ia32", async (t) => {
60+
if (process.platform !== "win32" || process.arch !== "x64") {
61+
t.skip()
62+
}
63+
await testZeromqBuild("modern", zeromqPath, "build", "--configs", "cross-win32-ia32", "--logger", "debug")
64+
})
65+
66+
test("cmake-ts cross-compile cross-darwin-x64", async (t) => {
67+
if (process.platform !== "darwin" || process.arch !== "arm64") {
68+
t.skip()
69+
}
70+
await testZeromqBuild("modern", zeromqPath, "build", "--configs", "cross-darwin-x64", "--logger", "debug")
71+
})
72+
73+
test("cmake-ts cross-compile cross-darwin-arm64", async (t) => {
74+
if (process.platform !== "darwin" || process.arch !== "x64") {
75+
t.skip()
76+
}
77+
await testZeromqBuild("modern", zeromqPath, "build", "--configs", "cross-darwin-arm64", "--logger", "debug")
78+
})
5179
})
5280

5381
async function testZeromqBuild(bundle: string, zeromqPath: string, ...args: string[]) {
@@ -69,12 +97,13 @@ async function testZeromqBuild(bundle: string, zeromqPath: string, ...args: stri
6997
const expectedConfig: BuildConfiguration = {
7098
name: "",
7199
dev: false,
72-
os: process.platform,
73-
arch: process.arch,
100+
os: args.some((arg) => arg.includes("linux")) ? "linux" : process.platform,
101+
arch: args.some((arg) => arg.includes("x64")) ? "x64" : process.arch,
74102
runtime: "node",
75103
runtimeVersion: process.versions.node,
76-
buildType: args.includes("Debug") ? "Debug" : "Release",
104+
buildType: args.includes("Debug") || args.some((arg) => arg.includes("-debug")) ? "Debug" : "Release",
77105
packageDirectory: "",
106+
cross: args.some((arg) => arg.includes("cross")),
78107
projectName: "addon",
79108
nodeAPI: "node-addon-api",
80109
targetDirectory: "build",
@@ -91,10 +120,10 @@ async function testZeromqBuild(bundle: string, zeromqPath: string, ...args: stri
91120

92121
expect(configKey.abi).toBeDefined()
93122
const addonPath = join(
94-
process.platform,
95-
process.arch,
123+
expectedConfig.os,
124+
expectedConfig.arch,
96125
"node",
97-
`${configKey.libc}-${configKey.abi}-${configKey.buildType}`,
126+
`${expectedConfig.libc}-${expectedConfig.abi}-${expectedConfig.buildType}`,
98127
"addon.node",
99128
)
100129

0 commit comments

Comments
 (0)