aboutsummaryrefslogtreecommitdiff
path: root/test/run-tests.js
diff options
context:
space:
mode:
authorkzc <zaxxon2011@gmail.com>2016-07-22 10:44:29 -0400
committerRichard van Velzen <rvanvelzen1@gmail.com>2016-08-14 21:27:23 +0200
commit67cca43358cfcf7ff2e7c9e5532bc975fb2591d0 (patch)
tree7db2c3138acdc1b3ee90e2712c35698d5949765b /test/run-tests.js
parent642273c29002e7676719f489d7fcf552974118f4 (diff)
downloadtracifyjs-67cca43358cfcf7ff2e7c9e5532bc975fb2591d0.tar.gz
tracifyjs-67cca43358cfcf7ff2e7c9e5532bc975fb2591d0.zip
Test reparsing test/compress/*.js output
Diffstat (limited to 'test/run-tests.js')
-rwxr-xr-xtest/run-tests.js42
1 files changed, 28 insertions, 14 deletions
diff --git a/test/run-tests.js b/test/run-tests.js
index 0fdee6f1..4063870a 100755
--- a/test/run-tests.js
+++ b/test/run-tests.js
@@ -132,25 +132,39 @@ function run_compress_tests() {
failures++;
failed_files[file] = 1;
}
- else if (test.expect_warnings) {
- U.AST_Node.warn_function = original_warn_function;
- var expected_warnings = make_code(test.expect_warnings, {
- beautify: false,
- quote_style: 2, // force double quote to match JSON
- });
- warnings_emitted = warnings_emitted.map(function(input) {
- return input.split(process.cwd() + path.sep).join("").split(path.sep).join("/");
- });
- var actual_warnings = JSON.stringify(warnings_emitted);
- if (expected_warnings != actual_warnings) {
- log("!!! failed\n---INPUT---\n{input}\n---EXPECTED WARNINGS---\n{expected_warnings}\n---ACTUAL WARNINGS---\n{actual_warnings}\n\n", {
+ else {
+ // expect == output
+ try {
+ var reparsed_ast = U.parse(output);
+ } catch (ex) {
+ log("!!! Test matched expected result but cannot parse output\n---INPUT---\n{input}\n---OUTPUT---\n{output}\n--REPARSE ERROR--\n{error}\n\n", {
input: input_code,
- expected_warnings: expected_warnings,
- actual_warnings: actual_warnings,
+ output: output,
+ error: ex.toString(),
});
failures++;
failed_files[file] = 1;
}
+ if (test.expect_warnings) {
+ U.AST_Node.warn_function = original_warn_function;
+ var expected_warnings = make_code(test.expect_warnings, {
+ beautify: false,
+ quote_style: 2, // force double quote to match JSON
+ });
+ warnings_emitted = warnings_emitted.map(function(input) {
+ return input.split(process.cwd() + path.sep).join("").split(path.sep).join("/");
+ });
+ var actual_warnings = JSON.stringify(warnings_emitted);
+ if (expected_warnings != actual_warnings) {
+ log("!!! failed\n---INPUT---\n{input}\n---EXPECTED WARNINGS---\n{expected_warnings}\n---ACTUAL WARNINGS---\n{actual_warnings}\n\n", {
+ input: input_code,
+ expected_warnings: expected_warnings,
+ actual_warnings: actual_warnings,
+ });
+ failures++;
+ failed_files[file] = 1;
+ }
+ }
}
}
var tests = parse_test(path.resolve(dir, file));