diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2018-01-15 04:56:06 +0800 |
---|---|---|
committer | alexlamsl <alexlamsl@gmail.com> | 2018-01-15 08:52:11 +0800 |
commit | 2b6657e96749989b55f0d98b00683016a1fccea1 (patch) | |
tree | 3c1dc51a5b1f438ea77a3a6378f9688c2bccb812 /test/travis-ufuzz.js | |
parent | 7c0c92943f08e89118ed32019c014a44192f9dfc (diff) | |
download | tracifyjs-2b6657e96749989b55f0d98b00683016a1fccea1.tar.gz tracifyjs-2b6657e96749989b55f0d98b00683016a1fccea1.zip |
run `test/ufuzz.js` when Travis CI is idle (#2784)
Diffstat (limited to 'test/travis-ufuzz.js')
-rw-r--r-- | test/travis-ufuzz.js | 45 |
1 files changed, 45 insertions, 0 deletions
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); +} |