suppress false positives in test/reduce (#5235)
This commit is contained in:
@@ -418,4 +418,20 @@ describe("test/reduce.js", function() {
|
|||||||
if (result.error) throw result.error;
|
if (result.error) throw result.error;
|
||||||
assert.deepEqual(result.warnings, []);
|
assert.deepEqual(result.warnings, []);
|
||||||
});
|
});
|
||||||
|
it("Should handle thrown falsy values gracefully", function() {
|
||||||
|
var code = [
|
||||||
|
"throw 0;",
|
||||||
|
"setTimeout(null, 42);",
|
||||||
|
].join("\n");
|
||||||
|
var result = reduce_test(code, {
|
||||||
|
mangle: false,
|
||||||
|
});
|
||||||
|
if (result.error) throw result.error;
|
||||||
|
assert.strictEqual(result.code, [
|
||||||
|
"// Can't reproduce test failure",
|
||||||
|
"// minify options: {",
|
||||||
|
'// "mangle": false',
|
||||||
|
"// }",
|
||||||
|
].join("\n"));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -146,7 +146,8 @@ function setup(global, builtins, setup_log, setup_tty) {
|
|||||||
delete ex[name];
|
delete ex[name];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
process.stderr.write(inspect(value) + "\n\n-----===== UNCAUGHT EXCEPTION =====-----\n\n");
|
var marker = "\n\n-----===== UNCAUGHT EXCEPTION =====-----\n\n";
|
||||||
|
process.stderr.write(marker + inspect(value) + marker);
|
||||||
throw ex;
|
throw ex;
|
||||||
}).on("unhandledRejection", function() {});
|
}).on("unhandledRejection", function() {});
|
||||||
}
|
}
|
||||||
@@ -284,18 +285,22 @@ function run_code_exec(code, toplevel, timeout) {
|
|||||||
return new Error("Script execution timed out.");
|
return new Error("Script execution timed out.");
|
||||||
}
|
}
|
||||||
if (result.error) return result.error;
|
if (result.error) return result.error;
|
||||||
var end = msg.indexOf("\n\n-----===== UNCAUGHT EXCEPTION =====-----\n\n");
|
var match = /\n([^:\s]*Error)(?:: ([\s\S]+?))?\n( at [\s\S]+)\n$/.exec(msg);
|
||||||
|
var marker = "\n\n-----===== UNCAUGHT EXCEPTION =====-----\n\n";
|
||||||
|
var start = msg.indexOf(marker) + marker.length;
|
||||||
|
var end = msg.indexOf(marker, start);
|
||||||
var details;
|
var details;
|
||||||
if (end >= 0) {
|
if (end >= 0) {
|
||||||
details = msg.slice(0, end).replace(/<([1-9][0-9]*) empty items?>/g, function(match, count) {
|
details = msg.slice(start, end).replace(/<([1-9][0-9]*) empty items?>/g, function(match, count) {
|
||||||
return new Array(+count).join();
|
return new Array(+count).join();
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
details = vm.runInNewContext("(" + details + ")");
|
details = vm.runInNewContext("(" + details + ")");
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
} else if (!match) {
|
||||||
|
new Error("Script execution aborted.");
|
||||||
}
|
}
|
||||||
var match = /\n([^:\s]*Error)(?:: ([\s\S]+?))?\n( at [\s\S]+)\n$/.exec(msg);
|
if (!match) return details;
|
||||||
if (!match) return details || new Error("Script execution aborted.");
|
|
||||||
var ex = new global[match[1]](match[2]);
|
var ex = new global[match[1]](match[2]);
|
||||||
ex.stack = ex.stack.slice(0, ex.stack.indexOf(" at ")) + match[3];
|
ex.stack = ex.stack.slice(0, ex.stack.indexOf(" at ")) + match[3];
|
||||||
if (typeof details == "object") {
|
if (typeof details == "object") {
|
||||||
|
|||||||
Reference in New Issue
Block a user