1+ import * as semver from "semver"
12import * as zmq from "../../src"
23
34import { assert } from "chai"
@@ -7,7 +8,7 @@ describe("context process exit", function() {
78 describe ( "with default context" , function ( ) {
89 it ( "should occur when sockets are closed" , async function ( ) {
910 this . slow ( 200 )
10- const code = await createProcess ( ( ) => {
11+ const { code} = await createProcess ( ( ) => {
1112 const socket1 = new zmq . Dealer ( )
1213 socket1 . close ( )
1314 const socket2 = new zmq . Router ( )
@@ -19,7 +20,7 @@ describe("context process exit", function() {
1920
2021 it ( "should occur when sockets are not closed" , async function ( ) {
2122 this . slow ( 200 )
22- const code = await createProcess ( ( ) => {
23+ const { code} = await createProcess ( ( ) => {
2324 const socket1 = new zmq . Dealer ( )
2425 const socket2 = new zmq . Router ( )
2526 } )
@@ -29,20 +30,69 @@ describe("context process exit", function() {
2930
3031 it ( "should not occur when sockets are open and polling" , async function ( ) {
3132 this . slow ( 1000 )
32- const code = await createProcess ( ( ) => {
33+ const { code} = await createProcess ( ( ) => {
3334 const socket1 = new zmq . Dealer ( )
3435 socket1 . connect ( "inproc://foo" )
3536 socket1 . receive ( )
3637 } )
3738
3839 assert . equal ( code , - 1 )
3940 } )
41+
42+ it ( "should produce warning when messages are queued with blocky" , async function ( ) {
43+ this . slow ( 1000 )
44+ const { stderr} = await createProcess ( ( ) => {
45+ zmq . context . blocky = true
46+ const socket1 = new zmq . Dealer ( { linger : 600 } )
47+ socket1 . connect ( "tcp://127.0.0.1:6789" )
48+ socket1 . send ( null )
49+ } )
50+
51+ if ( semver . satisfies ( zmq . version , ">= 4.2" ) ) {
52+ assert . match (
53+ stderr . toString ( ) ,
54+ / \( n o d e : \d + \) W A R N I N G : W a i t i n g f o r q u e u e d Z e r o M Q m e s s a g e s t o b e d e l i v e r e d \. S e t ' c o n t e x t \. b l o c k y = f a l s e ' t o c h a n g e t h i s b e h a v i o u r \. \n / ,
55+ )
56+ } else {
57+ assert . match (
58+ stderr . toString ( ) ,
59+ / \( n o d e : \d + \) W A R N I N G : W a i t i n g f o r q u e u e d Z e r o M Q m e s s a g e s t o b e d e l i v e r e d \. \n / ,
60+ )
61+ }
62+ } )
63+
64+ it ( "should produce warning when messages are queued without blocky" , async function ( ) {
65+ this . slow ( 1000 )
66+ const { stderr} = await createProcess ( ( ) => {
67+ zmq . context . blocky = false
68+ const socket1 = new zmq . Dealer ( { linger : 600 } )
69+ socket1 . connect ( "tcp://127.0.0.1:6789" )
70+ socket1 . send ( null )
71+ } )
72+
73+ assert . match (
74+ stderr . toString ( ) ,
75+ / \( n o d e : \d + \) W A R N I N G : W a i t i n g f o r q u e u e d Z e r o M Q m e s s a g e s t o b e d e l i v e r e d \. \n / ,
76+ )
77+ } )
78+
79+ it ( "should not produce warning when messages are queued for a short time" , async function ( ) {
80+ this . slow ( 1000 )
81+ const { stderr} = await createProcess ( ( ) => {
82+ zmq . context . blocky = true
83+ const socket1 = new zmq . Dealer ( { linger : 100 } )
84+ socket1 . connect ( "tcp://127.0.0.1:6789" )
85+ socket1 . send ( null )
86+ } )
87+
88+ assert . equal ( stderr . toString ( ) , "" )
89+ } )
4090 } )
4191
4292 describe ( "with custom context" , function ( ) {
4393 it ( "should occur when sockets are closed" , async function ( ) {
4494 this . slow ( 200 )
45- const code = await createProcess ( ( ) => {
95+ const { code} = await createProcess ( ( ) => {
4696 const context = new zmq . Context ( )
4797 const socket1 = new zmq . Dealer ( { context} )
4898 socket1 . close ( )
@@ -55,7 +105,7 @@ describe("context process exit", function() {
55105
56106 it ( "should occur when sockets are closed and context is gced" , async function ( ) {
57107 this . slow ( 200 )
58- const code = await createProcess ( ( ) => {
108+ const { code} = await createProcess ( ( ) => {
59109 function run ( ) {
60110 const context = new zmq . Context ( )
61111 const socket1 = new zmq . Dealer ( { context} )
@@ -73,7 +123,7 @@ describe("context process exit", function() {
73123
74124 it ( "should occur when sockets are not closed" , async function ( ) {
75125 this . slow ( 200 )
76- const code = await createProcess ( ( ) => {
126+ const { code} = await createProcess ( ( ) => {
77127 const context = new zmq . Context ( )
78128 const socket1 = new zmq . Dealer ( { context} )
79129 const socket2 = new zmq . Router ( { context} )
@@ -84,7 +134,7 @@ describe("context process exit", function() {
84134
85135 it ( "should not occur when sockets are open and polling" , async function ( ) {
86136 this . slow ( 1000 )
87- const code = await createProcess ( ( ) => {
137+ const { code} = await createProcess ( ( ) => {
88138 const context = new zmq . Context ( )
89139 const socket1 = new zmq . Dealer ( { context} )
90140 socket1 . connect ( "inproc://foo" )
0 commit comments