aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2018-04-26 17:44:37 +0800
committerGitHub <noreply@github.com>2018-04-26 17:44:37 +0800
commit69fc7ca8da1ac26a66cb1b7689ddbd901bda2120 (patch)
tree6fe9c529dde0379adab4eb11ecaf1e5af25375c9
parent0a79496e0a2b0fb7739fc757e4e33d652694a6b5 (diff)
downloadtracifyjs-69fc7ca8da1ac26a66cb1b7689ddbd901bda2120.tar.gz
tracifyjs-69fc7ca8da1ac26a66cb1b7689ddbd901bda2120.zip
workaround test failures in Node.js 10 (#3102)
-rw-r--r--test/mocha/cli.js10
-rwxr-xr-xtest/run-tests.js11
2 files changed, 14 insertions, 7 deletions
diff --git a/test/mocha/cli.js b/test/mocha/cli.js
index 8c858bd9..3b3dcab1 100644
--- a/test/mocha/cli.js
+++ b/test/mocha/cli.js
@@ -100,8 +100,8 @@ describe("bin/uglifyjs", function () {
exec(command, function (err, stdout, stderr) {
if (err) throw err;
- var stderrLines = stderr.split('\n');
- assert.strictEqual(stderrLines[0], 'INFO: Using input source map: test/input/issue-2082/sample.js.map');
+ var stderrLines = stderr.split("\n");
+ assert.strictEqual(stderrLines[0], "INFO: Using input source map: test/input/issue-2082/sample.js.map");
assert.notStrictEqual(stderrLines[1], 'INFO: Using input source map: {"version": 3,"sources": ["index.js"],"mappings": ";"}');
done();
});
@@ -244,7 +244,8 @@ describe("bin/uglifyjs", function () {
"//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QvaW5wdXQvaXNzdWUtMTMyMy9zYW1wbGUuanMiXSwibmFtZXMiOlsiYmFyIiwiZm9vIl0sIm1hcHBpbmdzIjoiQUFBQSxJQUFJQSxJQUFNLFdBQ04sU0FBU0MsSUFBS0QsS0FDVixPQUFPQSxJQUdYLE9BQU9DLElBTEQifQ==",
"",
].join("\n"));
- assert.strictEqual(stderr, "WARN: inline source map not found: test/input/issue-1323/sample.js\n");
+ var stderrLines = stderr.split("\n");
+ assert.strictEqual(stderrLines[0], "WARN: inline source map not found: test/input/issue-1323/sample.js");
done();
});
});
@@ -264,7 +265,8 @@ describe("bin/uglifyjs", function () {
"//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0ZGluIiwidGVzdC9pbnB1dC9pc3N1ZS0xMzIzL3NhbXBsZS5qcyJdLCJuYW1lcyI6WyJGb28iLCJjb25zb2xlIiwibG9nIiwiYmFyIiwiZm9vIl0sIm1hcHBpbmdzIjoiQUFBQSxJQUFNQSxJQUFJLFNBQUFBLE1BQWdCQyxRQUFRQyxJQUFJLEVBQUUsSUFBTyxJQUFJRixJQ0FuRCxJQUFJRyxJQUFNLFdBQ04sU0FBU0MsSUFBS0QsS0FDVixPQUFPQSxJQUdYLE9BQU9DLElBTEQifQ==",
"",
].join("\n"));
- assert.strictEqual(stderr, "WARN: inline source map not found: test/input/issue-1323/sample.js\n");
+ var stderrLines = stderr.split("\n");
+ assert.strictEqual(stderrLines[0], "WARN: inline source map not found: test/input/issue-1323/sample.js");
done();
});
});
diff --git a/test/run-tests.js b/test/run-tests.js
index 3ed28df5..b31c33bc 100755
--- a/test/run-tests.js
+++ b/test/run-tests.js
@@ -172,7 +172,7 @@ function run_compress_tests() {
}
if (test.expect_stdout
&& (!test.node_version || semver.satisfies(process.version, test.node_version))) {
- var stdout = sandbox.run_code(input_code, true);
+ var stdout = run_code(input_code);
if (test.expect_stdout === true) {
test.expect_stdout = stdout;
}
@@ -186,7 +186,7 @@ function run_compress_tests() {
});
return false;
}
- stdout = sandbox.run_code(output, true);
+ stdout = run_code(output);
if (!sandbox.same_stdout(test.expect_stdout, stdout)) {
log("!!! failed\n---INPUT---\n{input}\n---EXPECTED {expected_type}---\n{expected}\n---ACTUAL {actual_type}---\n{actual}\n\n", {
input: input_formatted,
@@ -344,6 +344,11 @@ function evaluate(code) {
return new Function("return(" + code + ")")();
}
+function run_code(code) {
+ var result = sandbox.run_code(code, true);
+ return typeof result == "string" ? result.replace(/\u001b\[\d+m/g, "") : result;
+}
+
// Try to reminify original input with standard options
// to see if it matches expect_stdout.
function reminify(orig_options, input_code, input_formatted, expect_stdout) {
@@ -367,7 +372,7 @@ function reminify(orig_options, input_code, input_formatted, expect_stdout) {
});
return false;
} else {
- var stdout = sandbox.run_code(result.code, true);
+ var stdout = run_code(result.code);
if (typeof expect_stdout != "string" && typeof stdout != "string" && expect_stdout.name == stdout.name) {
stdout = expect_stdout;
}