test: don't use process.exit to end tests

Newer versions of `tap` run more asynchronously, so sometimes using `process.nextTick(process.exit)`
to end a test would prevent the test from completing correctly. Removing all instances of
`process.nextTick(process.exit)` put tests into three categories:
* the test still worked correctly -- no fixup needed.
* the test would hang because the VM's `_steppingInterval` was keeping
  Node alive. These tests call a new `quit()` method which ends the
  stepping interval.
* the `load-extensions` test needed special attention because the "Video
  Sensing" extension starts its own loop using `setTimeout`. I added a
  `_stopLoop()` method on the extension and directly call that from the
  test. I'm not completely happy with this solution but anything more
  general would likely require a change to the extension spec, so I'm
  leaving that as a followup task.
This commit is contained in:
Christopher Willis-Ford 2022-06-06 12:00:10 -07:00
parent 605b1c2386
commit 840ffb5df0
69 changed files with 182 additions and 156 deletions

View file

@ -2578,6 +2578,15 @@ class Runtime extends EventEmitter {
this.emit(Runtime.RUNTIME_STARTED);
}
/**
* Quit the Runtime, clearing any handles which might keep the process alive.
* Do not use the runtime after calling this method. This method is meant for test shutdown.
*/
quit () {
clearInterval(this._steppingInterval);
this._steppingInterval = null;
}
/**
* Turn on profiling.
* @param {Profiler/FrameCallback} onFrame A callback handle passed a

View file

@ -81,8 +81,8 @@ class ExtensionManager {
this.pendingWorkers = [];
/**
* Set of loaded extension URLs/IDs (equivalent for built-in extensions).
* @type {Set.<string>}
* Map of loaded extension URLs/IDs (equivalent for built-in extensions) to service name.
* @type {Map.<string,string>}
* @private
*/
this._loadedExtensions = new Map();

View file

