make expect_stdout node version specific (#1963)

... via semver string on `node_version` label.
This commit is contained in:
Alex Lam S.L
2017-05-18 11:28:35 +08:00
committed by GitHub
parent 6ed90913ca
commit efcf167e5e
4 changed files with 28 additions and 5 deletions

View File

@@ -1,3 +1,4 @@
var semver = require("semver");
var vm = require("vm");
function safe_log(arg, level) {
@@ -63,7 +64,7 @@ exports.run_code = function(code) {
process.stdout.write = original_write;
}
};
exports.same_stdout = ~process.version.lastIndexOf("v0.12.", 0) ? function(expected, actual) {
exports.same_stdout = semver.satisfies(process.version, "0.12") ? function(expected, actual) {
if (typeof expected != typeof actual) return false;
if (typeof expected != "string") {
if (expected.name != actual.name) return false;