var fs = require("fs");
var assert = require("assert");
var sandbox = require("./sandbox");
+var semver = require("semver");
var tests_dir = path.dirname(module.filename);
var failures = 0;
failed_files[file] = 1;
}
}
- if (test.expect_stdout) {
+ if (test.expect_stdout
+ && (!test.node_version || semver.satisfies(process.version, test.node_version))) {
var stdout = sandbox.run_code(input_code);
if (test.expect_stdout === true) {
test.expect_stdout = stdout;
if (node instanceof U.AST_LabeledStatement) {
var label = node.label;
assert.ok(
- ["input", "expect", "expect_exact", "expect_warnings", "expect_stdout"].indexOf(label.name) >= 0,
+ [
+ "input",
+ "expect",
+ "expect_exact",
+ "expect_warnings",
+ "expect_stdout",
+ "node_version",
+ ].indexOf(label.name) >= 0,
tmpl("Unsupported label {name} [{line},{col}]", {
name: label.name,
line: label.start.line,
})
);
var stat = node.body;
- if (label.name == "expect_exact") {
+ if (label.name == "expect_exact" || label.name == "node_version") {
test[label.name] = read_string(stat);
} else if (label.name == "expect_stdout") {
if (stat.TYPE == "SimpleStatement" && stat.body instanceof U.AST_Boolean) {
+var semver = require("semver");
var vm = require("vm");
function safe_log(arg, level) {
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;