@ -231,7 +231,8 @@ class Scratch3VideoSensingBlocks {
* @private
*/
_loop () {
setTimeout(this._loop.bind(this), Math.max(this.runtime.currentStepTime, Scratch3VideoSensingBlocks.INTERVAL));
const loopTime = Math.max(this.runtime.currentStepTime, Scratch3VideoSensingBlocks.INTERVAL);
this._loopInterval = setTimeout(this._loop.bind(this), loopTime);
// Add frame to detector
const time = Date.now();
@ -251,6 +252,13 @@ class Scratch3VideoSensingBlocks {
}
}
/**
* Stop the video sampling loop. Only used for testing.
*/
_stopLoop () {
clearTimeout(this._loopInterval);
}
/**
* Create data for a menu in scratch-blocks format, consisting of an array
* of objects with text and value properties. The text is a translated

View file

@ -175,6 +175,14 @@ class VirtualMachine extends EventEmitter {
this.runtime.start();
}
/**
* Quit the VM, clearing any handles which might keep the process alive.
* Do not use the runtime after calling this method. This method is meant for test shutdown.
*/
quit () {
this.runtime.quit();
}
/**
* "Green flag" handler - start all threads starting with a green flag.
*/

View file

@ -27,8 +27,8 @@ test('default cat', t => {
vm.on('playgroundData', e => {
const threads = JSON.parse(e.threads);
t.ok(threads.length === 0);
vm.quit();
t.end();
process.nextTick(process.exit);
});
vm.start();

View file

@ -33,8 +33,8 @@ test('importing sb2 project where block comment is converted to workspace commen
const invalidComments = targetComments.filter(comment => typeof comment.blockId === 'number');
t.equal(invalidComments.length, 0);
vm.quit();
t.end();
process.nextTick(process.exit);
});
// Start VM, load project, and run

View file

@ -38,8 +38,8 @@ test('importing sb2 project where block comment is converted to workspace commen
const targetBlocks = Object.values(target.blocks._blocks);
t.equal(targetBlocks.length, 0);
vm.quit();
t.end();
process.nextTick(process.exit);
});
// Start VM, load project, and run

View file

@ -62,8 +62,8 @@ test('importing sb2 project with special chars in message names', t => {
t.equal(catMessageBlocks[0].fields.BROADCAST_OPTION.id, ltPerfectMessageId);
t.equal(catMessageBlocks[1].fields.BROADCAST_OPTION.id, abMessageId);
vm.quit();
t.end();
process.nextTick(process.exit);
});
// Start VM, load project, and run

View file

@ -62,8 +62,8 @@ test('importing sb3 project with special chars in message names', t => {
t.equal(catMessageBlocks[0].fields.BROADCAST_OPTION.id, ltPerfectMessageId);
t.equal(catMessageBlocks[1].fields.BROADCAST_OPTION.id, abMessageId);
vm.quit();
t.end();
process.nextTick(process.exit);
});
// Start VM, load project, and run

View file

@ -65,8 +65,8 @@ test('clone-cleanup', t => {
// The second batch of clones has deleted themselves; everything is finished
verifyCounts(0, 0);
vm.quit();
t.end();
process.nextTick(process.exit);
break;
}
};

View file

@ -37,6 +37,7 @@ test('importing an sb2 project with cloud variables', t => {
// when the message is being sent to the server rather than on the client
t.equal(variable.isCloud, true);
vm.quit();
t.end();
});
});
@ -60,6 +61,7 @@ test('importing an sb2 project with cloud variables at the limit for a project',
// All of the 8 stage variables should be cloud variables
t.equal(stageVars.filter(v => v.isCloud).length, 10);
vm.quit();
t.end();
});
});
@ -85,6 +87,7 @@ test('importing an sb2 project with cloud variables exceeding the limit for a pr
// Only 8 of the variables should have the isCloud flag set to true
t.equal(stageVars.filter(v => v.isCloud).length, 10);
vm.quit();
t.end();
});
});
@ -115,6 +118,7 @@ test('importing one project after the other resets cloud variable limit', t => {
t.equal(vm.runtime.canAddCloudVariable(), true);
vm.quit();
t.end();
});
});
@ -145,8 +149,7 @@ test('local cloud variables get imported as regular variables', t => {
t.equal(spriteVars.length, 1);
t.equal(spriteVars[0].isCloud, false);
vm.quit();
t.end();
process.nextTick(process.exit); // This is needed because this is the end of the last test in this file!!!
});
});

View file

@ -35,6 +35,7 @@ test('importing an sb3 project with cloud variables', t => {
t.equal(Number(variable.value), 100);
t.equal(variable.isCloud, true);
vm.quit();
t.end();
});
});
@ -58,6 +59,7 @@ test('importing an sb3 project with cloud variables at the limit for a project',
// All of the 10 stage variables should be cloud variables
t.equal(stageVars.filter(v => v.isCloud).length, 10);
vm.quit();
t.end();
});
});
@ -83,6 +85,7 @@ test('importing an sb3 project with cloud variables exceeding the limit for a pr
// Only 8 of the variables should have the isCloud flag set to true
t.equal(stageVars.filter(v => v.isCloud).length, 10);
vm.quit();
t.end();
});
});
@ -111,6 +114,7 @@ test('importing one project after the other resets cloud variable limit', t => {
t.equal(vm.runtime.canAddCloudVariable(), true);
vm.quit();
t.end();
});
});
@ -141,8 +145,7 @@ test('local cloud variables get imported as regular variables', t => {
t.equal(spriteVars.length, 1);
t.equal(spriteVars[0].isCloud, false);
vm.quit();
t.end();
process.nextTick(process.exit); // This is needed because this is the end of the last test in this file!!!
});
});

View file

@ -70,8 +70,8 @@ test('importing sb2 project with comments', t => {
t.equal(stopAllBlock.comment, blockComments[4].id);
t.equal(stopAllBlock.opcode, 'control_stop');
vm.quit();
t.end();
process.nextTick(process.exit);
});
// Start VM, load project, and run

