@@ -4,17 +4,11 @@ const common = require('../common');
44const assert = require ( 'assert' ) ;
55const { spawn } = require ( 'child_process' ) ;
66const path = require ( 'path' ) ;
7+ const { suite, test } = require ( 'node:test' ) ;
78const testName = path . join ( __dirname , 'test-http-max-http-headers.js' ) ;
8-
99const timeout = common . platformTimeout ( 100 ) ;
1010
11- const tests = [ ] ;
12-
13- function test ( fn ) {
14- tests . push ( fn ) ;
15- }
16-
17- test ( function ( cb ) {
11+ test ( { timeout } , function ( _ , cb ) {
1812 console . log ( 'running subtest expecting failure' ) ;
1913
2014 // Validate that the test fails if the max header size is too small.
@@ -30,7 +24,7 @@ test(function(cb) {
3024 } ) ) ;
3125} ) ;
3226
33- test ( function ( cb ) {
27+ test ( { timeout } , function ( _ , cb ) {
3428 console . log ( 'running subtest expecting success' ) ;
3529
3630 const env = Object . assign ( { } , process . env , {
@@ -54,13 +48,13 @@ test(function(cb) {
5448 } ) ) ;
5549} ) ;
5650
57- // Next, repeat the same checks using NODE_OPTIONS if it is supported.
58- if ( ! process . config . variables . node_without_node_options ) {
51+ const skip = process . config . variables . node_without_node_options ;
52+ suite ( 'same checks using NODE_OPTIONS if it is supported' , { skip } , ( ) => {
5953 const env = Object . assign ( { } , process . env , {
6054 NODE_OPTIONS : '--max-http-header-size=1024'
6155 } ) ;
6256
63- test ( function ( cb ) {
57+ test ( { timeout } , function ( _ , cb ) {
6458 console . log ( 'running subtest expecting failure' ) ;
6559
6660 // Validate that the test fails if the max header size is too small.
@@ -74,7 +68,7 @@ if (!process.config.variables.node_without_node_options) {
7468 } ) ) ;
7569 } ) ;
7670
77- test ( function ( cb ) {
71+ test ( { timeout } , function ( _ , cb ) {
7872 // Validate that the test now passes if the same limit is large enough.
7973 const args = [ '--expose-internals' , testName , '1024' ] ;
8074 const cp = spawn ( process . execPath , args , { env, stdio : 'inherit' } ) ;
@@ -85,18 +79,4 @@ if (!process.config.variables.node_without_node_options) {
8579 cb ( ) ;
8680 } ) ) ;
8781 } ) ;
88- }
89-
90- function runTest ( ) {
91- const fn = tests . shift ( ) ;
92-
93- if ( ! fn ) {
94- return ;
95- }
96-
97- fn ( ( ) => {
98- setTimeout ( runTest , timeout ) ;
99- } ) ;
100- }
101-
102- runTest ( ) ;
82+ } ) ;
0 commit comments