From c4d28e3b2a2d82c7e5e3b398513755b507a75e76 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Tue, 14 Apr 2020 03:13:42 +0100 Subject: [PATCH] expand testing on Node.js versions (#3779) --- .github/workflows/ci.yml | 6 +++++- .github/workflows/ufuzz.yml | 1 + bin/uglifyjs | 2 +- test/benchmark.js | 15 ++++++++------- test/jetstream.js | 13 ++++++------- test/mocha/reduce.js | 4 ++-- test/release/benchmark.js | 3 --- tools/exit.js | 2 +- 8 files changed, 24 insertions(+), 22 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6b1d796c62f..76dea5b1f83 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,9 +4,12 @@ jobs: test: strategy: matrix: - node: [ "0.10", "0.12", "4", "6", "8", "10", latest ] + node: [ "0.8", "0.10", "0.12", "4", "6", "8", "10", "12", latest ] os: [ ubuntu-latest, windows-latest ] script: [ compress, mocha, release/benchmark, release/jetstream ] + exclude: + - node: "0.8" + script: release/jetstream name: ${{ matrix.node }} ${{ matrix.os }} ${{ matrix.script }} runs-on: ${{ matrix.os }} env: @@ -33,6 +36,7 @@ jobs: npm config set audit false npm config set optional false npm config set save false + npm config set strict-ssl false npm config set update-notifier false npm --version while !(npm install); do echo "'npm install' failed - retrying..."; done diff --git a/.github/workflows/ufuzz.yml b/.github/workflows/ufuzz.yml index 7a8c70c0054..5e360f2b5ca 100644 --- a/.github/workflows/ufuzz.yml +++ b/.github/workflows/ufuzz.yml @@ -27,6 +27,7 @@ jobs: npm config set audit false npm config set optional false npm config set save false + npm config set strict-ssl false npm config set update-notifier false npm --version while !(npm install); do echo "'npm install' failed - retrying..."; done diff --git a/bin/uglifyjs b/bin/uglifyjs index 2893d87b917..4f84d387b90 100755 --- a/bin/uglifyjs +++ b/bin/uglifyjs @@ -337,7 +337,7 @@ function simple_glob(glob) { .replace(/\?/g, "[^/\\\\]") + "$"; var mod = process.platform === "win32" ? "i" : ""; var rx = new RegExp(pattern, mod); - var results = entries.filter(function(name) { + var results = entries.sort().filter(function(name) { return rx.test(name); }).map(function(name) { return path.join(dir, name); diff --git a/test/benchmark.js b/test/benchmark.js index 63009dd8122..ea044b26afe 100644 --- a/test/benchmark.js +++ b/test/benchmark.js @@ -5,12 +5,11 @@ var createHash = require("crypto").createHash; var fetch = require("./fetch"); -var fork = require("child_process").fork; +var spawn = require("child_process").spawn; var zlib = require("zlib"); var args = process.argv.slice(2); -if (!args.length) { - args.push("-mc"); -} +args.unshift("bin/uglifyjs"); +if (!args.length) args.push("-mc"); args.push("--timings"); var urls = [ "https://code.jquery.com/jquery-3.4.1.js", @@ -70,18 +69,20 @@ urls.forEach(function(url) { }; fetch(url, function(err, res) { if (err) throw err; - var uglifyjs = fork("bin/uglifyjs", args, { silent: true }); + var uglifyjs = spawn(process.argv[0], args, { silent: true }); res.on("data", function(data) { results[url].input += data.length; }).pipe(uglifyjs.stdin); + var sha1 = createHash("sha1"); uglifyjs.stdout.on("data", function(data) { results[url].output += data.length; }).pipe(zlib.createGzip({ level: zlib.Z_BEST_COMPRESSION })).on("data", function(data) { results[url].gzip += data.length; - }).pipe(createHash("sha1")).on("data", function(data) { - results[url].sha1 = data.toString("hex"); + sha1.update(data); + }).on("end", function() { + results[url].sha1 = sha1.digest("hex"); done(); }); uglifyjs.stderr.setEncoding("utf8"); diff --git a/test/jetstream.js b/test/jetstream.js index e7c846e68ad..834f2575052 100644 --- a/test/jetstream.js +++ b/test/jetstream.js @@ -8,15 +8,14 @@ if (typeof phantom == "undefined") { require("../tools/exit"); var args = process.argv.slice(2); var debug = args.indexOf("--debug"); - if (debug >= 0) { + if (debug < 0) { + debug = false; + } else { args.splice(debug, 1); debug = true; - } else { - debug = false; - } - if (!args.length) { - args.push("-mcb", "beautify=false,webkit"); } + args.unshift("bin/uglifyjs"); + if (!args.length) args.push("-mcb", "beautify=false,webkit"); args.push("--timings"); var child_process = require("child_process"); var fetch = require("./fetch"); @@ -39,7 +38,7 @@ if (typeof phantom == "undefined") { }); if (/\.js$/.test(url)) { var stderr = ""; - var uglifyjs = child_process.fork("bin/uglifyjs", args, { + var uglifyjs = child_process.spawn(process.argv[0], args, { silent: true }).on("exit", function(code) { console.log("uglifyjs", url.slice(site.length + 1), args.join(" ")); diff --git a/test/mocha/reduce.js b/test/mocha/reduce.js index fb3989dc688..a6c8a75211c 100644 --- a/test/mocha/reduce.js +++ b/test/mocha/reduce.js @@ -186,7 +186,7 @@ describe("test/reduce.js", function() { ].join("\n")); }); it("Should reduce infinite loops with reasonable performance", function() { - if (semver.satisfies(process.version, "0.10")) return; + if (semver.satisfies(process.version, "<=0.10")) return; this.timeout(120000); var result = reduce_test("while (/9/.test(1 - .8));", { compress: { @@ -211,7 +211,7 @@ describe("test/reduce.js", function() { it("Should ignore difference in Error.message", function() { var result = reduce_test("null[function() {\n}];"); if (result.error) throw result.error; - assert.strictEqual(result.code, (semver.satisfies(process.version, "0.10") ? [ + assert.strictEqual(result.code, (semver.satisfies(process.version, "<=0.10") ? [ "// Can't reproduce test failure", "// minify options: {}", ] : [ diff --git a/test/release/benchmark.js b/test/release/benchmark.js index a48bc42ab58..c4b10fbcc04 100644 --- a/test/release/benchmark.js +++ b/test/release/benchmark.js @@ -1,6 +1,3 @@ -setInterval(function() { - process.stderr.write("\0"); -}, 8 * 60 * 1000).unref(); require("./run")([ "-b", "-b braces", diff --git a/tools/exit.js b/tools/exit.js index 17048d8ef34..4dd7141b241 100644 --- a/tools/exit.js +++ b/tools/exit.js @@ -5,7 +5,7 @@ process.exit = function() { process.once("uncaughtException", function() { (function callback() { if (process.stdout.bufferSize || process.stderr.bufferSize) { - setImmediate(callback); + setTimeout(callback, 1); } else { exit.apply(process, args); }