[Pkg-javascript-commits] [uglifyjs] 440/491: enhance `test/ufuzz.js` (#2808)

Jonas Smedegaard dr at jones.dk
Wed Feb 14 19:52:02 UTC 2018


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag debian/3.3.10-1
in repository uglifyjs.

commit b335912e8690469044b89ccf93ac9dec11b273f7
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date:   Thu Jan 18 14:08:05 2018 +0800

    enhance `test/ufuzz.js` (#2808)
    
    - standalone test for `rename`
    - handle `keep_fargs` & `rename` upon failure
---
 test/ufuzz.js   | 24 ++++++++++++++++++++++--
 test/ufuzz.json |  3 ++-
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/test/ufuzz.js b/test/ufuzz.js
index d02e9f7..07b67a8 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 4057a35..f04b641 100644
--- a/test/ufuzz.json
+++ b/test/ufuzz.json
@@ -5,7 +5,8 @@
         "output": {
             "beautify": true,
             "bracketize": true
-        }
+        },
+        "rename": true
     },
     {
         "compress": false

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git



More information about the Pkg-javascript-commits mailing list