enable reminify on harmony branch to avoid regressions (#2834)

- can skip known test failures with `reminify: false`
This commit is contained in:
kzc
2018-01-22 05:20:29 -05:00
committed by Alex Lam S.L
parent bc01a85ba0
commit bea9dbd812
4 changed files with 40 additions and 9 deletions

View File

@@ -75,6 +75,7 @@ issue_1664: {
} }
expect_stdout: "1" expect_stdout: "1"
node_version: ">=6" node_version: ">=6"
reminify: false // FIXME - block scoped function
} }
issue_1672_for: { issue_1672_for: {

View File

@@ -60,6 +60,7 @@ dead_code_2_should_warn: {
} }
expect_stdout: true expect_stdout: true
node_version: ">=6" node_version: ">=6"
reminify: false // FIXME - block scoped function
} }
dead_code_2_should_warn_strict: { dead_code_2_should_warn_strict: {
@@ -100,6 +101,7 @@ dead_code_2_should_warn_strict: {
} }
expect_stdout: true expect_stdout: true
node_version: ">=4" node_version: ">=4"
reminify: false // FIXME - block scoped function
} }
dead_code_constant_boolean_should_warn_more: { dead_code_constant_boolean_should_warn_more: {
@@ -135,6 +137,7 @@ dead_code_constant_boolean_should_warn_more: {
} }
expect_stdout: true expect_stdout: true
node_version: ">=6" node_version: ">=6"
reminify: false // FIXME - block scoped function
} }
dead_code_constant_boolean_should_warn_more_strict: { dead_code_constant_boolean_should_warn_more_strict: {
@@ -171,6 +174,7 @@ dead_code_constant_boolean_should_warn_more_strict: {
} }
expect_stdout: true expect_stdout: true
node_version: ">=4" node_version: ">=4"
reminify: false // FIXME - block scoped function
} }
dead_code_block_decls_die: { dead_code_block_decls_die: {

View File

@@ -79,6 +79,7 @@ same_variable_in_multiple_forOf: {
} }
} }
expect_stdout: true expect_stdout: true
reminify: false // FIXME - regression https://github.com/mishoo/UglifyJS2/issues/2835
} }
same_variable_in_multiple_forIn: { same_variable_in_multiple_forIn: {
@@ -120,6 +121,7 @@ same_variable_in_multiple_forIn: {
} }
} }
expect_stdout: true expect_stdout: true
reminify: false // FIXME - regression https://github.com/mishoo/UglifyJS2/issues/2835
} }
different_variable_in_multiple_for_loop: { different_variable_in_multiple_for_loop: {

View File

@@ -208,6 +208,9 @@ function run_compress_tests() {
}); });
return false; return false;
} }
if (test.reminify && !reminify(test.options, input_code, input_formatted, test.expect_stdout)) {
return false;
}
} }
return true; return true;
} }
@@ -261,6 +264,16 @@ function parse_test(file) {
})); }));
} }
function read_boolean(stat) {
if (stat.TYPE == "SimpleStatement") {
var body = stat.body;
if (body instanceof U.AST_Boolean) {
return body.value;
}
}
throw new Error("Should be boolean");
}
function read_string(stat) { function read_string(stat) {
if (stat.TYPE == "SimpleStatement") { if (stat.TYPE == "SimpleStatement") {
var body = stat.body; var body = stat.body;
@@ -279,7 +292,11 @@ function parse_test(file) {
} }
function get_one_test(name, block) { function get_one_test(name, block) {
var test = { name: name, options: {} }; var test = {
name: name,
options: {},
reminify: true,
};
var tw = new U.TreeWalker(function(node, descend){ var tw = new U.TreeWalker(function(node, descend){
if (node instanceof U.AST_Assign) { if (node instanceof U.AST_Assign) {
if (!(node.left instanceof U.AST_SymbolRef)) { if (!(node.left instanceof U.AST_SymbolRef)) {
@@ -299,6 +316,7 @@ function parse_test(file) {
"expect_warnings", "expect_warnings",
"expect_stdout", "expect_stdout",
"node_version", "node_version",
"reminify",
].indexOf(label.name) >= 0, ].indexOf(label.name) >= 0,
tmpl("Unsupported label {name} [{line},{col}]", { tmpl("Unsupported label {name} [{line},{col}]", {
name: label.name, name: label.name,
@@ -309,6 +327,9 @@ function parse_test(file) {
var stat = node.body; var stat = node.body;
if (label.name == "expect_exact" || label.name == "node_version") { if (label.name == "expect_exact" || label.name == "node_version") {
test[label.name] = read_string(stat); test[label.name] = read_string(stat);
} else if (label.name == "reminify") {
var value = read_boolean(stat);
test.reminify = value == null || value;
} else if (label.name == "expect_stdout") { } else if (label.name == "expect_stdout") {
var body = stat.body; var body = stat.body;
if (body instanceof U.AST_Boolean) { if (body instanceof U.AST_Boolean) {
@@ -358,14 +379,17 @@ function evaluate(code) {
function reminify(orig_options, input_code, input_formatted, expect_stdout) { function reminify(orig_options, input_code, input_formatted, expect_stdout) {
for (var i = 0; i < minify_options.length; i++) { for (var i = 0; i < minify_options.length; i++) {
var options = JSON.parse(minify_options[i]); var options = JSON.parse(minify_options[i]);
if (options.compress) [ options.keep_fnames = orig_options.keep_fnames;
"keep_fargs", options.keep_classnames = orig_options.keep_classnames;
"keep_fnames", if (orig_options.compress) {
].forEach(function(name) { options.compress.keep_classnames = orig_options.compress.keep_classnames;
if (name in orig_options) { options.compress.keep_fargs = orig_options.compress.keep_fargs;
options.compress[name] = orig_options[name]; options.compress.keep_fnames = orig_options.compress.keep_fnames;
} }
}); if (orig_options.mangle) {
options.mangle.keep_classnames = orig_options.mangle.keep_classnames;
options.mangle.keep_fnames = orig_options.mangle.keep_fnames;
}
var options_formatted = JSON.stringify(options, null, 4); var options_formatted = JSON.stringify(options, null, 4);
var result = U.minify(input_code, options); var result = U.minify(input_code, options);
if (result.error) { if (result.error) {