suppress false positives in ufuzz (#4574)

This commit is contained in:
Alex Lam S.L
2021-01-20 13:03:33 +00:00
committed by GitHub
parent 018e0350f8
commit bc7a88baea

View File

@@ -1311,10 +1311,11 @@ function createObjectFunction(recurmax, stmtDepth, canThrow) {
var save_async = async; var save_async = async;
var s; var s;
var name = createObjectKey(recurmax, stmtDepth, canThrow); var name = createObjectKey(recurmax, stmtDepth, canThrow);
createBlockVariables(recurmax, stmtDepth, canThrow, function(defns) { var fn;
switch (rng(SUPPORT.computed_key ? 3 : 2)) { switch (rng(SUPPORT.computed_key ? 3 : 2)) {
case 0: case 0:
async = false; async = false;
fn = function(defns) {
s = [ s = [
"get " + name + "(){", "get " + name + "(){",
strictMode(), strictMode(),
@@ -1323,13 +1324,15 @@ function createObjectFunction(recurmax, stmtDepth, canThrow) {
createStatement(recurmax, canThrow, CANNOT_BREAK, CANNOT_CONTINUE, CAN_RETURN, stmtDepth, STMT_RETURN_ETC), createStatement(recurmax, canThrow, CANNOT_BREAK, CANNOT_CONTINUE, CAN_RETURN, stmtDepth, STMT_RETURN_ETC),
"},", "},",
]; ];
break; };
case 1: break;
var prop; case 1:
do { var prop;
prop = getDotKey(); do {
} while (name == prop); prop = getDotKey();
async = false; } while (name == prop);
async = false;
fn = function(defns) {
s = [ s = [
"set " + name + "(" + createVarName(MANDATORY) + "){", "set " + name + "(" + createVarName(MANDATORY) + "){",
strictMode(), strictMode(),
@@ -1338,9 +1341,11 @@ function createObjectFunction(recurmax, stmtDepth, canThrow) {
"this." + prop + createAssignment() + _createBinaryExpr(recurmax, COMMA_OK, stmtDepth, canThrow) + ";", "this." + prop + createAssignment() + _createBinaryExpr(recurmax, COMMA_OK, stmtDepth, canThrow) + ";",
"},", "},",
]; ];
break; };
default: break;
async = SUPPORT.async && rng(50) == 0; default:
async = SUPPORT.async && rng(50) == 0;
fn = function(defns) {
s = [ s = [
(async ? "async " : "") + name + "(" + createParams(save_async, NO_DUPLICATE) + "){", (async ? "async " : "") + name + "(" + createParams(save_async, NO_DUPLICATE) + "){",
strictMode(), strictMode(),
@@ -1348,9 +1353,10 @@ function createObjectFunction(recurmax, stmtDepth, canThrow) {
_createStatements(3, recurmax, canThrow, CANNOT_BREAK, CANNOT_CONTINUE, CAN_RETURN, stmtDepth), _createStatements(3, recurmax, canThrow, CANNOT_BREAK, CANNOT_CONTINUE, CAN_RETURN, stmtDepth),
"},", "},",
] ]
break; };
} break;
}); }
createBlockVariables(recurmax, stmtDepth, canThrow, fn);
async = save_async; async = save_async;
VAR_NAMES.length = nameLenBefore; VAR_NAMES.length = nameLenBefore;
return filterDirective(s).join("\n"); return filterDirective(s).join("\n");
@@ -1787,6 +1793,10 @@ function fuzzy_match(original, uglified) {
} }
} }
function is_error_timeout(ex) {
return /timed out/.test(ex.message);
}
function is_error_in(ex) { function is_error_in(ex) {
return ex.name == "TypeError" && /'in'/.test(ex.message); return ex.name == "TypeError" && /'in'/.test(ex.message);
} }
@@ -1942,10 +1952,15 @@ for (var round = 1; round <= num_iterations; round++) {
} }
// ignore difference in error message caused by Temporal Dead Zone // ignore difference in error message caused by Temporal Dead Zone
if (!ok && errored && uglify_result.name == "ReferenceError" && original_result.name == "ReferenceError") ok = true; if (!ok && errored && uglify_result.name == "ReferenceError" && original_result.name == "ReferenceError") ok = true;
// ignore spurious time-outs if (!ok && errored && is_error_timeout(original_result)) {
if (!ok && errored && /timed out/.test(original_result.message) && !/timed out/.test(uglify_result.message)) { if (is_error_timeout(uglify_result)) {
if (!orig_result[toplevel ? 3 : 2]) orig_result[toplevel ? 3 : 2] = sandbox.run_code(original_code, toplevel, 10000); // ignore difference in error message
ok = sandbox.same_stdout(orig_result[toplevel ? 3 : 2], uglify_result); ok = true;
} else {
// ignore spurious time-outs
if (!orig_result[toplevel ? 3 : 2]) orig_result[toplevel ? 3 : 2] = sandbox.run_code(original_code, toplevel, 10000);
ok = sandbox.same_stdout(orig_result[toplevel ? 3 : 2], uglify_result);
}
} }
// ignore difference in error message caused by `in` // ignore difference in error message caused by `in`
if (!ok && errored && is_error_in(uglify_result) && is_error_in(original_result)) ok = true; if (!ok && errored && is_error_in(uglify_result) && is_error_in(original_result)) ok = true;