From 247d48788582084152acbc62eb2eede3fa1fbc1e Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Thu, 23 Feb 2017 18:18:48 -0800 Subject: [PATCH 1/3] test: Fix flaky test-vm-timeout-rethrow 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 --- test/sequential/test-vm-timeout-rethrow.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sequential/test-vm-timeout-rethrow.js b/test/sequential/test-vm-timeout-rethrow.js index a434e2ae3e6978..2e0712d4b2d0f0 100644 --- a/test/sequential/test-vm-timeout-rethrow.js +++ b/test/sequential/test-vm-timeout-rethrow.js @@ -6,7 +6,7 @@ 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' + + 'while(true);\n' + 'j;'; const ctx = vm.createContext({ From b0907c02d1fb8d642b91eaa832b4f24c979462b3 Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Thu, 23 Feb 2017 18:30:15 -0800 Subject: [PATCH 2/3] test: Removed unnecessary function --- test/sequential/test-vm-timeout-rethrow.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/test/sequential/test-vm-timeout-rethrow.js b/test/sequential/test-vm-timeout-rethrow.js index 2e0712d4b2d0f0..ee0427e29b2b2e 100644 --- a/test/sequential/test-vm-timeout-rethrow.js +++ b/test/sequential/test-vm-timeout-rethrow.js @@ -9,11 +9,7 @@ if (process.argv[2] === 'child') { 'while(true);\n' + 'j;'; - const ctx = vm.createContext({ - add: function(x, y) { - return x + y; - } - }); + const ctx = vm.createContext(); vm.runInContext(code, ctx, { timeout: 1 }); } else { From f1a5b6348ee651c8bee19d52fe5bed444f144081 Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Fri, 24 Feb 2017 12:09:46 -0800 Subject: [PATCH 3/3] test: More refactoring --- test/sequential/test-vm-timeout-rethrow.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/sequential/test-vm-timeout-rethrow.js b/test/sequential/test-vm-timeout-rethrow.js index ee0427e29b2b2e..54ffee1ff976f5 100644 --- a/test/sequential/test-vm-timeout-rethrow.js +++ b/test/sequential/test-vm-timeout-rethrow.js @@ -5,9 +5,7 @@ const vm = require('vm'); const spawn = require('child_process').spawn; if (process.argv[2] === 'child') { - const code = 'let j = 0;\n' + - 'while(true);\n' + - 'j;'; + const code = 'while(true);'; const ctx = vm.createContext();