fix: Catch exit when Node.js failed
parent
0e932d833a
commit
9e7060707a
|
@ -10,8 +10,11 @@ global.fetch = fetch;
|
|||
|
||||
async function main(file) {
|
||||
const tests = await import('./' + file + '.js');
|
||||
const result = await run.default(tests.default);
|
||||
const result = await run(tests.default);
|
||||
process.send(result);
|
||||
}
|
||||
|
||||
main(process.argv[2]);
|
||||
main(process.argv[2])
|
||||
.catch((error) => {
|
||||
log.error(error);
|
||||
});
|
||||
|
|
|
@ -4,8 +4,17 @@ const tests = {
|
|||
async invalidURL() {
|
||||
try {
|
||||
new Request('http://example.com%');
|
||||
} catch ({name, message}) {
|
||||
return {name, message};
|
||||
return {error: null};
|
||||
} catch (error) {
|
||||
return {error: error.toString()};
|
||||
}
|
||||
},
|
||||
async rejectCredentials() {
|
||||
try {
|
||||
new Request('http://user:pass@example.com');
|
||||
return {error: null};
|
||||
} catch (error) {
|
||||
return {error: error.toString()};
|
||||
}
|
||||
},
|
||||
},
|
||||
|
|
|
@ -44,12 +44,12 @@ export const safari: BrowserDriver = {
|
|||
path: '/usr/bin/safaridriver',
|
||||
args: (port: number, logLevel = 'warn') => {
|
||||
const logLevelArg = {
|
||||
trace: '',
|
||||
debug: '',
|
||||
info: '',
|
||||
warn: '',
|
||||
error: '',
|
||||
silent: '',
|
||||
trace: 'trace',
|
||||
debug: 'debug',
|
||||
info: 'info',
|
||||
warn: 'warn',
|
||||
error: 'error',
|
||||
silent: 'fatal',
|
||||
}[logLevel];
|
||||
if (!logLevelArg) {
|
||||
throw new Error('invalid log level');
|
||||
|
|
|
@ -46,7 +46,7 @@ function* tabularResults(results: Record<string, Result>): Iterable<string[]> {
|
|||
yield [
|
||||
`${group}:${result}:${key}`,
|
||||
n,
|
||||
results[n][group][result][key].toString(),
|
||||
results[n][group][result][key]?.toString() ?? 'null',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ export default class PlatformDeno implements Platform {
|
|||
const child = cp.spawn(binary, []);
|
||||
await new Promise((resolve, reject) => {
|
||||
child.once('error', reject);
|
||||
child.once('exit', reject);
|
||||
child.once('spawn', resolve);
|
||||
});
|
||||
child.kill();
|
||||
|
|
|
@ -12,6 +12,7 @@ export default class PlatformNode implements Platform {
|
|||
);
|
||||
const result: Result = await new Promise((resolve, reject) => {
|
||||
child.once('error', reject);
|
||||
child.once('exit', reject);
|
||||
child.once('message', resolve);
|
||||
});
|
||||
child.kill();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
export type ResultObject = Record<string, string | number>;
|
||||
export type ResultObject = Record<string, string | number | null>;
|
||||
export type Result = Record<string, Record<string, ResultObject>>;
|
||||
|
||||
export interface Context {
|
||||
|
|
Loading…
Reference in New Issue