[Pkg-javascript-commits] [uglifyjs] 10/49: Test reparsing test/compress/*.js output

Jonas Smedegaard dr at jones.dk
Fri Dec 9 11:43:25 UTC 2016


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

js pushed a commit to branch master
in repository uglifyjs.

commit 67cca43358cfcf7ff2e7c9e5532bc975fb2591d0
Author: kzc <zaxxon2011 at gmail.com>
Date:   Fri Jul 22 10:44:29 2016 -0400

    Test reparsing test/compress/*.js output
---
 test/run-tests.js | 42 ++++++++++++++++++++++++++++--------------
 1 file changed, 28 insertions(+), 14 deletions(-)

diff --git a/test/run-tests.js b/test/run-tests.js
index 0fdee6f..4063870 100755
--- a/test/run-tests.js
+++ b/test/run-tests.js
@@ -132,25 +132,39 @@ function run_compress_tests() {
                 failures++;
                 failed_files[file] = 1;
             }
-            else if (test.expect_warnings) {
-                U.AST_Node.warn_function = original_warn_function;
-                var expected_warnings = make_code(test.expect_warnings, {
-                    beautify: false,
-                    quote_style: 2, // force double quote to match JSON
-                });
-                warnings_emitted = warnings_emitted.map(function(input) {
-                  return input.split(process.cwd() + path.sep).join("").split(path.sep).join("/");
-                });
-                var actual_warnings = JSON.stringify(warnings_emitted);
-                if (expected_warnings != actual_warnings) {
-                    log("!!! failed\n---INPUT---\n{input}\n---EXPECTED WARNINGS---\n{expected_warnings}\n---ACTUAL WARNINGS---\n{actual_warnings}\n\n", {
+            else {
+                // expect == output
+                try {
+                    var reparsed_ast = U.parse(output);
+                } catch (ex) {
+                    log("!!! Test matched expected result but cannot parse output\n---INPUT---\n{input}\n---OUTPUT---\n{output}\n--REPARSE ERROR--\n{error}\n\n", {
                         input: input_code,
-                        expected_warnings: expected_warnings,
-                        actual_warnings: actual_warnings,
+                        output: output,
+                        error: ex.toString(),
                     });
                     failures++;
                     failed_files[file] = 1;
                 }
+                if (test.expect_warnings) {
+                    U.AST_Node.warn_function = original_warn_function;
+                    var expected_warnings = make_code(test.expect_warnings, {
+                        beautify: false,
+                        quote_style: 2, // force double quote to match JSON
+                    });
+                    warnings_emitted = warnings_emitted.map(function(input) {
+                      return input.split(process.cwd() + path.sep).join("").split(path.sep).join("/");
+                    });
+                    var actual_warnings = JSON.stringify(warnings_emitted);
+                    if (expected_warnings != actual_warnings) {
+                        log("!!! failed\n---INPUT---\n{input}\n---EXPECTED WARNINGS---\n{expected_warnings}\n---ACTUAL WARNINGS---\n{actual_warnings}\n\n", {
+                            input: input_code,
+                            expected_warnings: expected_warnings,
+                            actual_warnings: actual_warnings,
+                        });
+                        failures++;
+                        failed_files[file] = 1;
+                    }
+                }
             }
         }
         var tests = parse_test(path.resolve(dir, file));

-- 
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