suppress false positives from fuzzer (#3638)
This commit is contained in:
@@ -1089,6 +1089,19 @@ function log(options) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fuzzy_match(original, uglified) {
|
||||||
|
original = original.split(" ", 5);
|
||||||
|
uglified = uglified.split(" ", 5);
|
||||||
|
for (var i = 0; i < 5; i++) {
|
||||||
|
if (original[i] === uglified[i]) continue;
|
||||||
|
var a = +original[i];
|
||||||
|
var b = +uglified[i];
|
||||||
|
if (Math.abs((b - a) / a) < 1e-10) continue;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
var fallback_options = [ JSON.stringify({
|
var fallback_options = [ JSON.stringify({
|
||||||
compress: false,
|
compress: false,
|
||||||
mangle: false
|
mangle: false
|
||||||
@@ -1111,8 +1124,12 @@ for (var round = 1; round <= num_iterations; round++) {
|
|||||||
uglify_code = uglify_code.code;
|
uglify_code = uglify_code.code;
|
||||||
uglify_result = sandbox.run_code(uglify_code, o.toplevel);
|
uglify_result = sandbox.run_code(uglify_code, o.toplevel);
|
||||||
ok = sandbox.same_stdout(original_result, uglify_result);
|
ok = sandbox.same_stdout(original_result, uglify_result);
|
||||||
if (!ok && o.compress.unsafe_math) {
|
if (!ok && typeof uglify_result == "string" && o.compress.unsafe_math) {
|
||||||
ok = sandbox.same_stdout(sandbox.run_code(original_code.replace(/( - 0\.1){3}/g, " - 0.3")), uglify_result, o.toplevel);
|
ok = fuzzy_match(original_result, uglify_result);
|
||||||
|
if (!ok) {
|
||||||
|
var fuzzy_result = sandbox.run_code(original_code.replace(/( - 0\.1){3}/g, " - 0.3"));
|
||||||
|
ok = sandbox.same_stdout(fuzzy_result, uglify_result, o.toplevel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
uglify_code = uglify_code.error;
|
uglify_code = uglify_code.error;
|
||||||
|
|||||||
@@ -12,17 +12,16 @@ function spawn(endTime) {
|
|||||||
], {
|
], {
|
||||||
stdio: [ "ignore", "pipe", "pipe" ]
|
stdio: [ "ignore", "pipe", "pipe" ]
|
||||||
}).on("exit", respawn);
|
}).on("exit", respawn);
|
||||||
var line = "";
|
var stdout = "";
|
||||||
child.stdout.on("data", function(data) {
|
child.stdout.on("data", function(data) {
|
||||||
line += data;
|
stdout += data;
|
||||||
});
|
});
|
||||||
child.stderr.once("data", function() {
|
var stderr = "";
|
||||||
process.exitCode = 1;
|
child.stderr.on("data", trap).pipe(process.stdout);
|
||||||
}).pipe(process.stdout);
|
|
||||||
var keepAlive = setInterval(function() {
|
var keepAlive = setInterval(function() {
|
||||||
var end = line.lastIndexOf("\r");
|
var end = stdout.lastIndexOf("\r");
|
||||||
console.log(line.slice(line.lastIndexOf("\r", end - 1) + 1, end));
|
console.log(stdout.slice(stdout.lastIndexOf("\r", end - 1) + 1, end));
|
||||||
line = line.slice(end + 1);
|
stdout = stdout.slice(end + 1);
|
||||||
}, ping);
|
}, ping);
|
||||||
var timer = setTimeout(function() {
|
var timer = setTimeout(function() {
|
||||||
clearInterval(keepAlive);
|
clearInterval(keepAlive);
|
||||||
@@ -31,9 +30,17 @@ function spawn(endTime) {
|
|||||||
}, endTime - Date.now());
|
}, endTime - Date.now());
|
||||||
|
|
||||||
function respawn() {
|
function respawn() {
|
||||||
console.log(line);
|
console.log(stdout.replace(/[^\r\n]*\r/g, ""));
|
||||||
clearInterval(keepAlive);
|
clearInterval(keepAlive);
|
||||||
clearTimeout(timer);
|
clearTimeout(timer);
|
||||||
spawn(endTime);
|
spawn(endTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function trap(data) {
|
||||||
|
stderr += data;
|
||||||
|
if (~stderr.indexOf("\nminify(options):\n")) {
|
||||||
|
process.exitCode = 1;
|
||||||
|
child.stderr.removeListener("data", trap);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user