Skip to content

Commit 66cf54f

Browse files
authored
Merge pull request #623 from zeromq/weak-napi
test: update weak-napi's dependencies + fix expose GC in the tests
2 parents 828ed28 + 0d7c94a commit 66cf54f

File tree

7 files changed

+34
-23
lines changed

7 files changed

+34
-23
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,7 @@ jobs:
160160
timeout_minutes: 5
161161
max_attempts: 1
162162
command: |
163-
pnpm run clean
164-
pnpm run test.skip_gc_tests
163+
pnpm run test
165164
continue-on-error: true
166165

167166
- name: Test Electron (Main)
@@ -173,7 +172,6 @@ jobs:
173172
command: |
174173
sudo apt-get install xvfb
175174
pnpm install -g electron@latest
176-
pnpm run clean
177175
xvfb-run --auto-servernum pnpm run test.electron.main
178176
continue-on-error: true
179177

@@ -184,6 +182,5 @@ jobs:
184182
timeout_minutes: 5
185183
max_attempts: 1
186184
command: |
187-
pnpm run clean
188185
pnpm run test
189186
continue-on-error: true

.mocharc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module.exports = {
44
require: ["ts-node/register", "rocha"],
55
spec: ["test/unit/*-test.ts", "test/unit/compat/*-test.{ts,js}"],
66
"expose-gc": true,
7+
"v8-expose-gc": true,
78
"experimental-worker": true,
89
recursive: true,
910
}

test/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"devDependencies": {
33
"@types/weak-napi": "^2.0.3",
4-
"weak-napi": "^2.0.2"
4+
"weak-napi": "https://github.com/aminya/weak-napi#ea97678fc4c9304eea7f3fb1ddc88eaf59cccc6f"
55
}
66
}

test/pnpm-lock.yaml

Lines changed: 11 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/unit/socket-close-test.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,14 @@ for (const proto of testProtos("tcp", "ipc", "inproc")) {
107107
})
108108

109109
it("should release reference to context", async function () {
110-
if (process.env.SKIP_GC_TESTS) {
110+
if (process.env.SKIP_GC_TESTS === "true") {
111111
this.skip()
112112
}
113+
if (global.gc === undefined) {
114+
console.warn("gc is not exposed by the runtime")
115+
this.skip()
116+
}
117+
113118
this.slow(200)
114119

115120
const weak = require("weak-napi") as typeof import("weak-napi")
@@ -124,14 +129,14 @@ for (const proto of testProtos("tcp", "ipc", "inproc")) {
124129
})
125130
context = undefined
126131

127-
global.gc?.()
132+
global.gc!()
128133
socket.connect(uniqAddress(proto))
129134
await socket.send(Buffer.from("foo"))
130135
socket.close()
131136
}
132137

133138
await task()
134-
global.gc?.()
139+
global.gc()
135140
await new Promise(resolve => {
136141
setTimeout(resolve, 5)
137142
})
@@ -141,10 +146,11 @@ for (const proto of testProtos("tcp", "ipc", "inproc")) {
141146

142147
describe("in gc finalizer", function () {
143148
it("should release reference to context", async function () {
144-
if (process.env.SKIP_GC_TESTS) {
149+
if (process.env.SKIP_GC_TESTS === "true") {
145150
this.skip()
146151
}
147-
if (process.env.SKIP_GC_FINALIZER_TESTS) {
152+
if (global.gc === undefined) {
153+
console.warn("gc is not exposed by the runtime")
148154
this.skip()
149155
}
150156
this.slow(200)
@@ -155,17 +161,17 @@ for (const proto of testProtos("tcp", "ipc", "inproc")) {
155161
const task = async () => {
156162
let context: zmq.Context | undefined = new zmq.Context()
157163

158-
new zmq.Dealer({context, linger: 0})
164+
const _dealer = new zmq.Dealer({context, linger: 0})
159165

160166
weak(context, () => {
161167
released = true
162168
})
163169
context = undefined
164-
global.gc?.()
170+
global.gc!()
165171
}
166172

167173
await task()
168-
global.gc?.()
174+
global.gc()
169175
await new Promise(resolve => {
170176
setTimeout(resolve, 5)
171177
})

test/unit/socket-zap-test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,10 @@ for (const proto of testProtos("tcp", "ipc")) {
162162
if (semver.satisfies(zmq.version, "< 4.3.0")) {
163163
this.skip()
164164
}
165+
if (zmq.capability.curve !== true) {
166+
console.warn("Curve not supported by this zmq build")
167+
this.skip()
168+
}
165169

166170
this.slow(250)
167171

typedoc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"test/**/*",
1212
"examples/**/*",
1313
"src/errors.ts",
14-
"src/util.ts"
14+
"src/util.ts",
15+
"build/**/*"
1516
],
1617
"cleanOutputDir": true,
1718
"pretty": false,

0 commit comments

Comments
 (0)