Skip to content

Commit 0bbe5d3

Browse files
authored
test: show more information in test-http2-debug upon failure
Use spawnSyncAndAssert() so that the stderr is logged when it doesn't match expectations. PR-URL: #58391 Refs: #58353 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent d2a1369 commit 0bbe5d3

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

test/parallel/test-http2-debug.js

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,31 @@
11
'use strict';
2+
23
const common = require('../common');
34
if (!common.hasCrypto)
45
common.skip('missing crypto');
56
const assert = require('assert');
6-
const child_process = require('child_process');
7+
const { spawnSyncAndAssert } = require('../common/child_process');
78
const path = require('path');
89

9-
process.env.NODE_DEBUG_NATIVE = 'http2';
10-
process.env.NODE_DEBUG = 'http2';
11-
const { stdout, stderr } = child_process.spawnSync(process.execPath, [
10+
spawnSyncAndAssert(process.execPath, [
1211
path.resolve(__dirname, 'test-http2-ping.js'),
13-
], { encoding: 'utf8' });
14-
15-
assert(stderr.match(/Setting the NODE_DEBUG environment variable to 'http2' can expose sensitive data \(such as passwords, tokens and authentication headers\) in the resulting log\.\r?\n/),
16-
stderr);
17-
assert(stderr.match(/Http2Session client \(\d+\) handling data frame for stream \d+\r?\n/),
18-
stderr);
19-
assert(stderr.match(/HttpStream \d+ \(\d+\) \[Http2Session client \(\d+\)\] reading starting\r?\n/),
20-
stderr);
21-
assert(stderr.match(/HttpStream \d+ \(\d+\) \[Http2Session client \(\d+\)\] closed with code 0\r?\n/),
22-
stderr);
23-
assert(stderr.match(/HttpStream \d+ \(\d+\) \[Http2Session server \(\d+\)\] closed with code 0\r?\n/),
24-
stderr);
25-
assert(stderr.match(/HttpStream \d+ \(\d+\) \[Http2Session server \(\d+\)\] tearing down stream\r?\n/),
26-
stderr);
27-
assert.strictEqual(stdout.trim(), '');
12+
], {
13+
env: {
14+
...process.env,
15+
NODE_DEBUG: 'http2',
16+
NODE_DEBUG_NATIVE: 'http2',
17+
},
18+
}, {
19+
trim: true,
20+
stderr(output) {
21+
assert.match(output,
22+
/Setting the NODE_DEBUG environment variable to 'http2' can expose sensitive data/);
23+
assert.match(output, /\(such as passwords, tokens and authentication headers\) in the resulting log\.\r?\n/);
24+
assert.match(output, /Http2Session client \(\d+\) handling data frame for stream \d+\r?\n/);
25+
assert.match(output, /HttpStream \d+ \(\d+\) \[Http2Session client \(\d+\)\] reading starting\r?\n/);
26+
assert.match(output, /HttpStream \d+ \(\d+\) \[Http2Session client \(\d+\)\] closed with code 0\r?\n/);
27+
assert.match(output, /HttpStream \d+ \(\d+\) \[Http2Session server \(\d+\)\] closed with code 0\r?\n/);
28+
assert.match(output, /HttpStream \d+ \(\d+\) \[Http2Session server \(\d+\)\] tearing down stream\r?\n/);
29+
},
30+
stdout: ''
31+
});

0 commit comments

Comments
 (0)