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