diff --git a/test/ufuzz/actions.js b/test/ufuzz/actions.js index 95e0a394..d473f74b 100644 --- a/test/ufuzz/actions.js +++ b/test/ufuzz/actions.js @@ -2,12 +2,14 @@ var get = require("https").get; var parse = require("url").parse; var base, token, run_number; +var expires = Date.now() + (5 * 60 + 55) * 60 * 1000; exports.init = function(url, auth, num) { base = url; token = auth; run_number = num; }; exports.should_stop = function(callback) { + if (Date.now() > expires) return callback(); read(base + "/actions/runs?per_page=100", function(reply) { var runs = verify(reply, "workflow_runs").sort(function(a, b) { return b.run_number - a.run_number; diff --git a/test/ufuzz/job.js b/test/ufuzz/job.js index 317894d1..5cef23e9 100644 --- a/test/ufuzz/job.js +++ b/test/ufuzz/job.js @@ -20,9 +20,13 @@ switch (process.argv.length) { var tasks = [ run(), run() ]; if (iterations) return; var alive = setInterval(function() { - actions.should_stop(stop); + actions.should_stop(function() { + clearInterval(alive); + tasks.forEach(function(kill) { + kill(); + }); + }); }, 8 * 60 * 1000); -var deadline = setTimeout(stop, (5 * 60 + 55) * 60 * 1000); function run() { var child, stdout, stderr, log; @@ -72,11 +76,3 @@ function run() { } } } - -function stop() { - clearInterval(alive); - clearInterval(deadline); - tasks.forEach(function(kill) { - kill(); - }); -}