make expect_stdout work on Node.js 0.12 (#1623)
That particular version of Node.js has messed up error messages, so provide a version-specific workaround. Also fixed an formatting issue which would cause `expect_stdout` to fail if error message contains excerpts of input. Apply `expect_stdout` to more applicable tests.
This commit is contained in:
@@ -11,6 +11,17 @@ var vm = require("vm");
|
||||
var tests_dir = path.dirname(module.filename);
|
||||
var failures = 0;
|
||||
var failed_files = {};
|
||||
var same_stdout = ~process.version.lastIndexOf("v0.12.", 0) ? function(expected, actual) {
|
||||
if (typeof expected != typeof actual) return false;
|
||||
if (typeof expected != "string") {
|
||||
if (expected.name != actual.name) return false;
|
||||
expected = expected.message.slice(expected.message.lastIndexOf("\n") + 1);
|
||||
actual = actual.message.slice(actual.message.lastIndexOf("\n") + 1);
|
||||
}
|
||||
return expected == actual;
|
||||
} : function(expected, actual) {
|
||||
return typeof expected == typeof actual && expected.toString() == actual.toString();
|
||||
};
|
||||
|
||||
run_compress_tests();
|
||||
if (failures) {
|
||||
@@ -172,7 +183,7 @@ function run_compress_tests() {
|
||||
}
|
||||
}
|
||||
if (test.expect_stdout) {
|
||||
var stdout = run_code(input_code);
|
||||
var stdout = run_code(make_code(input, output_options));
|
||||
if (test.expect_stdout === true) {
|
||||
test.expect_stdout = stdout;
|
||||
}
|
||||
@@ -336,7 +347,3 @@ function run_code(code) {
|
||||
process.stdout.write = original_write;
|
||||
}
|
||||
}
|
||||
|
||||
function same_stdout(expected, actual) {
|
||||
return typeof expected == typeof actual && expected.toString() == actual.toString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user