Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function errorResult(error: Error): RunResult {
return {
errorMessages: [errorToString(error)],
status: RunStatus.Error,
tests: []
};
}
public async run(options: RunOptions, attemptsLeft = 2, lastError?: Error): Promise {
if (attemptsLeft > 0) {
try {
return await this.innerRunner.run(options);
} catch (error) {
if (error instanceof OutOfMemoryError) {
this.log.info('Test runner process [%s] ran out of memory. You probably have a memory leak in your tests. Don\'t worry, Stryker will restart the process, but you might want to investigate this later, because this decreases performance.', error.pid);
}
await this.recover();
return this.run(options, attemptsLeft - 1, error);
}
} else {
await this.recover();
return { status: RunStatus.Error, errorMessages: [ERROR_MESSAGE + errorToString(lastError)], tests: [] };
}
}
if (attemptsLeft > 0) {
try {
return await this.innerRunner.run(options);
} catch (error) {
if (error instanceof OutOfMemoryError) {
this.log.info(
"Test runner process [%s] ran out of memory. You probably have a memory leak in your tests. Don't worry, Stryker will restart the process, but you might want to investigate this later, because this decreases performance.",
error.pid
);
}
await this.recover();
return this.run(options, attemptsLeft - 1, error);
}
} else {
await this.recover();
return { status: RunStatus.Error, errorMessages: [`${ERROR_MESSAGE}${errorToString(lastError)}`], tests: [] };
}
}
function errorResult(error: Error): RunResult {
return {
errorMessages: [errorToString(error)],
status: RunStatus.Error,
tests: []
};
}
.catch(error => {
this.send({
correlationId: message.correlationId,
error: errorToString(error),
kind: ParentMessageKind.Rejection
});
});
this.removeAnyAdditionalMessageListeners(this.handleMessage);
.catch(error => ({ outputFiles: [], error: errorToString(error) }));
}
private async transpileMutant(mutant: TestableMutant): Promise {
const filesToTranspile: File[] = [];
if (this.currentMutatedFile && this.currentMutatedFile.name !== mutant.fileName) {
filesToTranspile.push(this.currentMutatedFile.file);
}
this.currentMutatedFile = mutant.sourceFile;
const mutatedFile = new File(mutant.fileName, Buffer.from(mutant.mutatedCode));
filesToTranspile.push(mutatedFile);
try {
const transpiledFiles = await this.transpiler.transpile(filesToTranspile);
return this.createTranspiledMutant(mutant, { outputFiles: transpiledFiles, error: null });
} catch (error) {
return this.createTranspiledMutant(mutant, { outputFiles: [], error: errorToString(error) });
}
}
}
}).catch(error => {
this.send({
correlationId: message.correlationId,
error: errorToString(error),
kind: ParentMessageKind.Rejection
});
});
this.removeAnyAdditionalMessageListeners(this.handleMessage);
.catch(err => {
this.log.error(`Unable to reach ${BASE_NPM_SEARCH} (for query ${query}). Please check your internet connection.`, errorToString(err));
const result: NpmSearchResult = {
results: [],
total: 0
};
return result;
});
}