mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-01-08 14:01:58 -05:00
test(execute): try to make 'execute' test more reliable
This commit is contained in:
parent
8263893c5b
commit
d8fc81a8b5
1 changed files with 4 additions and 4 deletions
|
@ -27,7 +27,7 @@ const VirtualMachine = require('../../src/index');
|
|||
* been reached.
|
||||
*/
|
||||
|
||||
const whenThreadsComplete = (t, vm, timeLimit = 2000) => (
|
||||
const whenThreadsComplete = (t, vm, uri, timeLimit = 5000) =>
|
||||
// When the number of threads reaches 0 the test is expected to be complete.
|
||||
new Promise((resolve, reject) => {
|
||||
const intervalId = setInterval(() => {
|
||||
|
@ -44,6 +44,7 @@ const whenThreadsComplete = (t, vm, timeLimit = 2000) => (
|
|||
}, 50);
|
||||
|
||||
const timeoutId = setTimeout(() => {
|
||||
t.fail(`Timeout waiting for threads to complete: ${uri}`);
|
||||
reject(new Error('time limit reached'));
|
||||
}, timeLimit);
|
||||
|
||||
|
@ -53,8 +54,7 @@ const whenThreadsComplete = (t, vm, timeLimit = 2000) => (
|
|||
clearInterval(intervalId);
|
||||
clearTimeout(timeoutId);
|
||||
});
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
const executeDir = path.resolve(__dirname, '../fixtures/execute');
|
||||
|
||||
|
@ -127,7 +127,7 @@ fs.readdirSync(executeDir)
|
|||
// the scratch project sent us a "end" message.
|
||||
return vm.loadProject(project)
|
||||
.then(() => vm.greenFlag())
|
||||
.then(() => whenThreadsComplete(t, vm))
|
||||
.then(() => whenThreadsComplete(t, vm, uri))
|
||||
.then(() => {
|
||||
// Setting a plan is not required but is a good idea.
|
||||
if (!didPlan) {
|
||||
|
|
Loading…
Reference in a new issue