From 2b6657e96749989b55f0d98b00683016a1fccea1 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Mon, 15 Jan 2018 04:56:06 +0800 Subject: run `test/ufuzz.js` when Travis CI is idle (#2784) --- test/travis-ufuzz.js | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 test/travis-ufuzz.js diff --git a/test/travis-ufuzz.js b/test/travis-ufuzz.js new file mode 100644 index 00000000..2fbe3b00 --- /dev/null +++ b/test/travis-ufuzz.js @@ -0,0 +1,45 @@ +"use strict"; + +var period = 20 * 60 * 1000; +if (process.argv.length > 2) { + var token = process.argv[2]; + var branch = process.argv[3] || "v" + require("../package.json").version; + (function init() { + setTimeout(init, period); + var options = require("url").parse("https://api.travis-ci.org/repo/mishoo%2FUglifyJS2/requests"); + options.method = "POST"; + options.headers = { + "Content-Type": "application/json", + "Travis-API-Version": 3, + "Authorization": "token " + token + }; + require("https").request(options, function(res) { + console.log("HTTP", res.statusCode); + console.log(JSON.stringify(res.headers, null, 2)); + console.log(); + res.setEncoding("utf8"); + res.on("data", console.log); + }).on("error", console.error).end(JSON.stringify({ + request: { + message: "ufuzz testing (when idle)", + branch: branch, + config: { + merge_mode: "replace", + language: "node_js", + node_js: "9", + sudo: false, + script: "node test/travis-ufuzz" + } + } + })); + })(); +} else { + var child = require("child_process").spawn("node", [ "test/ufuzz" ], { + stdio: [ "ignore", "ignore", 1 ] + }); + var keepAlive = setInterval(console.log, 5 * 60 * 1000); + setTimeout(function() { + clearInterval(keepAlive); + child.kill(); + }, period); +} -- cgit v1.2.3