aboutsummaryrefslogtreecommitdiff
path: root/test/run-tests.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-05-18 11:28:35 +0800
committerGitHub <noreply@github.com>2017-05-18 11:28:35 +0800
commitefcf167e5efc95a82678db2056396dcf94993641 (patch)
tree45bec5ba66ee834d539057dce26069f251fec858 /test/run-tests.js
parent6ed90913cae80e55b9575a64a59ef7b1bd06e702 (diff)
downloadtracifyjs-efcf167e5efc95a82678db2056396dcf94993641.tar.gz
tracifyjs-efcf167e5efc95a82678db2056396dcf94993641.zip
make `expect_stdout` node version specific (#1963)
... via semver string on `node_version` label.
Diffstat (limited to 'test/run-tests.js')
-rwxr-xr-xtest/run-tests.js15
1 files changed, 12 insertions, 3 deletions
diff --git a/test/run-tests.js b/test/run-tests.js
index edcd7cc9..8427d4a8 100755
--- a/test/run-tests.js
+++ b/test/run-tests.js
@@ -5,6 +5,7 @@ var path = require("path");
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;
@@ -164,7 +165,8 @@ function run_compress_tests() {
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;
@@ -274,7 +276,14 @@ function parse_test(file) {
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,
@@ -282,7 +291,7 @@ function parse_test(file) {
})
);
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) {