Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const tests = getTests();
for (let i = 0; i < tests.length; i++) {
const test = tests[i];
const server = spawnServer();
listen(server);
log.info('Running test ' + (i + 1) + ' of ' + tests.length);
spawnSync('truffle test ' + test + ' --network develop', {
stdio: 'inherit',
shell: true
});
kill(server.pid);
if (i < (tests.length - 1)) {
await sleep(1000);
}
}
break;
case 'coverage':
// @TODO: refactor SolCover + pull request + start coverage task without provided TestRPC (user our own Ganache Server)
// remove build folder, otherwise the result of code coverage might not be correct
sh.rm('-fr', './build');
spawnSync('solidity-coverage', {
stdio: 'inherit',
shell: true
});
const killPromise = new Promise(resolve => kill(this.process.pid, 'SIGTERM', resolve));
await fcb(cb => treeKill(proc.pid, undefined, cb));
}
function cleanExit() {
if (!dead) {
log.info(process.pid);
log.info('Clean up all (sub) processes');
kill(process.pid, 'SIGTERM', (err) => {
if (arguments.length > 0) {
log.info('tree kill callback arguments:');
log.info(arguments.toString());
}
if (err) {
log.error(err);
}
});
dead = true;
}
}
function cleanExit() {
if (!dead) {
log.info('PID main process: ' + process.pid);
log.info('Clean up all (sub) processes');
kill(process.pid, 'SIGTERM', (err) => {
if (arguments.length > 0) {
log.info('tree kill callback arguments:');
log.info(arguments);
}
if (err) {
log.error(err);
}
});
dead = true;
}
}
function cleanExit(code = 1) {
if (proc && proc.pid) {
treeKill(proc.pid, () => exit(code))
} else {
exit(code)
}
}
it('should log errors from killing the process', async done => {
treeKill.mockImplementation((pid, signal, callback) => {
callback(new Error('Error Message'));
});
const loggerError = spyOn(context.logger, 'error');
scheduleTargetAndForget = scheduleTargetAndForget.and.returnValue(
from([
{ success: true, outfile: 'outfile.js' },
{ success: true, outfile: 'outfile.js' }
])
);
electronExecuteBuilderHandler(testOptions, context).subscribe({
complete: () => {
expect(loggerError.calls.argsFor(1)).toEqual(['Error Message']);
done();
}
});
});
function openByElectron(argv: StartOption, prevProcess?: ch.ChildProcess, onRestart?: () => void) {
if (prevProcess && prevProcess.kill) {
try {
restartingElectron = true
kill(prevProcess.pid, 'SIGKILL')
setTimeout(() => {
restartingElectron = false
}, 5000)
} catch (err) {
message.error(`failed to kill electron process: ${err.message}`)
}
}
const DefaultPort = 5858
const args = [
argv.electronInspectBrk != null
? `--inspect-brk=${argv.electronInspectBrk || DefaultPort}`
: argv.electronInspect != null
? `--inspect=${argv.electronInspect || DefaultPort}`
: '',
'.',
killTask(execution: TaskExecution) {
if (execution.process.pid) {
kill(execution.process.pid);
}
}
this.simulateCtrlC = () => {
kill(this.childProcess.pid, 'SIGINT');
};
});