aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/compress.js2
-rw-r--r--test/ufuzz/index.js (renamed from test/ufuzz.js)9
-rw-r--r--test/ufuzz/job.js39
-rw-r--r--test/ufuzz/options.json (renamed from test/ufuzz.json)0
-rw-r--r--test/ufuzz/travis.js (renamed from test/travis-ufuzz.js)45
5 files changed, 48 insertions, 47 deletions
diff --git a/test/compress.js b/test/compress.js
index 7fdedd12..c2e747cd 100644
--- a/test/compress.js
+++ b/test/compress.js
@@ -9,7 +9,7 @@ var U = require("./node");
var file = process.argv[2];
var dir = path.resolve(path.dirname(module.filename), "compress");
if (file) {
- var minify_options = require("./ufuzz.json").map(JSON.stringify);
+ var minify_options = require("./ufuzz/options.json").map(JSON.stringify);
log("--- {file}", { file: file });
var tests = parse_test(path.resolve(dir, file));
process.exit(Object.keys(tests).filter(function(name) {
diff --git a/test/ufuzz.js b/test/ufuzz/index.js
index 86125477..8f86e49c 100644
--- a/test/ufuzz.js
+++ b/test/ufuzz/index.js
@@ -1,4 +1,3 @@
-// ufuzz.js
// derived from https://github.com/qfox/uglyfuzzer by Peter van der Zee
"use strict";
@@ -6,11 +5,11 @@
// bin/uglifyjs s.js -c && bin/uglifyjs s.js -c passes=3 && bin/uglifyjs s.js -c passes=3 -m
// cat s.js | node && node s.js && bin/uglifyjs s.js -c | node && bin/uglifyjs s.js -c passes=3 | node && bin/uglifyjs s.js -c passes=3 -m | node
-require("../tools/exit");
+require("../../tools/exit");
-var UglifyJS = require("..");
+var UglifyJS = require("../..");
var randomBytes = require("crypto").randomBytes;
-var sandbox = require("./sandbox");
+var sandbox = require("../sandbox");
var MAX_GENERATED_TOPLEVELS_PER_RUN = 1;
var MAX_GENERATION_RECURSION_DEPTH = 12;
@@ -1088,7 +1087,7 @@ var fallback_options = [ JSON.stringify({
compress: false,
mangle: false
}) ];
-var minify_options = require("./ufuzz.json").map(JSON.stringify);
+var minify_options = require("./options.json").map(JSON.stringify);
var original_code, original_result, errored;
var uglify_code, uglify_result, ok;
for (var round = 1; round <= num_iterations; round++) {
diff --git a/test/ufuzz/job.js b/test/ufuzz/job.js
new file mode 100644
index 00000000..921162f6
--- /dev/null
+++ b/test/ufuzz/job.js
@@ -0,0 +1,39 @@
+var child_process = require("child_process");
+
+var ping = 5 * 60 * 1000;
+var period = +process.argv[2];
+var endTime = Date.now() + period;
+for (var i = 0; i < 2; i++) spawn(endTime);
+
+function spawn(endTime) {
+ var child = child_process.spawn("node", [
+ "--max-old-space-size=2048",
+ "test/ufuzz"
+ ], {
+ stdio: [ "ignore", "pipe", "pipe" ]
+ }).on("exit", respawn);
+ var line = "";
+ child.stdout.on("data", function(data) {
+ line += data;
+ });
+ child.stderr.once("data", function() {
+ process.exitCode = 1;
+ }).pipe(process.stdout);
+ var keepAlive = setInterval(function() {
+ var end = line.lastIndexOf("\r");
+ console.log(line.slice(line.lastIndexOf("\r", end - 1) + 1, end));
+ line = line.slice(end + 1);
+ }, ping);
+ var timer = setTimeout(function() {
+ clearInterval(keepAlive);
+ child.removeListener("exit", respawn);
+ child.kill();
+ }, endTime - Date.now());
+
+ function respawn() {
+ console.log(line);
+ clearInterval(keepAlive);
+ clearTimeout(timer);
+ spawn(endTime);
+ }
+}
diff --git a/test/ufuzz.json b/test/ufuzz/options.json
index d20741a8..d20741a8 100644
--- a/test/ufuzz.json
+++ b/test/ufuzz/options.json
diff --git a/test/travis-ufuzz.js b/test/ufuzz/travis.js
index 22dcca93..0c1b8c7c 100644
--- a/test/travis-ufuzz.js
+++ b/test/ufuzz/travis.js
@@ -6,13 +6,9 @@ var url = require("url");
var period = 45 * 60 * 1000;
var wait = 2 * 60 * 1000;
-var ping = 5 * 60 * 1000;
-if (process.argv[2] == "run") {
- var endTime = Date.now() + period;
- for (var i = 0; i < 2; i++) spawn(endTime);
-} else if (process.argv.length > 2) {
+if (process.argv.length > 2) {
var token = process.argv[2];
- var branch = process.argv[3] || "v" + require("../package.json").version;
+ var branch = process.argv[3] || "v" + require("../../package.json").version;
var repository = encodeURIComponent(process.argv[4] || "mishoo/UglifyJS2");
var concurrency = process.argv[5] || 1;
var platform = process.argv[6] || "latest";
@@ -38,44 +34,11 @@ if (process.argv[2] == "run") {
config: {
cache: false,
env: "NODE=" + platform,
- script: "node test/travis-ufuzz run"
+ script: "node test/ufuzz/job " + period
}
}
}));
})();
} else {
- console.log("Usage: test/travis-ufuzz.js <token> [branch] [repository] [concurrency] [platform]");
-}
-
-function spawn(endTime) {
- var child = child_process.spawn("node", [
- "--max-old-space-size=2048",
- "test/ufuzz"
- ], {
- stdio: [ "ignore", "pipe", "pipe" ]
- }).on("exit", respawn);
- var line = "";
- child.stdout.on("data", function(data) {
- line += data;
- });
- child.stderr.on("data", function() {
- process.exitCode = 1;
- }).pipe(process.stdout);
- var keepAlive = setInterval(function() {
- var end = line.lastIndexOf("\r");
- console.log(line.slice(line.lastIndexOf("\r", end - 1) + 1, end));
- line = line.slice(end + 1);
- }, ping);
- var timer = setTimeout(function() {
- clearInterval(keepAlive);
- child.removeListener("exit", respawn);
- child.kill();
- }, endTime - Date.now());
-
- function respawn() {
- console.log(line);
- clearInterval(keepAlive);
- clearTimeout(timer);
- spawn(endTime);
- }
+ console.log("Usage: test/ufuzz/travis.js <token> [branch] [repository] [concurrency] [platform]");
}