Skip to content

Commit da8a308

Browse files
committed
Address comments
1 parent 70e5309 commit da8a308

2 files changed

Lines changed: 50 additions & 5 deletions

File tree

test/test-message-translator-complex.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,16 @@ describe('Rclnodejs message translation: complex types', function () {
226226
// Keep republishing until the subscription is matched and the
227227
// message is received; a single publish can be lost while pub/sub
228228
// discovery is still in progress.
229-
timer = setInterval(() => publisher.publish(v), 100);
229+
const start = Date.now();
230+
timer = setInterval(() => {
231+
if (Date.now() - start > 55 * 1000) {
232+
clearInterval(timer);
233+
node.destroy();
234+
reject('Timed out waiting for message');
235+
return;
236+
}
237+
publisher.publish(v);
238+
}, 100);
230239
publisher.publish(v);
231240
rclnodejs.spin(node);
232241
});

test/test-message-translator-primitive.js

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,16 @@ describe('Rclnodejs message translation: primitive types', function () {
109109
);
110110
}
111111
});
112-
timer = setInterval(() => publisher.publish(v), 100);
112+
const start = Date.now();
113+
timer = setInterval(() => {
114+
if (Date.now() - start > 55 * 1000) {
115+
clearInterval(timer);
116+
node.destroy();
117+
reject('Timed out waiting for message');
118+
return;
119+
}
120+
publisher.publish(v);
121+
}, 100);
113122
publisher.publish(v); // Short-cut form of publishing primitive types
114123
rclnodejs.spin(node);
115124
});
@@ -138,7 +147,16 @@ describe('Rclnodejs message translation: primitive types', function () {
138147
);
139148
}
140149
});
141-
timer = setInterval(() => publisher.publish({ data: v }), 100);
150+
const start = Date.now();
151+
timer = setInterval(() => {
152+
if (Date.now() - start > 55 * 1000) {
153+
clearInterval(timer);
154+
node.destroy();
155+
reject('Timed out waiting for message');
156+
return;
157+
}
158+
publisher.publish({ data: v });
159+
}, 100);
142160
publisher.publish({ data: v }); // Ensure the original form of the message can be used
143161
rclnodejs.spin(node);
144162
});
@@ -253,7 +271,16 @@ describe('Rclnodejs message translation: primitive types array', function () {
253271
},
254272
data: testData.values,
255273
};
256-
timer = setInterval(() => publisher.publish(msg), 100);
274+
const start = Date.now();
275+
timer = setInterval(() => {
276+
if (Date.now() - start > 55 * 1000) {
277+
clearInterval(timer);
278+
node.destroy();
279+
reject('Timed out waiting for message');
280+
return;
281+
}
282+
publisher.publish(msg);
283+
}, 100);
257284
publisher.publish(msg);
258285
rclnodejs.spin(node);
259286
});
@@ -520,7 +547,16 @@ describe('Rclnodejs message translation: TypedArray large data', function () {
520547
},
521548
data: testData.values,
522549
};
523-
timer = setInterval(() => publisher.publish(msg), 100);
550+
const start = Date.now();
551+
timer = setInterval(() => {
552+
if (Date.now() - start > 55 * 1000) {
553+
clearInterval(timer);
554+
node.destroy();
555+
reject('Timed out waiting for message');
556+
return;
557+
}
558+
publisher.publish(msg);
559+
}, 100);
524560
publisher.publish(msg);
525561
rclnodejs.spin(node);
526562
});

0 commit comments

Comments
 (0)