Skip to content

Commit

Permalink
test: fix flaky test-vm-timeout-rethrow
Browse files Browse the repository at this point in the history
The intention of test case is to make sure that `timeout` property is honored
and the code in context terminates and throws correct exception. However in
test case, the code inside context would complete before `timeout` for windows
and would sometimes fail. Updated the code so it guarantee to not complete
execution until timeout is triggered.

Fixes: #11261
PR-URL: #11530
Reviewed-By: James M Snell <jasnell.gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Josh Gavant <josh.gavant@outlook.com>
  • Loading branch information
kunalspathak authored and italoacasas committed Feb 25, 2017
1 parent 56cd193 commit ff85483
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions test/sequential/test-vm-timeout-rethrow.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,9 @@ const vm = require('vm');
const spawn = require('child_process').spawn;

if (process.argv[2] === 'child') {
const code = 'let j = 0;\n' +
'for (let i = 0; i < 1000000; i++) j += add(i, i + 1);\n' +
'j;';
const code = 'while(true);';

const ctx = vm.createContext({
add: function(x, y) {
return x + y;
}
});
const ctx = vm.createContext();

vm.runInContext(code, ctx, { timeout: 1 });
} else {
Expand Down

0 comments on commit ff85483

Please sign in to comment.