From 7fa3e4e2468867ab57e7b2fe2abce4c22dedb6b4 Mon Sep 17 00:00:00 2001 From: Yoshiki Kurihara Date: Fri, 24 Dec 2021 11:35:19 +0900 Subject: [PATCH 1/4] test: remove duplicate test about deprecation warning --- ...test-net-deprecated-setsimultaneousaccepts.js | 16 ---------------- ...-simultaneous-accepts-produce-warning-once.js | 5 ++++- 2 files changed, 4 insertions(+), 17 deletions(-) delete mode 100644 test/parallel/test-net-deprecated-setsimultaneousaccepts.js diff --git a/test/parallel/test-net-deprecated-setsimultaneousaccepts.js b/test/parallel/test-net-deprecated-setsimultaneousaccepts.js deleted file mode 100644 index 3778a9650fcc8d..00000000000000 --- a/test/parallel/test-net-deprecated-setsimultaneousaccepts.js +++ /dev/null @@ -1,16 +0,0 @@ -// Flags: --no-warnings -'use strict'; - -const { - expectWarning -} = require('../common'); -const { - _setSimultaneousAccepts -} = require('net'); - -expectWarning( - 'DeprecationWarning', - 'net._setSimultaneousAccepts() is deprecated and will be removed.', - 'DEP0121'); - -_setSimultaneousAccepts(); diff --git a/test/parallel/test-net-server-simultaneous-accepts-produce-warning-once.js b/test/parallel/test-net-server-simultaneous-accepts-produce-warning-once.js index ffca38f603b2a9..bef25d0cdef271 100644 --- a/test/parallel/test-net-server-simultaneous-accepts-produce-warning-once.js +++ b/test/parallel/test-net-server-simultaneous-accepts-produce-warning-once.js @@ -1,6 +1,6 @@ 'use strict'; -const { expectWarning } = require('../common'); +const { expectWarning, mustCall, mustNotCall } = require('../common'); const net = require('net'); expectWarning( @@ -8,5 +8,8 @@ expectWarning( 'net._setSimultaneousAccepts() is deprecated and will be removed.', 'DEP0121'); +process.on('warning', mustCall(() => { + process.on('warning', mustNotCall()); +})); net._setSimultaneousAccepts(); net._setSimultaneousAccepts(); From c23d0e622a2e265e405d877497ef0c79b2eb6cca Mon Sep 17 00:00:00 2001 From: kuriyosh Date: Sun, 26 Dec 2021 18:51:29 +0900 Subject: [PATCH 2/4] test: revert two test and add comments for each --- ...t-net-deprecated-setsimultaneousaccepts.js | 19 +++++++++++++++++++ ...multaneous-accepts-produce-warning-once.js | 15 ++++++++------- 2 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 test/parallel/test-net-deprecated-setsimultaneousaccepts.js diff --git a/test/parallel/test-net-deprecated-setsimultaneousaccepts.js b/test/parallel/test-net-deprecated-setsimultaneousaccepts.js new file mode 100644 index 00000000000000..4735e13847f8b6 --- /dev/null +++ b/test/parallel/test-net-deprecated-setsimultaneousaccepts.js @@ -0,0 +1,19 @@ +// Flags: --no-warnings +'use strict'; + +// This test checks that `_setSimultaneousAccepts` emit DEP0121 warning. +// Ref test-net-server-simultaneous-accepts-produce-warning-once.js + +const { + expectWarning +} = require('../common'); +const { + _setSimultaneousAccepts +} = require('net'); + +expectWarning( + 'DeprecationWarning', + 'net._setSimultaneousAccepts() is deprecated and will be removed.', + 'DEP0121'); + +_setSimultaneousAccepts(); diff --git a/test/parallel/test-net-server-simultaneous-accepts-produce-warning-once.js b/test/parallel/test-net-server-simultaneous-accepts-produce-warning-once.js index bef25d0cdef271..5f32867235e8dc 100644 --- a/test/parallel/test-net-server-simultaneous-accepts-produce-warning-once.js +++ b/test/parallel/test-net-server-simultaneous-accepts-produce-warning-once.js @@ -1,15 +1,16 @@ 'use strict'; -const { expectWarning, mustCall, mustNotCall } = require('../common'); -const net = require('net'); +// This test checks that `_setSimultaneousAccepts` does not emit DEP0121 warning +// in second calling, by combination with +// `test-net-deprecated-setsimultaneousaccepts.js`. + +const { expectWarning } = require('../common'); +const { _setSimultaneousAccepts } = require('net'); expectWarning( 'DeprecationWarning', 'net._setSimultaneousAccepts() is deprecated and will be removed.', 'DEP0121'); -process.on('warning', mustCall(() => { - process.on('warning', mustNotCall()); -})); -net._setSimultaneousAccepts(); -net._setSimultaneousAccepts(); +_setSimultaneousAccepts(); +_setSimultaneousAccepts(); \ No newline at end of file From 20457393045634a3b5164e4e49556afb0ec11e2d Mon Sep 17 00:00:00 2001 From: kuriyosh Date: Sun, 26 Dec 2021 19:18:42 +0900 Subject: [PATCH 3/4] test: fix lint error --- ...test-net-server-simultaneous-accepts-produce-warning-once.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-net-server-simultaneous-accepts-produce-warning-once.js b/test/parallel/test-net-server-simultaneous-accepts-produce-warning-once.js index 5f32867235e8dc..7692a0b62ab9ac 100644 --- a/test/parallel/test-net-server-simultaneous-accepts-produce-warning-once.js +++ b/test/parallel/test-net-server-simultaneous-accepts-produce-warning-once.js @@ -13,4 +13,4 @@ expectWarning( 'DEP0121'); _setSimultaneousAccepts(); -_setSimultaneousAccepts(); \ No newline at end of file +_setSimultaneousAccepts(); From 6ef49ff546de6fafeffb46e9e57f9fae02fff0c9 Mon Sep 17 00:00:00 2001 From: kuriyosh Date: Mon, 27 Dec 2021 09:43:52 +0900 Subject: [PATCH 4/4] test: update comment for test description --- .../test-net-deprecated-setsimultaneousaccepts.js | 3 +-- ...t-server-simultaneous-accepts-produce-warning-once.js | 9 ++++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-net-deprecated-setsimultaneousaccepts.js b/test/parallel/test-net-deprecated-setsimultaneousaccepts.js index 4735e13847f8b6..dd6decdcce513f 100644 --- a/test/parallel/test-net-deprecated-setsimultaneousaccepts.js +++ b/test/parallel/test-net-deprecated-setsimultaneousaccepts.js @@ -1,8 +1,7 @@ // Flags: --no-warnings 'use strict'; -// This test checks that `_setSimultaneousAccepts` emit DEP0121 warning. -// Ref test-net-server-simultaneous-accepts-produce-warning-once.js +// Test that DEP0121 is emitted on the first call of _setSimultaneousAccepts(). const { expectWarning diff --git a/test/parallel/test-net-server-simultaneous-accepts-produce-warning-once.js b/test/parallel/test-net-server-simultaneous-accepts-produce-warning-once.js index 7692a0b62ab9ac..391c2ecea76841 100644 --- a/test/parallel/test-net-server-simultaneous-accepts-produce-warning-once.js +++ b/test/parallel/test-net-server-simultaneous-accepts-produce-warning-once.js @@ -1,8 +1,11 @@ 'use strict'; -// This test checks that `_setSimultaneousAccepts` does not emit DEP0121 warning -// in second calling, by combination with -// `test-net-deprecated-setsimultaneousaccepts.js`. +// Test that DEP0121 is emitted only once if _setSimultaneousAccepts() is called +// more than once. This test is similar to +// test-net-deprecated-setsimultaneousaccepts.js, but that test calls +// _setSimultaneousAccepts() only once. Unlike this test, that will confirm +// that the warning is emitted on the first call. This test doesn't check which +// call caused the warning to be emitted. const { expectWarning } = require('../common'); const { _setSimultaneousAccepts } = require('net');