Skip to content

Commit ec1a72d

Browse files
authored
Merge pull request #620 from zeromq/test-endpoints
test: fix the ipc endpoint tests
2 parents b675b0a + 3d54dba commit ec1a72d

File tree

9 files changed

+32
-22
lines changed

9 files changed

+32
-22
lines changed

.github/workflows/CI.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ jobs:
6565
docker: node:18-alpine
6666
docker_cmd:
6767
apk add --no-cache pkgconfig curl tar python3 make gcc g++ cmake
68-
musl-dev && npm i -g pnpm && pnpm install && pnpm run build.prebuild
68+
musl-dev && npm i -g pnpm && pnpm install && pnpm run
69+
build.prebuild
6970
node_version: 18
7071
node_arch: x64
7172
ARCH: x64

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
"scripts": {
8383
"install": "(shx test -f ./script/build.js || run-s build.js) && cross-env npm_config_build_from_source=true aminya-node-gyp-build",
8484
"clean": "shx rm -rf ./build ./lib/ ./prebuilds ./script/*.js ./script/*.js.map ./script/*.d.ts ./script/*.tsbuildinfo",
85-
"clean.temp": "shx rm -rf ./tmp && shx mkdir -p ./tmp && shx touch ./tmp/.gitkeep",
85+
"clean.temp": "shx rm -rf ./tmp && shx mkdir -p ./tmp",
8686
"build.library": "tsc -p ./src/tsconfig.json",
8787
"build.script": "tsc -p ./script/tsconfig.json && tsc -p ./script/tsconfig.esm.json",
8888
"build.js": "run-p build.script build.library",
@@ -94,9 +94,9 @@
9494
"build": "run-s build.js build.native",
9595
"build.debug": "run-s build.js build.native.debug",
9696
"test.deps": "cd test && pnpm install && cd ..",
97-
"test": "run-s test.deps build && mocha --exit",
98-
"test.skip_gc_tests": "run-s test.deps build.debug && cross-env SKIP_GC_TESTS=true mocha --exit",
99-
"test.electron.main": "run-s test.deps build && electron-mocha",
97+
"test": "run-s clean.temp test.deps build && mocha",
98+
"test.skip_gc_tests": "run-s clean.temp test.deps build.debug && cross-env SKIP_GC_TESTS=true mocha",
99+
"test.electron.main": "run-s clean.temp test.deps build && electron-mocha",
100100
"format": "prettier --write .",
101101
"test.electron.renderer": "run-s build && electron-mocha --renderer",
102102
"lint.clang-format": "clang-format -i -style=file ./src/*.cc ./src/*.h ./src/util/*.h",

script/tsconfig.esm.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"extends": "./tsconfig.json",
33
"compilerOptions": {
44
"module": "ESNext",
5-
"moduleResolution": "node",
5+
"moduleResolution": "node"
66
},
77
"include": ["./**/*.mts"],
88
"exclude": []

src/util/error.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static inline Napi::Error ErrnoException(
4848

4949
static inline Napi::Error ErrnoException(
5050
const Napi::Env& env, int32_t error, const std::string& address) {
51-
auto exception = ErrnoException(env, error);
51+
auto exception = ErrnoException(env, error, nullptr);
5252
exception.Set("address", Napi::String::New(env, address));
5353
return exception;
5454
}

test/unit/helpers.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as path from "path"
22
import * as semver from "semver"
3+
import * as fs from "fs"
34

45
import {spawn} from "child_process"
56

@@ -21,13 +22,17 @@ export function uniqAddress(proto: Proto) {
2122
switch (proto) {
2223
case "ipc": {
2324
const sock = path.resolve(__dirname, `../../tmp/${proto}-${id}`)
25+
// create the directory
26+
fs.mkdirSync(path.dirname(sock), {recursive: true})
27+
2428
return `${proto}://${sock}`
2529
}
2630

2731
case "tcp":
2832
case "udp":
2933
return `${proto}://127.0.0.1:${id}`
3034

35+
case "inproc":
3136
default:
3237
return `${proto}://${proto}-${id}`
3338
}

test/unit/proxy-router-dealer-test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ import {testProtos, uniqAddress} from "./helpers"
66

77
for (const proto of testProtos("tcp", "ipc", "inproc")) {
88
describe(`proxy with ${proto} router/dealer`, function () {
9+
/* ZMQ < 4.0.5 has no steerable proxy support. */
10+
if (semver.satisfies(zmq.version, "< 4.0.5")) {
11+
return
12+
}
13+
914
let proxy: zmq.Proxy
1015

1116
let frontAddress: string
@@ -15,11 +20,6 @@ for (const proto of testProtos("tcp", "ipc", "inproc")) {
1520
let rep: zmq.Reply
1621

1722
beforeEach(async function () {
18-
/* ZMQ < 4.0.5 has no steerable proxy support. */
19-
if (semver.satisfies(zmq.version, "< 4.0.5")) {
20-
this.skip()
21-
}
22-
2323
proxy = new zmq.Proxy(new zmq.Router(), new zmq.Dealer())
2424

2525
frontAddress = uniqAddress(proto)
@@ -89,6 +89,8 @@ for (const proto of testProtos("tcp", "ipc", "inproc")) {
8989
rep.close()
9090
}
9191

92+
console.log("waiting for messages")
93+
9294
await Promise.all([echo(), send()])
9395
assert.deepEqual(received, messages)
9496

test/unit/proxy-terminate-test.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ import {isFullError} from "../../src/errors"
77

88
for (const proto of testProtos("tcp", "ipc", "inproc")) {
99
describe(`proxy with ${proto} terminate`, function () {
10+
/* ZMQ < 4.0.5 has no steerable proxy support. */
11+
if (semver.satisfies(zmq.version, "< 4.0.5")) {
12+
return
13+
}
14+
1015
let proxy: zmq.Proxy
1116

1217
beforeEach(async function () {
13-
/* ZMQ < 4.0.5 has no steerable proxy support. */
14-
if (semver.satisfies(zmq.version, "< 4.0.5")) {
15-
this.skip()
16-
}
17-
1818
proxy = new zmq.Proxy(new zmq.Router(), new zmq.Dealer())
1919
})
2020

@@ -28,12 +28,13 @@ for (const proto of testProtos("tcp", "ipc", "inproc")) {
2828
await proxy.frontEnd.bind(uniqAddress(proto))
2929
await proxy.backEnd.bind(uniqAddress(proto))
3030

31-
try {
32-
const timer = setTimeout(() => proxy.terminate(), 50)
33-
await proxy.run()
31+
const sleep_ms = 50
32+
33+
setTimeout(() => proxy.terminate(), sleep_ms)
34+
await proxy.run()
3435

36+
try {
3537
await proxy.terminate()
36-
timer.unref()
3738
assert.ok(false)
3839
} catch (err) {
3940
if (!isFullError(err)) {

test/unit/typings-compatibility-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
readFile,
99
writeFile,
1010
} from "fs-extra"
11-
import * as which from "which"
11+
import which from "which"
1212

1313
import {assert} from "chai"
1414

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"noUnusedParameters": false,
1717
"incremental": true,
1818
"sourceMap": true,
19+
"esModuleInterop": true,
1920
"lib": ["ES2020", "dom"]
2021
}
2122
}

0 commit comments

Comments
 (0)