[Pkg-javascript-commits] [uglifyjs] 433/491: improve `test/travis-ufuzz.js` (#2795)

Jonas Smedegaard dr at jones.dk
Wed Feb 14 19:52:01 UTC 2018


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag debian/3.3.10-1
in repository uglifyjs.

commit 7857354d85589aef285aac7c36c96fe4f7e2143e
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date:   Tue Jan 16 17:33:21 2018 +0800

    improve `test/travis-ufuzz.js` (#2795)
    
    - print usage
    - support concurrent jobs
    - improve instance utilisation
    - resume after V8 self-destruct
---
 test/travis-ufuzz.js | 42 ++++++++++++++++++++++++++++--------------
 1 file changed, 28 insertions(+), 14 deletions(-)

diff --git a/test/travis-ufuzz.js b/test/travis-ufuzz.js
index 579b744..f84ed68 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();
+    }
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git



More information about the Pkg-javascript-commits mailing list