From 05909d045baedb022e5d2ef654641fd2ec6b116a Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Thu, 23 Feb 2017 18:18:48 -0800 Subject: [PATCH] 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: https://github.com/nodejs/node/issues/11261 PR-URL: https://github.com/nodejs/node/pull/11530 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Josh Gavant --- test/sequential/test-vm-timeout-rethrow.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/test/sequential/test-vm-timeout-rethrow.js b/test/sequential/test-vm-timeout-rethrow.js index f0f9c0b9c51063..7e148bd4d0b94f 100644 --- a/test/sequential/test-vm-timeout-rethrow.js +++ b/test/sequential/test-vm-timeout-rethrow.js @@ -5,15 +5,9 @@ var vm = require('vm'); var spawn = require('child_process').spawn; if (process.argv[2] === 'child') { - var code = 'var j = 0;\n' + - 'for (var i = 0; i < 1000000; i++) j += add(i, i + 1);\n' + - 'j;'; + const code = 'while(true);'; - var ctx = vm.createContext({ - add: function(x, y) { - return x + y; - } - }); + const ctx = vm.createContext(); vm.runInContext(code, ctx, { timeout: 1 }); } else {