From 3649c15f2a910f9a71ed34219cff1ab78c1e52f3 Mon Sep 17 00:00:00 2001 From: Christopher Willis-Ford Date: Mon, 19 Nov 2018 16:34:30 -0800 Subject: [PATCH] Fix monitor tests to count only monitor threads The monitor tests no longer fail if the last step happens to have run a non-monitor thread in addition to the monitor threads. --- test/integration/monitors_sb2.js | 7 ++++++- test/integration/monitors_sb3.js | 9 +++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/test/integration/monitors_sb2.js b/test/integration/monitors_sb2.js index dc9a9e9e4..a2c263487 100644 --- a/test/integration/monitors_sb2.js +++ b/test/integration/monitors_sb2.js @@ -17,7 +17,12 @@ test('importing sb2 project with monitors', t => { // All monitors should create threads that finish during the step and // are revoved from runtime.threads. t.equal(threads.length, 0); - t.equal(vm.runtime._lastStepDoneThreads.length, 8); + + // we care that the last step updated the right number of monitors + // we don't care whether the last step ran other threads or not + const lastStepUpdatedMonitorThreads = vm.runtime._lastStepDoneThreads.filter(thread => thread.updateMonitor); + t.equal(lastStepUpdatedMonitorThreads.length, 8); + // There should be one additional hidden monitor that is in the monitorState but // does not start a thread. t.equal(vm.runtime._monitorState.size, 9); diff --git a/test/integration/monitors_sb3.js b/test/integration/monitors_sb3.js index 60a280e98..3c5c08f9e 100644 --- a/test/integration/monitors_sb3.js +++ b/test/integration/monitors_sb3.js @@ -8,7 +8,7 @@ const Variable = require('../../src/engine/variable'); const projectUri = path.resolve(__dirname, '../fixtures/monitors.sb3'); const project = readFileToBuffer(projectUri); -test('importing sb2 project with monitors', t => { +test('importing sb3 project with monitors', t => { const vm = new VirtualMachine(); vm.attachStorage(makeTestStorage()); @@ -18,7 +18,12 @@ test('importing sb2 project with monitors', t => { // All monitors should create threads that finish during the step and // are revoved from runtime.threads. t.equal(threads.length, 0); - t.equal(vm.runtime._lastStepDoneThreads.length, 17); + + // we care that the last step updated the right number of monitors + // we don't care whether the last step ran other threads or not + const lastStepUpdatedMonitorThreads = vm.runtime._lastStepDoneThreads.filter(thread => thread.updateMonitor); + t.equal(lastStepUpdatedMonitorThreads.length, 17); + // There should be one additional hidden monitor that is in the monitorState but // does not start a thread. t.equal(vm.runtime._monitorState.size, 18);