Commit b5f7e297 authored by Vladimír Štill's avatar Vladimír Štill
Browse files

test: Test both html and text flavour of checker

parent 81728fc1
Pipeline #76764 passed with stage
in 1 minute and 24 seconds
......@@ -8,7 +8,7 @@ from typing import Dict, Set
FilePath = str
def run_checker(task_file: FilePath, solution_file: FilePath) \
def run_checker(task_file: FilePath, solution_file: FilePath, html: bool) \
-> subprocess.CompletedProcess:
"""
Executes the checker with task given in files, returns information about
......@@ -17,12 +17,15 @@ def run_checker(task_file: FilePath, solution_file: FilePath) \
with open(task_file) as task_handle:
task = task_handle.read()
return subprocess.run([sys.executable, # the Python itself
"fja_checker/__main__.py", solution_file, f"-o{task}"],
args = [sys.executable, # the Python itself
"fja_checker/__main__.py"]
if html:
args.append("--html")
return subprocess.run(args + [solution_file, f"-o{task}"],
capture_output=True)
def run_tests(test_dir: FilePath) -> None:
def run_tests(test_dir: FilePath, html: bool) -> None:
"""
Run all tests in given directory.
Task are given by files of form <NAME.q>.
......@@ -48,7 +51,7 @@ def run_tests(test_dir: FilePath) -> None:
assert solutions, f"Test {task} has no solutions"
for solution in sorted(solutions):
sol_count += 1
res = run_checker(task, solution)
res = run_checker(task, solution, html)
assert 0 <= res.returncode < 128, \
f"Killed with signal {res.returncode}"
passed = (res.returncode != 0) == solution.endswith("nok")
......@@ -62,9 +65,17 @@ def run_tests(test_dir: FilePath) -> None:
# Test entry points
def test_reg():
run_tests("test/checker/reg")
def test_reg_text():
run_tests("test/checker/reg", False)
def test_cfl():
run_tests("test/checker/cfl")
def test_reg_html():
run_tests("test/checker/reg", True)
def test_cfl_text():
run_tests("test/checker/cfl", False)
def test_cfl_html():
run_tests("test/checker/cfl", True)
Supports Markdown
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