aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-04-14 03:13:42 +0100
committerGitHub <noreply@github.com>2020-04-14 10:13:42 +0800
commitc4d28e3b2a2d82c7e5e3b398513755b507a75e76 (patch)
tree955bed9c2cfb691ea84abf8476cc2dd0a507f907
parent77261e1ee037f3eea2d5ec80abb1387d4ba5c67e (diff)
downloadtracifyjs-c4d28e3b2a2d82c7e5e3b398513755b507a75e76.tar.gz
tracifyjs-c4d28e3b2a2d82c7e5e3b398513755b507a75e76.zip
expand testing on Node.js versions (#3779)
-rw-r--r--.github/workflows/ci.yml6
-rw-r--r--.github/workflows/ufuzz.yml1
-rwxr-xr-xbin/uglifyjs2
-rw-r--r--test/benchmark.js15
-rw-r--r--test/jetstream.js13
-rw-r--r--test/mocha/reduce.js4
-rw-r--r--test/release/benchmark.js3
-rw-r--r--tools/exit.js2
8 files changed, 24 insertions, 22 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 6b1d796c..76dea5b1 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 7a8c70c0..5e360f2b 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 2893d87b..4f84d387 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 63009dd8..ea044b26 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 e7c846e6..834f2575 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 fb3989dc..a6c8a752 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 a48bc42a..c4b10fbc 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 17048d8e..4dd7141b 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);
}