Skip to content

Commit

Permalink
chore(test): improve log output on error
Browse files Browse the repository at this point in the history
  • Loading branch information
mmarchini committed Jul 15, 2023
1 parent 1b94e27 commit 26592b9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
7 changes: 7 additions & 0 deletions test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,15 @@ function startFixtureProcess(t, withInspector = false, port = '0') {
execArgv.push('--inspect');
}
const child = fork('./test/fixtures/default-program.js', { execArgv, silent: true});
let output = '';
child.stdout.setEncoding('utf-8');
child.stdout.on('data', (data) => output += `[${ child.pid }][stdout] ${ data }`);
child.stderr.setEncoding('utf-8');
child.stderr.on('data', (data) => output += `[${ child.pid }][stderr] ${ data }`);
const fixture = new FixtureProcess(child);
fixture.on('timeout', t.fail);
t.once('result', ({ ok }) => { if (!ok) { console.log(output) } });
t.teardown(() => fixture.send('exit'));
return fixture;
}

Expand Down
7 changes: 0 additions & 7 deletions test/test-executables.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ test('observe heap-profile', async (t) => {
t.notEqual(head, undefined);
const { callFrame } = head;
t.notEqual(callFrame, undefined);
f.send('exit');
t.end();
});
});
Expand All @@ -33,7 +32,6 @@ test('observe heap-profile to file', async (t) => {
t.notEqual(head, undefined);
const { callFrame } = head;
t.notEqual(callFrame, undefined);
f.send('exit');
t.end();
});
});
Expand All @@ -49,7 +47,6 @@ test('observe heap-snapshot', async (t) => {
t.notEqual(nodes, undefined);
t.notEqual(edges, undefined);
t.notEqual(strings, undefined);
f.send('exit');
t.end();
});
});
Expand All @@ -65,7 +62,6 @@ test('observe heap-snapshot to file', async (t) => {
t.notEqual(nodes, undefined);
t.notEqual(edges, undefined);
t.notEqual(strings, undefined);
f.send('exit');
t.end();
});
});
Expand All @@ -77,7 +73,6 @@ test('observe cpu-profile', async (t) => {
const options = { pid: f.pid, port, options: ['-d', 1]};
const result = await runObserveExecutable('cpu-profile', options);
t.ok(validateCpuProfile(result));
f.send('exit');
t.end();
});
});
Expand All @@ -89,7 +84,6 @@ test('observe cpu-profile to file', async (t) => {
const options = { pid: f.pid, port, toFile: true, options: ['-d', 1]};
const result = await runObserveExecutable('cpu-profile', options);
t.ok(validateCpuProfile(result));
f.send('exit');
t.end();
});
});
Expand All @@ -103,7 +97,6 @@ test('observe --close', async (t) => {
setTimeout(async () => {
t.notOk(await isPortInUse(port));
t.ok(validateCpuProfile(result));
f.send('exit');
t.end();
}, 500);
});
Expand Down

0 comments on commit 26592b9

Please sign in to comment.