Commit cfafbf1b authored by Johannes Bechberger's avatar Johannes Bechberger

Fix `compile_firm` mode and add simple test cases

parent 70ac960b
......@@ -129,12 +129,12 @@ usage: mjt.py [-h] [--only_incorrect_tests] [--produce_no_reports]
[--produce_all_reports] [--parallel]
[--output_no_incorrect_reports] [--color] [--ci_testing]
[--log_level LOG_LEVEL]
{all,lexer,syntax,ast,semantic,exec} MJ_RUN
{all,lexer,syntax,ast,semantic,compile-firm.exec} MJ_RUN
MiniJava test runner
positional arguments:
{all,lexer,syntax,ast,semantic,exec}
{all,lexer,syntax,ast,semantic,compile-firm,exec}
What do you want to test?
MJ_RUN Command to run your MiniJava implementation, e.g.
`mj/run`, can be omitted by assigning the environment
......
......@@ -36,17 +36,26 @@ class JavaExecTest(BasicSyntaxTest):
self.env.run_command("javac", base_filename + ".java")
if javac_rtcode != 0:
_LOG.error("File \"{}\" isn't valid Java".format(self.preprocessed_file))
os.chdir(cwd)
shutil.rmtree(tmp_dir)
raise InterruptedError()
exp_out, _, _ = \
self.env.run_command("java", base_filename)
exp_out = exp_out.decode().strip()
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:
exp_out = f.read()
_, err, rtcode = self.env.run_mj_command(self.MODE, base_filename + ".java")
out, _, _ = self.env.run_command(base_filename)
os.chdir(cwd)
if self.type == self.MODE and self.env.mode == self.MODE:
return BasicDiffTestResult(self, rtcode, out.decode(), err.decode(), exp_out)
return BasicTestResult(self, rtcode, out.decode(), err.decode())
try:
_, err, rtcode = self.env.run_mj_command(self.MODE, base_filename + ".java")
out, _, _ = self.env.run_command("./" + base_filename)
out = out.decode().strip()
os.chdir(cwd)
shutil.rmtree(tmp_dir)
if self.type == self.MODE and self.env.mode == self.MODE:
return BasicDiffTestResult(self, rtcode, out, err.decode(), exp_out)
return BasicTestResult(self, rtcode, out.decode(), err.decode())
except:
os.chdir(cwd)
raise
TestCase.TEST_CASE_CLASSES[TestMode.comile_firm].append(JavaExecTest)
\ No newline at end of file
......@@ -437,3 +437,4 @@ TestCase.TEST_CASE_CLASSES[TestMode.lexer].append(LexerDiffTest)
import mjtest.test.syntax_tests
import mjtest.test.ast_tests
import mjtest.test.semantic_tests
import mjtest.test.exec_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