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,6 +1324,7 @@ 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; break;
case 1: case 1:
var prop; var prop;
@@ -1330,6 +1332,7 @@ function createObjectFunction(recurmax, stmtDepth, canThrow) {
prop = getDotKey(); prop = getDotKey();
} while (name == prop); } while (name == prop);
async = false; 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; break;
default: default:
async = SUPPORT.async && rng(50) == 0; 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,11 +1952,16 @@ 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;
if (!ok && errored && is_error_timeout(original_result)) {
if (is_error_timeout(uglify_result)) {
// ignore difference in error message
ok = true;
} else {
// ignore spurious time-outs // ignore spurious time-outs
if (!ok && errored && /timed out/.test(original_result.message) && !/timed out/.test(uglify_result.message)) {
if (!orig_result[toplevel ? 3 : 2]) orig_result[toplevel ? 3 : 2] = sandbox.run_code(original_code, toplevel, 10000); 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); 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;
// ignore difference in error message caused by spread syntax // ignore difference in error message caused by spread syntax