From ed850806ef905e7202449d04c0bf093acc8445d9 Mon Sep 17 00:00:00 2001 From: kzc Date: Wed, 3 Jan 2018 13:27:36 -0500 Subject: [PATCH 1/3] [WIP] have test/compress tests also run reminified input if expect_stdout present --- test/run-tests.js | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/test/run-tests.js b/test/run-tests.js index e95bbb83..2fad74b3 100755 --- a/test/run-tests.js +++ b/test/run-tests.js @@ -205,6 +205,48 @@ function run_compress_tests() { failed_files[file] = 1; } } + // The test with expect_stdout passed. + // Now try to reminify original input with standard options + // to see if it matches expect_stdout. + var reminified_result = U.minify(test.input.print_to_string(), { + output: { + beautify: true, + }, + mangle: false, + compress: { + passes: 9, + toplevel: true, + global_defs: options.global_defs, + keep_fargs: options.keep_fargs, + keep_fnames: options.keep_fnames, + // keep_classnames: options.keep_classnames, // harmony + // probably other test affecting options have to be copied + }, + }); + if (reminified_result.error) { + log("!!! failed input reminify\n---INPUT---\n{input}\n--reminify error---\n{reminify_error}\n\n", { + input: input_formatted, + reminify_error: reminified_result.error, + }); + failures++; + failed_files[file] = 1; + } else { + stdout = sandbox.run_code(reminified_result.code); + if (!sandbox.same_stdout(test.expect_stdout, stdout)) { + log("!!! failed running reminified input\n---INPUT---\n{input}\n---reminified INPUT---\n{output}\n---EXPECTED {expected_type}---\n{expected}\n---ACTUAL {actual_type}---\n{actual}\n\n", { + input: input_formatted, + output: reminified_result.code, + expected_type: typeof test.expect_stdout == "string" ? "STDOUT" : "ERROR", + expected: test.expect_stdout, + actual_type: typeof stdout == "string" ? "STDOUT" : "ERROR", + actual: stdout, + }); + failures++; + failed_files[file] = 1; + } else { + //log("*** reminify passed: " + test.name); + } + } } } } From 17378e7642ebbc44481cfd189c2a52f967ae7776 Mon Sep 17 00:00:00 2001 From: kzc Date: Wed, 3 Jan 2018 15:40:11 -0500 Subject: [PATCH 2/3] output the correct reminify input in error message as well as options --- test/run-tests.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/run-tests.js b/test/run-tests.js index 2fad74b3..e1a408d0 100755 --- a/test/run-tests.js +++ b/test/run-tests.js @@ -208,7 +208,8 @@ function run_compress_tests() { // The test with expect_stdout passed. // Now try to reminify original input with standard options // to see if it matches expect_stdout. - var reminified_result = U.minify(test.input.print_to_string(), { + var reminify_input = test.input.print_to_string(); + var reminify_options = { output: { beautify: true, }, @@ -222,7 +223,9 @@ function run_compress_tests() { // keep_classnames: options.keep_classnames, // harmony // probably other test affecting options have to be copied }, - }); + }; + var reminify_options_json = JSON.stringify(JSON.parse(JSON.stringify(reminify_options)), null, 2); + var reminified_result = U.minify(reminify_input, reminify_options); if (reminified_result.error) { log("!!! failed input reminify\n---INPUT---\n{input}\n--reminify error---\n{reminify_error}\n\n", { input: input_formatted, @@ -233,8 +236,9 @@ function run_compress_tests() { } else { stdout = sandbox.run_code(reminified_result.code); if (!sandbox.same_stdout(test.expect_stdout, stdout)) { - log("!!! failed running reminified input\n---INPUT---\n{input}\n---reminified INPUT---\n{output}\n---EXPECTED {expected_type}---\n{expected}\n---ACTUAL {actual_type}---\n{actual}\n\n", { - input: input_formatted, + log("!!! failed running reminified input\n---INPUT---\n{input}\n---options---\n{options}\n---reminified INPUT---\n{output}\n---EXPECTED {expected_type}---\n{expected}\n---ACTUAL {actual_type}---\n{actual}\n\n", { + input: reminify_input, + options: reminify_options_json, output: reminified_result.code, expected_type: typeof test.expect_stdout == "string" ? "STDOUT" : "ERROR", expected: test.expect_stdout, From f8ae3c9cb368b790eb4e42f01ba933e3ae84968e Mon Sep 17 00:00:00 2001 From: kzc Date: Wed, 3 Jan 2018 16:15:03 -0500 Subject: [PATCH 3/3] use input_code for reminify_input --- test/run-tests.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/run-tests.js b/test/run-tests.js index e1a408d0..dad561c8 100755 --- a/test/run-tests.js +++ b/test/run-tests.js @@ -208,7 +208,7 @@ function run_compress_tests() { // The test with expect_stdout passed. // Now try to reminify original input with standard options // to see if it matches expect_stdout. - var reminify_input = test.input.print_to_string(); + var reminify_input = input_code; var reminify_options = { output: { beautify: true,