expand testing on Node.js versions (#3779)

This commit is contained in:
Alex Lam S.L
2020-04-14 03:13:42 +01:00
committed by GitHub
parent 77261e1ee0
commit c4d28e3b2a
8 changed files with 24 additions and 22 deletions

View File

@@ -4,9 +4,12 @@ jobs:
test: test:
strategy: strategy:
matrix: 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 ] os: [ ubuntu-latest, windows-latest ]
script: [ compress, mocha, release/benchmark, release/jetstream ] script: [ compress, mocha, release/benchmark, release/jetstream ]
exclude:
- node: "0.8"
script: release/jetstream
name: ${{ matrix.node }} ${{ matrix.os }} ${{ matrix.script }} name: ${{ matrix.node }} ${{ matrix.os }} ${{ matrix.script }}
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
env: env:
@@ -33,6 +36,7 @@ jobs:
npm config set audit false npm config set audit false
npm config set optional false npm config set optional false
npm config set save false npm config set save false
npm config set strict-ssl false
npm config set update-notifier false npm config set update-notifier false
npm --version npm --version
while !(npm install); do echo "'npm install' failed - retrying..."; done while !(npm install); do echo "'npm install' failed - retrying..."; done

View File

@@ -27,6 +27,7 @@ jobs:
npm config set audit false npm config set audit false
npm config set optional false npm config set optional false
npm config set save false npm config set save false
npm config set strict-ssl false
npm config set update-notifier false npm config set update-notifier false
npm --version npm --version
while !(npm install); do echo "'npm install' failed - retrying..."; done while !(npm install); do echo "'npm install' failed - retrying..."; done

View File

@@ -337,7 +337,7 @@ function simple_glob(glob) {
.replace(/\?/g, "[^/\\\\]") + "$"; .replace(/\?/g, "[^/\\\\]") + "$";
var mod = process.platform === "win32" ? "i" : ""; var mod = process.platform === "win32" ? "i" : "";
var rx = new RegExp(pattern, mod); var rx = new RegExp(pattern, mod);
var results = entries.filter(function(name) { var results = entries.sort().filter(function(name) {
return rx.test(name); return rx.test(name);
}).map(function(name) { }).map(function(name) {
return path.join(dir, name); return path.join(dir, name);

View File

@@ -5,12 +5,11 @@
var createHash = require("crypto").createHash; var createHash = require("crypto").createHash;
var fetch = require("./fetch"); var fetch = require("./fetch");
var fork = require("child_process").fork; var spawn = require("child_process").spawn;
var zlib = require("zlib"); var zlib = require("zlib");
var args = process.argv.slice(2); var args = process.argv.slice(2);
if (!args.length) { args.unshift("bin/uglifyjs");
args.push("-mc"); if (!args.length) args.push("-mc");
}
args.push("--timings"); args.push("--timings");
var urls = [ var urls = [
"https://code.jquery.com/jquery-3.4.1.js", "https://code.jquery.com/jquery-3.4.1.js",
@@ -70,18 +69,20 @@ urls.forEach(function(url) {
}; };
fetch(url, function(err, res) { fetch(url, function(err, res) {
if (err) throw err; 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) { res.on("data", function(data) {
results[url].input += data.length; results[url].input += data.length;
}).pipe(uglifyjs.stdin); }).pipe(uglifyjs.stdin);
var sha1 = createHash("sha1");
uglifyjs.stdout.on("data", function(data) { uglifyjs.stdout.on("data", function(data) {
results[url].output += data.length; results[url].output += data.length;
}).pipe(zlib.createGzip({ }).pipe(zlib.createGzip({
level: zlib.Z_BEST_COMPRESSION level: zlib.Z_BEST_COMPRESSION
})).on("data", function(data) { })).on("data", function(data) {
results[url].gzip += data.length; results[url].gzip += data.length;
}).pipe(createHash("sha1")).on("data", function(data) { sha1.update(data);
results[url].sha1 = data.toString("hex"); }).on("end", function() {
results[url].sha1 = sha1.digest("hex");
done(); done();
}); });
uglifyjs.stderr.setEncoding("utf8"); uglifyjs.stderr.setEncoding("utf8");

View File

@@ -8,15 +8,14 @@ if (typeof phantom == "undefined") {
require("../tools/exit"); require("../tools/exit");
var args = process.argv.slice(2); var args = process.argv.slice(2);
var debug = args.indexOf("--debug"); var debug = args.indexOf("--debug");
if (debug >= 0) { if (debug < 0) {
debug = false;
} else {
args.splice(debug, 1); args.splice(debug, 1);
debug = true; 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"); args.push("--timings");
var child_process = require("child_process"); var child_process = require("child_process");
var fetch = require("./fetch"); var fetch = require("./fetch");
@@ -39,7 +38,7 @@ if (typeof phantom == "undefined") {
}); });
if (/\.js$/.test(url)) { if (/\.js$/.test(url)) {
var stderr = ""; var stderr = "";
var uglifyjs = child_process.fork("bin/uglifyjs", args, { var uglifyjs = child_process.spawn(process.argv[0], args, {
silent: true silent: true
}).on("exit", function(code) { }).on("exit", function(code) {
console.log("uglifyjs", url.slice(site.length + 1), args.join(" ")); console.log("uglifyjs", url.slice(site.length + 1), args.join(" "));

View File

@@ -186,7 +186,7 @@ describe("test/reduce.js", function() {
].join("\n")); ].join("\n"));
}); });
it("Should reduce infinite loops with reasonable performance", function() { 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); this.timeout(120000);
var result = reduce_test("while (/9/.test(1 - .8));", { var result = reduce_test("while (/9/.test(1 - .8));", {
compress: { compress: {
@@ -211,7 +211,7 @@ describe("test/reduce.js", function() {
it("Should ignore difference in Error.message", function() { it("Should ignore difference in Error.message", function() {
var result = reduce_test("null[function() {\n}];"); var result = reduce_test("null[function() {\n}];");
if (result.error) throw result.error; 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", "// Can't reproduce test failure",
"// minify options: {}", "// minify options: {}",
] : [ ] : [

View File

@@ -1,6 +1,3 @@
setInterval(function() {
process.stderr.write("\0");
}, 8 * 60 * 1000).unref();
require("./run")([ require("./run")([
"-b", "-b",
"-b braces", "-b braces",

View File

@@ -5,7 +5,7 @@ process.exit = function() {
process.once("uncaughtException", function() { process.once("uncaughtException", function() {
(function callback() { (function callback() {
if (process.stdout.bufferSize || process.stderr.bufferSize) { if (process.stdout.bufferSize || process.stderr.bufferSize) {
setImmediate(callback); setTimeout(callback, 1);
} else { } else {
exit.apply(process, args); exit.apply(process, args);
} }