Skip to content

Commit

Permalink
expand testing on Node.js versions (#3779)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlamsl committed Apr 14, 2020
1 parent 77261e1 commit c4d28e3
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 22 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ufuzz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bin/uglifyjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
15 changes: 8 additions & 7 deletions test/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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");
Expand Down
13 changes: 6 additions & 7 deletions test/jetstream.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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(" "));
Expand Down
4 changes: 2 additions & 2 deletions test/mocha/reduce.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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: {}",
] : [
Expand Down
3 changes: 0 additions & 3 deletions test/release/benchmark.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
setInterval(function() {
process.stderr.write("\0");
}, 8 * 60 * 1000).unref();
require("./run")([
"-b",
"-b braces",
Expand Down
2 changes: 1 addition & 1 deletion tools/exit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit c4d28e3

Please sign in to comment.