aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-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
4 files changed, 16 insertions, 19 deletions
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",