Commit 28d4296d authored by Johannes Bechberger's avatar Johannes Bechberger

Improve mjtest and move one test case

parent 9400fe7d
...@@ -112,8 +112,8 @@ class Environment: ...@@ -112,8 +112,8 @@ class Environment:
self._pid_tmpdirs = {} # type: Dict[int, str] self._pid_tmpdirs = {} # type: Dict[int, str]
self.only_small_exec_tests = not all_exec_tests self.only_small_exec_tests = not all_exec_tests
self.timeout = float(os.getenv("MJ_TIMEOUT", "5")) self.timeout = float(os.getenv("MJ_TIMEOUT", "10"))
self.big_timeout = float(os.getenv("MJ_BIG_TIMEOUT", "30")) self.big_timeout = float(os.getenv("MJ_BIG_TIMEOUT", "60"))
def create_tmpfile(self) -> str: def create_tmpfile(self) -> str:
self._tmp_file_ctr += 1 self._tmp_file_ctr += 1
......
...@@ -63,14 +63,14 @@ class JavaExecTest(BasicSyntaxTest): ...@@ -63,14 +63,14 @@ class JavaExecTest(BasicSyntaxTest):
test_result.add_file("Source file", self.preprocessed_file) test_result.add_file("Source file", self.preprocessed_file)
os.chdir(cwd) os.chdir(cwd)
return test_result return test_result
main_class = get_main_class_name(base_filename + ".java", timeout=timeout) main_class = get_main_class_name(base_filename + ".java")
if not main_class: if not main_class:
_LOG.debug("Can't find a main class, using the file name instead") _LOG.debug("Can't find a main class, using the file name instead")
main_class = base_filename main_class = base_filename
exp_out, err, java_rtcode = \ exp_out, err, java_rtcode = \
self.env.run_command("java", get_main_class_name(base_filename + ".java"), timeout=timeout) self.env.run_command("java", get_main_class_name(base_filename + ".java"), timeout=timeout)
test_result.add_long_text("Java output: ", exp_out.decode())
if javac_rtcode != 0: if javac_rtcode != 0:
test_result.add_long_text("Java output: ", exp_out.decode())
test_result.incorrect_msg = "java runtime error" test_result.incorrect_msg = "java runtime error"
test_result.set_error_code(java_rtcode) test_result.set_error_code(java_rtcode)
test_result.add_long_text("Java error message", err.decode()) test_result.add_long_text("Java error message", err.decode())
...@@ -88,8 +88,7 @@ class JavaExecTest(BasicSyntaxTest): ...@@ -88,8 +88,7 @@ class JavaExecTest(BasicSyntaxTest):
if self._has_expected_output_file and self.type == self.MODE and self.env.mode == self.MODE: if self._has_expected_output_file and self.type == self.MODE and self.env.mode == self.MODE:
with open(self._expected_output_file, "r") as f: with open(self._expected_output_file, "r") as f:
exp_out = f.read() exp_out = f.read()
test_result.add_short_text("Expected output file", self._expected_output_file)
test_result.add_long_text("Expected output", exp_out)
try: try:
out, err, rtcode = None, None, None out, err, rtcode = None, None, None
try: try:
...@@ -136,6 +135,9 @@ class JavaExecTest(BasicSyntaxTest): ...@@ -136,6 +135,9 @@ class JavaExecTest(BasicSyntaxTest):
if exp_out.strip() != out.strip(): if exp_out.strip() != out.strip():
test_result.incorrect_msg = "incorrect output" test_result.incorrect_msg = "incorrect output"
test_result.has_succeeded = False test_result.has_succeeded = False
test_result.add_short_text("Expected output file", self._expected_output_file)
test_result.add_long_text("Expected output", exp_out)
test_result.add_long_text("Actual output", out)
test_result.add_diff("Output diff [expected <-> actual]", exp_out, out, with_line_numbers=True) test_result.add_diff("Output diff [expected <-> actual]", exp_out, out, with_line_numbers=True)
test_result.add_file("Source file", self.preprocessed_file) test_result.add_file("Source file", self.preprocessed_file)
os.chdir(cwd) os.chdir(cwd)
......
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