aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2018-01-16 17:33:21 +0800
committerGitHub <noreply@github.com>2018-01-16 17:33:21 +0800
commit7857354d85589aef285aac7c36c96fe4f7e2143e (patch)
tree580d95147f5500991b7352e325b3b6086a13d5e6 /test
parentb4aef753e7f65c0919c6c40b2b28d9f149bc81ed (diff)
downloadtracifyjs-7857354d85589aef285aac7c36c96fe4f7e2143e.tar.gz
tracifyjs-7857354d85589aef285aac7c36c96fe4f7e2143e.zip
improve `test/travis-ufuzz.js` (#2795)
- print usage - support concurrent jobs - improve instance utilisation - resume after V8 self-destruct
Diffstat (limited to 'test')
-rw-r--r--test/travis-ufuzz.js42
1 files changed, 28 insertions, 14 deletions
diff --git a/test/travis-ufuzz.js b/test/travis-ufuzz.js
index 579b7448..f84ed684 100644
--- a/test/travis-ufuzz.js
+++ b/test/travis-ufuzz.js
@@ -1,22 +1,29 @@
"use strict";
+var child_process = require("child_process");
+var https = require("https");
+var url = require("url");
+
var period = 45 * 60 * 1000;
var wait = 2 * 60 * 1000;
var ping = 5 * 60 * 1000;
-if (process.argv.length > 2) {
+if (process.argv[2] == "run") {
+ for (var i = 0; i < 2; i++) spawn();
+} else if (process.argv.length > 2) {
var token = process.argv[2];
var branch = process.argv[3] || "v" + require("../package.json").version;
- var project = encodeURIComponent(process.argv[4] || "mishoo/UglifyJS2");
- (function init() {
- setTimeout(init, period + wait);
- var options = require("url").parse("https://api.travis-ci.org/repo/" + project + "/requests");
+ var repository = encodeURIComponent(process.argv[4] || "mishoo/UglifyJS2");
+ var concurrency = process.argv[5] || 1;
+ (function request() {
+ setTimeout(request, (period + wait) / concurrency);
+ var options = url.parse("https://api.travis-ci.org/repo/" + repository + "/requests");
options.method = "POST";
options.headers = {
"Content-Type": "application/json",
"Travis-API-Version": 3,
"Authorization": "token " + token
};
- require("https").request(options, function(res) {
+ https.request(options, function(res) {
console.log("HTTP", res.statusCode);
console.log(JSON.stringify(res.headers, null, 2));
console.log();
@@ -31,22 +38,22 @@ if (process.argv.length > 2) {
language: "node_js",
node_js: "9",
sudo: false,
- script: "node test/travis-ufuzz"
+ script: "node test/travis-ufuzz run"
}
}
}));
})();
} else {
- var child = require("child_process").spawn("node", [
+ console.log("Usage: test/travis-ufuzz.js <token> [branch] [repository] [concurrency]");
+}
+
+function spawn() {
+ var child = child_process.spawn("node", [
"--max-old-space-size=2048",
"test/ufuzz"
], {
stdio: [ "ignore", "pipe", "pipe" ]
- }).on("exit", function() {
- console.log(line);
- clearInterval(keepAlive);
- clearTimeout(timer);
- });
+ }).on("exit", respawn);
var line = "";
child.stdout.on("data", function(data) {
line += data;
@@ -61,7 +68,14 @@ if (process.argv.length > 2) {
}, ping);
var timer = setTimeout(function() {
clearInterval(keepAlive);
- child.removeAllListeners("exit");
+ child.removeListener("exit", respawn);
child.kill();
}, period);
+
+ function respawn() {
+ console.log(line);
+ clearInterval(keepAlive);
+ clearTimeout(timer);
+ spawn();
+ }
}