Commit 4c8ebdac authored by Johannes Bechberger's avatar Johannes Bechberger Committed by GitHub

Merge pull request #9 from mj3-16/fix-ast

Changed the ast flag to --print-ast and properly save pretty-printed input files
parents 11983076 eaae56f4
...@@ -106,7 +106,7 @@ class Environment: ...@@ -106,7 +106,7 @@ class Environment:
mode_flag = { mode_flag = {
TestMode.lexer: "--lextest", TestMode.lexer: "--lextest",
TestMode.syntax: "--parsetest", TestMode.syntax: "--parsetest",
TestMode.ast: "--pretty-print" TestMode.ast: "--print-ast"
}[mode] }[mode]
cmd = [self.mj_run_cmd, mode_flag] + list(args) cmd = [self.mj_run_cmd, mode_flag] + list(args)
return execute(cmd, timeout=self.timeout) return execute(cmd, timeout=self.timeout)
...@@ -117,4 +117,4 @@ class Environment: ...@@ -117,4 +117,4 @@ class Environment:
:return: (out, err, return code) :return: (out, err, return code)
""" """
return execute([cmd] + list(args), timeout=self.timeout) return execute([cmd] + list(args), timeout=self.timeout)
\ No newline at end of file
...@@ -85,8 +85,8 @@ class ASTPrettyPrintTest(BasicSyntaxTest): ...@@ -85,8 +85,8 @@ class ASTPrettyPrintTest(BasicSyntaxTest):
def _pretty_print(self, input_file: str, output_file: str) -> Tuple[int, str, str]: def _pretty_print(self, input_file: str, output_file: str) -> Tuple[int, str, str]:
out, err, rtcode = self.env.run_mj_command(TestMode.ast, input_file) out, err, rtcode = self.env.run_mj_command(TestMode.ast, input_file)
with open(output_file, "w") as f: with open(output_file, "wb") as f:
print(out, file=f) f.write(out)
return rtcode, out.decode(), err.decode() return rtcode, out.decode(), err.decode()
TestCase.TEST_CASE_CLASSES["ast"].append(ASTPrettyPrintTest) TestCase.TEST_CASE_CLASSES["ast"].append(ASTPrettyPrintTest)
\ No newline at end of file
...@@ -281,7 +281,7 @@ class BasicTestResult(TestResult): ...@@ -281,7 +281,7 @@ class BasicTestResult(TestResult):
incorrect_msg: str = "incorrect return code"): incorrect_msg: str = "incorrect return code"):
super().__init__(test_case, error_code) super().__init__(test_case, error_code)
self._incorrect_msg = incorrect_msg self._incorrect_msg = incorrect_msg
self._contains_error_str = "error" in error_output self._contains_error_str = error_output is not None and "error" in error_output
self.error_output = error_output self.error_output = error_output
self.output = output self.output = output
self.other_texts = [] # type: List[Tuple[str, str, bool]] self.other_texts = [] # type: List[Tuple[str, str, bool]]
...@@ -420,4 +420,4 @@ class LexerDiffTest(DiffTest): ...@@ -420,4 +420,4 @@ class LexerDiffTest(DiffTest):
TestCase.TEST_CASE_CLASSES[TestMode.lexer].append(LexerDiffTest) TestCase.TEST_CASE_CLASSES[TestMode.lexer].append(LexerDiffTest)
import mjtest.test.syntax_tests import mjtest.test.syntax_tests
import mjtest.test.ast_tests import mjtest.test.ast_tests
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment