Skip to content

Commit 815a957

Browse files
cjihrigtargos
authored andcommitted
test: refactor test-tls-enable-trace-cli.js
PR-URL: #27553 Reviewed-By: Sam Roberts <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent b6e540a commit 815a957

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

test/parallel/test-tls-enable-trace-cli.js

+17-9
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,24 @@ const child = fork(__filename, ['test'], {
2222
execArgv: ['--trace-tls']
2323
});
2424

25+
let stdout = '';
2526
let stderr = '';
27+
child.stdout.setEncoding('utf8');
2628
child.stderr.setEncoding('utf8');
29+
child.stdout.on('data', (data) => stdout += data);
2730
child.stderr.on('data', (data) => stderr += data);
28-
child.on('close', common.mustCall(() => {
31+
child.on('close', common.mustCall((code, signal) => {
32+
// For debugging and observation of actual trace output.
33+
console.log(stderr);
34+
35+
assert.strictEqual(code, 0);
36+
assert.strictEqual(signal, null);
37+
assert.strictEqual(stdout.trim(), '');
2938
assert(/Warning: Enabling --trace-tls can expose sensitive/.test(stderr));
3039
assert(/Received Record/.test(stderr));
3140
assert(/ClientHello/.test(stderr));
3241
}));
3342

34-
// For debugging and observation of actual trace output.
35-
child.stderr.pipe(process.stderr);
36-
child.stdout.pipe(process.stdout);
37-
38-
child.on('exit', common.mustCall((code) => {
39-
assert.strictEqual(code, 0);
40-
}));
41-
4243
function test() {
4344
const {
4445
connect, keys
@@ -54,6 +55,13 @@ function test() {
5455
key: keys.agent6.key
5556
},
5657
}, common.mustCall((err, pair, cleanup) => {
58+
if (err) {
59+
console.error(err);
60+
console.error(err.opensslErrorStack);
61+
console.error(err.reason);
62+
assert(err);
63+
}
64+
5765
return cleanup();
5866
}));
5967
}

0 commit comments

Comments
 (0)