View file

@ -70,8 +70,8 @@ test('load an sb3 project with comments', t => {
t.equal(stopAllBlock.comment, blockComments[4].id);
t.equal(stopAllBlock.opcode, 'control_stop');
vm.quit();
t.end();
process.nextTick(process.exit);
});
// Start VM, load project, and run

View file

@ -19,8 +19,8 @@ test('complex', t => {
vm.on('playgroundData', e => {
const threads = JSON.parse(e.threads);
t.ok(threads.length === 0);
vm.quit();
t.end();
process.nextTick(process.exit);
});
// Manipulate each target

View file

@ -15,8 +15,8 @@ test('control', t => {
vm.on('playgroundData', e => {
const threads = JSON.parse(e.threads);
t.ok(threads.length > 0);
vm.quit();
t.end();
process.nextTick(process.exit);
});
// Start VM, load project, and run

View file

@ -14,8 +14,8 @@ test('data', t => {
// Evaluate playground data and exit
vm.on('playgroundData', () => {
// @todo Additional tests
vm.quit();
t.end();
process.nextTick(process.exit);
});
// Start VM, load project, and run

View file

@ -27,8 +27,8 @@ test('default cat', t => {
vm.on('playgroundData', e => {
const threads = JSON.parse(e.threads);
t.ok(threads.length === 0);
vm.quit();
t.end();
process.nextTick(process.exit);
});
vm.start();

View file

@ -15,8 +15,8 @@ test('event', t => {
vm.on('playgroundData', e => {
const threads = JSON.parse(e.threads);
t.ok(threads.length > 0);
vm.quit();
t.end();
process.nextTick(process.exit);
});
// Start VM, load project, and run

View file

@ -66,6 +66,8 @@ fs.readdirSync(executeDir)
log.suggest.deny('vm', 'error');
t.tearDown(() => log.suggest.clear());
const vm = new VirtualMachine();
// Map string messages to tap reporting methods. This will be used
// with events from scratch's runtime emitted on block instructions.
let didPlan;
@ -86,6 +88,7 @@ fs.readdirSync(executeDir)
},
end () {
didEnd = true;
vm.quit();
t.end();
}
};
@ -100,7 +103,6 @@ fs.readdirSync(executeDir)
return reporters.comment(text);
};
const vm = new VirtualMachine();
vm.attachStorage(makeTestStorage());
// Start the VM and initialize some vm properties.
@ -138,6 +140,7 @@ fs.readdirSync(executeDir)
// it can be resolved.
if (!didEnd) {
t.fail('did not say "end"');
vm.quit();
t.end();
}
});

View file

@ -20,8 +20,8 @@ test('complex', t => {
const results = vm.runtime.targets[0].variables[resultKey].value;
t.deepEqual(results, ['3', '2', '1', 'stage']);
vm.quit();
t.end();
process.nextTick(process.exit);
});
// Start VM, load project, and run

View file

@ -15,8 +15,8 @@ test('default', t => {
vm.on('playgroundData', e => {
const threads = JSON.parse(e.threads);
t.ok(threads.length === 0);
vm.quit();
t.end();
process.nextTick(process.exit);
});
// Start VM, load project, and run

View file

@ -15,8 +15,8 @@ test('default', t => {
vm.on('playgroundData', e => {
const threads = JSON.parse(e.threads);
t.ok(threads.length === 0);
vm.quit();
t.end();
process.nextTick(process.exit);
});
// Start VM, load project, and run

View file

@ -31,8 +31,8 @@ test('importing sb3 project with incorrect list monitor name', t => {
t.equal(monitorBlock.fields.LIST.value, renamedListName);
}
vm.quit();
t.end();
process.nextTick(process.exit);
});
// Start VM, load project, and run

View file

@ -3,9 +3,19 @@ const tap = require('tap');
const {test} = tap;
const fs = require('fs');
const readFileToBuffer = require('../fixtures/readProjectFile').readFileToBuffer;
const dispatch = require('../../src/dispatch/central-dispatch');
const VirtualMachine = require('../../src/index');
tap.tearDown(() => process.nextTick(process.exit));
/**
* Call _stopLoop() on the Video Sensing extension.
* @param {VirtualMachine} vm - a VM instance which has loaded the 'videoSensing' extension.
*/
const stopVideoLoop = vm => {
// TODO: provide a general way to tell extensions to shut down
// Ideally we'd just dispose of the extension's Worker...
const serviceName = vm.extensionManager._loadedExtensions.get('videoSensing');
dispatch.call(serviceName, '_stopLoop');
};
test('Load external extensions', async t => {
const vm = new VirtualMachine();
@ -25,6 +35,9 @@ test('Load external extensions', async t => {
});
});
}
stopVideoLoop(vm);
vm.quit();
t.end();
});
@ -64,5 +77,7 @@ test('Load video sensing extension and video properties', async t => {
t.equal(vm.runtime.ioDevices.video._ghost, project.videoTransparency);
}
stopVideoLoop(vm);
vm.quit();
t.end();
});

View file

@ -17,8 +17,8 @@ test('sb2 project (originally from Scratch 1.4) with missing backdrop image shou
vm.on('playgroundData', e => {
const threads = JSON.parse(e.threads);
t.ok(threads.length === 0);
vm.quit();
t.end();
process.nextTick(process.exit);
});
vm.start();

View file

@ -15,8 +15,8 @@ test('looks', t => {
vm.on('playgroundData', e => {
const threads = JSON.parse(e.threads);
t.ok(threads.length === 0);
vm.quit();
t.end();
process.nextTick(process.exit);
});
// Start VM, load project, and run

View file

@ -122,8 +122,8 @@ test('importing sb2 project with monitors', t => {
t.equal(monitorRecord.spriteName, null);
t.equal(monitorRecord.targetId, null);
vm.quit();
t.end();
process.nextTick(process.exit);
});
// Start VM, load project, and run

View file

@ -140,7 +140,6 @@ test('saving and loading sb2 project with monitors preserves sliderMin and slide
t.equal(monitorRecord.targetId, null);
t.end();
process.nextTick(process.exit);
});
// Start VM, load project, and run

View file

@ -247,8 +247,8 @@ test('importing sb3 project with monitors', t => {
t.equal(monitorRecord.targetId, null);
t.equal(vm.extensionManager.isExtensionLoaded('ev3'), true);
vm.quit();
t.end();
process.nextTick(process.exit);
});
// Start VM, load project, and run

View file

@ -15,8 +15,8 @@ test('motion', t => {
vm.on('playgroundData', e => {
const threads = JSON.parse(e.threads);
t.ok(threads.length > 0);
vm.quit();
t.end();
process.nextTick(process.exit);
});
// Start VM, load project, and run

View file

@ -33,8 +33,8 @@ test('offline-custom-assets', t => {
vm.on('playgroundData', e => {
const threads = JSON.parse(e.threads);
t.ok(threads.length === 0);
vm.quit();
t.end();
process.nextTick(process.exit);
});
// Start VM, load project, and run

View file

@ -37,8 +37,8 @@ test('pen', t => {
t.equal(originalPenState.penAttributes.diameter, 51);
t.equal(clonePenState.penAttributes.diameter, 42);
vm.quit();
t.end();
process.nextTick(process.exit);
});
// Start VM, load project, and run

View file

@ -15,8 +15,8 @@ test('procedure', t => {
vm.on('playgroundData', e => {
const threads = JSON.parse(e.threads);
t.ok(threads.length === 0);
vm.quit();
t.end();
process.nextTick(process.exit);
});
// Start VM, load project, and run

View file

@ -19,8 +19,8 @@ test('Running project should not emit project changed event', t => {
// Evaluate playground data and exit
vm.on('playgroundData', () => {
t.equal(projectChanged, false);
vm.quit();
t.end();
process.nextTick(process.exit);
});
// Start VM, load project, and run

View file

@ -29,8 +29,8 @@ test('say/think and wait', t => {
// The test will fail if the project throws.
setTimeout(() => {
vm.stopAll();
vm.quit();
t.end();
process.nextTick(process.exit);
}, 2000);
});
});

View file

@ -25,8 +25,6 @@ const visibleTempoMonitorProjectUri = path.resolve(
__dirname, '../fixtures/visible-tempo-monitor-no-other-music-blocks.sb2');
const visibleTempoMonitorProject = readFileToBuffer(visibleTempoMonitorProjectUri);
tap.tearDown(() => process.nextTick(process.exit));
test('loading sb2 project with invisible video monitor should not load monitor or extension', t => {
const vm = new VirtualMachine();
vm.attachStorage(makeTestStorage());
@ -39,6 +37,7 @@ test('loading sb2 project with invisible video monitor should not load monitor o
vm.loadProject(invisibleVideoMonitorProject).then(() => {
t.equal(vm.extensionManager.isExtensionLoaded('videoSensing'), false);
t.equal(vm.runtime._monitorState.size, 0);
vm.quit();
t.end();
});
});
@ -55,6 +54,7 @@ test('loading sb2 project with visible video monitor should not load extension',
vm.loadProject(visibleVideoMonitorProject).then(() => {
t.equal(vm.extensionManager.isExtensionLoaded('videoSensing'), false);
t.equal(vm.runtime._monitorState.size, 0);
vm.quit();
t.end();
});
});
@ -86,6 +86,7 @@ test('sb2 project with invisible music monitor should not load monitor or extens
vm.loadProject(invisibleTempoMonitorProject).then(() => {
t.equal(vm.extensionManager.isExtensionLoaded('music'), false);
t.equal(vm.runtime._monitorState.size, 0);
vm.quit();
t.end();
});
});
@ -104,6 +105,7 @@ test('sb2 project with visible music monitor should load monitor and extension',
t.equal(vm.runtime._monitorState.size, 1);
t.equal(vm.runtime._monitorState.has('music_getTempo'), true);
t.equal(vm.runtime._monitorState.get('music_getTempo').visible, true);
vm.quit();
t.end();
});
});

View file

@ -122,5 +122,4 @@ test('serializeCostume saves orignal broken costume', t => {
t.equal(costume.fileName, `${brokenCostumeMd5}.png`);
t.equal(md5(costume.fileContent), brokenCostumeMd5);
t.end();
process.nextTick(process.exit);
});

View file

@ -124,5 +124,4 @@ test('serializeCostume saves orignal broken costume', t => {
t.equal(costume.fileName, `${brokenCostumeMd5}.svg`);
t.equal(md5(costume.fileContent), brokenCostumeMd5);
t.end();
process.nextTick(process.exit);
});

View file

@ -107,5 +107,4 @@ test('serializeCostume does not save data for missing costume', t => {
t.not(costumeDescs[0].fileName, `${missingCostumeAssetId}.png`);
t.end();
process.nextTick(process.exit);
});

View file

@ -106,5 +106,4 @@ test('serializeCostume does not save data for missing costume', t => {
t.not(costumeDescs[0].fileName, `${missingCostumeAssetId}.svg`);
t.end();
process.nextTick(process.exit);
});

View file

@ -122,5 +122,4 @@ test('serializeCostume saves orignal broken costume', t => {
t.equal(costume.fileName, `${brokenCostumeMd5}.png`);
t.equal(md5(costume.fileContent), brokenCostumeMd5);
t.end();
process.nextTick(process.exit);
});

View file

@ -116,5 +116,4 @@ test('serializeSounds saves orignal broken sound', t => {
t.equal(sound.fileName, `${brokenSoundMd5}.wav`);
t.equal(md5(sound.fileContent), brokenSoundMd5);
t.end();
process.nextTick(process.exit);
});

View file

@ -103,5 +103,4 @@ test('serializeCostume saves orignal broken costume', t => {
t.equal(costume.fileName, `${brokenCostumeMd5}.svg`);
t.equal(md5(costume.fileContent), brokenCostumeMd5);
t.end();
process.nextTick(process.exit);
});

View file

@ -107,5 +107,4 @@ test('serializeCostume does not save data for missing costume', t => {
t.not(costumeDescs[0].fileName, `${missingCostumeAssetId}.png`);
t.end();
process.nextTick(process.exit);
});

View file

@ -83,5 +83,4 @@ test('serializeCostume does not save data for missing costume', t => {
t.not(soundDescs[0].fileName, `${missingSoundAssetId}.wav`);
t.end();
process.nextTick(process.exit);
});

View file

@ -86,5 +86,4 @@ test('serializeCostume does not save data for missing costume', t => {
t.not(costumeDescs[0].fileName, `${missingCostumeAssetId}.svg`);
t.end();
process.nextTick(process.exit);
});

View file

@ -15,8 +15,8 @@ test('sensing', t => {
vm.on('playgroundData', e => {
const threads = JSON.parse(e.threads);
t.ok(threads.length > 0);
vm.quit();
t.end();
process.nextTick(process.exit);
});
// Start VM, load project, and run

View file

@ -20,8 +20,8 @@ test('sound', t => {
vm.on('playgroundData', e => {
const threads = JSON.parse(e.threads);
t.ok(threads.length > 0);
vm.quit();
t.end();
process.nextTick(process.exit);
});
// Start VM, load project, and run

View file

@ -121,5 +121,4 @@ test('serializeCostume saves orignal broken costume', t => {
t.equal(costume.fileName, `${brokenCostumeMd5}.png`);
t.equal(md5(costume.fileContent), brokenCostumeMd5);
t.end();
process.nextTick(process.exit);
});

View file

@ -122,5 +122,4 @@ test('serializeCostume saves orignal broken costume', t => {
t.equal(costume.fileName, `${brokenCostumeMd5}.svg`);
t.equal(md5(costume.fileContent), brokenCostumeMd5);
t.end();
process.nextTick(process.exit);
});

View file

@ -103,5 +103,4 @@ test('serializeCostume does not save data for missing costume', t => {
t.equal(costumeDescs.length, 0);
t.end();
process.nextTick(process.exit);
});

View file

@ -103,5 +103,4 @@ test('serializeCostume does not save data for missing costume', t => {
t.equal(costumeDescs.length, 0);
t.end();
process.nextTick(process.exit);
});

View file

@ -121,5 +121,4 @@ test('serializeCostume saves orignal broken costume', t => {
t.equal(costume.fileName, `${brokenCostumeMd5}.png`);
t.equal(md5(costume.fileContent), brokenCostumeMd5);
t.end();
process.nextTick(process.exit);
});

View file

@ -102,5 +102,4 @@ test('serializeCostume saves orignal broken costume', t => {
t.equal(costume.fileName, `${brokenCostumeMd5}.svg`);
t.equal(md5(costume.fileContent), brokenCostumeMd5);
t.end();
process.nextTick(process.exit);
});

View file

@ -103,5 +103,4 @@ test('serializeCostume does not save data for missing costume', t => {
t.equal(costumeDescs.length, 0);
t.end();
process.nextTick(process.exit);
});

View file

@ -83,5 +83,4 @@ test('serializeCostume does not save data for missing costume', t => {
t.equal(costumeDescs.length, 0);
t.end();
process.nextTick(process.exit);
});

View file

@ -22,8 +22,8 @@ test('stack click activates the stack', t => {
vm.on('playgroundData', () => {
// The sprite should have moved 100 to the right
t.equal(vm.editingTarget.x, 100);
vm.quit();
t.end();
process.nextTick(process.exit);
});
// Start VM, load project, and run

View file

@ -48,7 +48,7 @@ test('unknown opcode', t => {
t.true(blocks.getBlock(fourthBlockInputId).shadow);
t.equal(blocks.getBlock(fourthBlockInputId).opcode, 'sound_sounds_menu');
vm.quit();
t.end();
process.nextTick(process.exit);
});
});

View file

@ -33,7 +33,7 @@ test('unknown opcode', t => {
t.equal(blocks.getBlock(secondBlockId).opcode, 'control_forever');
t.equal(innerBlockId, null);
vm.quit();
t.end();
process.nextTick(process.exit);
});
});

View file

@ -49,7 +49,7 @@ test('unknown opcode', t => {
t.equal(undefinedComment.x, 0);
t.equal(undefinedComment.y, 0);
vm.quit();
t.end();
process.nextTick(process.exit);
});
});

View file

@ -35,8 +35,8 @@ test('importing one project after the other resets monitored variables', t => {
const jamalVarBlock = vm.runtime.monitorBlocks.getBlock(jamalVarId);
t.notOk(jamalVarBlock);
vm.quit();
t.end();
process.nextTick(process.exit);
});
});
});

View file

@ -114,8 +114,8 @@ test('importing sb2 project with special chars in variable names', t => {
t.equal(bananasVarBlocks.length, 1);
t.equal(bananasVarBlocks[0].fields.VARIABLE.id, ltPerfectVarId);
vm.quit();
t.end();
process.nextTick(process.exit);
});
// Start VM, load project, and run

View file

@ -114,8 +114,8 @@ test('importing sb3 project with special chars in variable names', t => {
t.equal(bananasVarBlocks.length, 1);
t.equal(bananasVarBlocks[0].fields.VARIABLE.id, ltPerfectVarId);
vm.quit();
t.end();
process.nextTick(process.exit);
});
// Start VM, load project, and run

View file

@ -6,8 +6,6 @@ const Runtime = require('../../src/engine/runtime');
const MonitorRecord = require('../../src/engine/monitor-record');
const {Map} = require('immutable');
tap.tearDown(() => process.nextTick(process.exit));
const test = tap.test;
test('spec', t => {
@ -193,6 +191,7 @@ test('Starting the runtime emits an event', t => {
});
rt.start();
t.equal(started, true);
rt.quit();
t.end();
});
@ -209,6 +208,7 @@ test('Runtime cannot be started while already running', t => {
// Starting again should not emit another event
rt.start();
t.equal(started, false);
rt.quit();
t.end();
});
@ -224,6 +224,7 @@ test('setCompatibilityMode restarts if it was already running', t => {
rt.setCompatibilityMode(true);
t.equal(started, true);
rt.quit();
t.end();
});

View file

@ -27,8 +27,6 @@ tap.beforeEach(() => {
});
});
tap.tearDown(() => process.nextTick(process.exit));
const test = tap.test;
test('Adding a sprite (from sprite2) should emit a project changed event', t => {

View file

@ -53,8 +53,6 @@ tap.beforeEach(() => {
});
});
tap.tearDown(() => process.nextTick(process.exit));
const test = tap.test;
test('Creating a block should emit a project changed event', t => {

View file

@ -4,8 +4,6 @@ const readFileToBuffer = require('../fixtures/readProjectFile').readFileToBuffer
const makeTestStorage = require('../fixtures/make-test-storage');
const VirtualMachine = require('../../src/virtual-machine');
tap.tearDown(() => process.nextTick(process.exit));
const test = tap.test;
// Test that loading a project does not emit a project change

View file

@ -8,8 +8,6 @@ const Renderer = require('../fixtures/fake-renderer');
const Runtime = require('../../src/engine/runtime');
const RenderedTarget = require('../../src/sprites/rendered-target');
tap.tearDown(() => process.nextTick(process.exit));
const test = tap.test;
test('deleteSound returns function after deleting or null if nothing was deleted', t => {
@ -1016,6 +1014,7 @@ test('Starting the VM emits an event', t => {
});
vm.start();
t.equal(started, true);
vm.quit();
t.end();
});