aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2018-01-18 14:08:05 +0800
committerGitHub <noreply@github.com>2018-01-18 14:08:05 +0800
commitb335912e8690469044b89ccf93ac9dec11b273f7 (patch)
tree9e18611de4f2307f99b8b17b62dc01798f4b83b2
parentcc07f3b806f2a6ea971f290bd44425493f5c2e3d (diff)
downloadtracifyjs-b335912e8690469044b89ccf93ac9dec11b273f7.tar.gz
tracifyjs-b335912e8690469044b89ccf93ac9dec11b273f7.zip
enhance `test/ufuzz.js` (#2808)
- standalone test for `rename` - handle `keep_fargs` & `rename` upon failure
-rw-r--r--test/ufuzz.js24
-rw-r--r--test/ufuzz.json3
2 files changed, 24 insertions, 3 deletions
diff --git a/test/ufuzz.js b/test/ufuzz.js
index d02e9f76..07b67a87 100644
--- a/test/ufuzz.js
+++ b/test/ufuzz.js
@@ -998,10 +998,11 @@ function log_suspects(minify_options, component) {
if (typeof options != "object") options = {};
var defs = default_options[component];
var suspects = Object.keys(defs).filter(function(name) {
- if ((name in options ? options : defs)[name]) {
+ var flip = name == "keep_fargs";
+ if (flip ? name in options : (name in options ? options : defs)[name]) {
var m = JSON.parse(JSON.stringify(minify_options));
var o = JSON.parse(JSON.stringify(options));
- o[name] = false;
+ o[name] = flip;
m[component] = o;
var result = UglifyJS.minify(original_code, m);
if (result.error) {
@@ -1022,6 +1023,24 @@ function log_suspects(minify_options, component) {
}
}
+function log_rename(options) {
+ if (!options.rename) return;
+ var m = JSON.parse(JSON.stringify(minify_options));
+ m.rename = false;
+ var result = UglifyJS.minify(original_code, m);
+ if (result.error) {
+ errorln("Error testing options.rename");
+ errorln(result.error.stack);
+ } else {
+ var r = sandbox.run_code(result.code);
+ if (sandbox.same_stdout(original_result, r)) {
+ errorln("Suspicious options:");
+ errorln(" rename");
+ errorln();
+ }
+ }
+}
+
function log(options) {
if (!ok) errorln('\n\n\n\n\n\n!!!!!!!!!!\n\n\n');
errorln("//=============================================================");
@@ -1056,6 +1075,7 @@ function log(options) {
errorln();
if (!ok && typeof uglify_code == "string") {
Object.keys(default_options).forEach(log_suspects.bind(null, options));
+ log_rename(options);
errorln("!!!!!! Failed... round " + round);
}
}
diff --git a/test/ufuzz.json b/test/ufuzz.json
index 4057a351..f04b6417 100644
--- a/test/ufuzz.json
+++ b/test/ufuzz.json
@@ -5,7 +5,8 @@
"output": {
"beautify": true,
"bracketize": true
- }
+ },
+ "rename": true
},
{
"compress": false