test: update test-set-http-max-http-headers to use node:test · nodejs/node@cfe5380
@@ -4,17 +4,10 @@ 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');
899-const timeout = common.platformTimeout(100);
10-11-const tests = [];
12-13-function test(fn) {
14-tests.push(fn);
15-}
16-17-test(function(cb) {
10+test(function(_, cb) {
1811console.log('running subtest expecting failure');
19122013// Validate that the test fails if the max header size is too small.
@@ -30,7 +23,7 @@ test(function(cb) {
3023}));
3124});
322533-test(function(cb) {
26+test(function(_, cb) {
3427console.log('running subtest expecting success');
35283629const env = Object.assign({}, process.env, {
@@ -54,13 +47,13 @@ test(function(cb) {
5447}));
5548});
564957-// Next, repeat the same checks using NODE_OPTIONS if it is supported.
58-if (!process.config.variables.node_without_node_options) {
50+const skip = process.config.variables.node_without_node_options;
51+suite('same checks using NODE_OPTIONS if it is supported', { skip }, () => {
5952const env = Object.assign({}, process.env, {
6053NODE_OPTIONS: '--max-http-header-size=1024'
6154});
625563-test(function(cb) {
56+test(function(_, cb) {
6457console.log('running subtest expecting failure');
65586659// Validate that the test fails if the max header size is too small.
@@ -74,7 +67,7 @@ if (!process.config.variables.node_without_node_options) {
7467}));
7568});
766977-test(function(cb) {
70+test(function(_, cb) {
7871// Validate that the test now passes if the same limit is large enough.
7972const args = ['--expose-internals', testName, '1024'];
8073const cp = spawn(process.execPath, args, { env, stdio: 'inherit' });
@@ -85,18 +78,4 @@ if (!process.config.variables.node_without_node_options) {
8578cb();
8679}));
8780});
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();
81+});