From 32e5faf93376976779401070bdc47e74d46a9ca3 Mon Sep 17 00:00:00 2001 From: Niko Strijbol Date: Mon, 29 Jan 2024 11:36:55 +0100 Subject: [PATCH] Fix line linking for Bash (in English) --- tested/languages/bash/config.py | 2 +- tests/test_stacktrace_cleaners.py | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/tested/languages/bash/config.py b/tested/languages/bash/config.py index 5e6854cb..87fb0e8c 100644 --- a/tested/languages/bash/config.py +++ b/tested/languages/bash/config.py @@ -74,7 +74,7 @@ def cleanup_stacktrace(self, stacktrace: str) -> str: f"{EXECUTION_PREFIX}_[0-9]+_[0-9]+\\." f"{self.file_extension()}: [a-zA-Z_]+ [0-9]+:" ) - script = rf"{submission_file(self)}: (regel|rule) (\d+)" + script = rf"{submission_file(self)}: (regel|line) (\d+)" stacktrace = re.sub(script, r":\2", stacktrace) stacktrace = regex.sub(":", stacktrace).replace( submission_file(self), "" diff --git a/tests/test_stacktrace_cleaners.py b/tests/test_stacktrace_cleaners.py index 6c9228e7..bc087c2a 100644 --- a/tests/test_stacktrace_cleaners.py +++ b/tests/test_stacktrace_cleaners.py @@ -10,7 +10,7 @@ _convert_stacktrace_to_html, _replace_code_line_number, ) -from tested.testsuite import Suite +from tested.testsuite import Suite, SupportedLanguage def get_language(workdir: str, language: str) -> Language: @@ -20,7 +20,7 @@ def get_language(workdir: str, language: str) -> Language: time_limit=0, memory_limit=0, natural_language="nl", - programming_language=language, + programming_language=SupportedLanguage(language), workdir=Path(workdir), judge=Path(), ) @@ -210,7 +210,7 @@ def test_bash_runtime_error(): assert actual == expected -def test_bash_compilation_error(): +def test_bash_compilation_error_nl(): original = """ submission: rule 1: syntaxfout nabij onverwacht symbool '(' submission: rule 1: `def isISBN10(code):' @@ -224,6 +224,20 @@ def test_bash_compilation_error(): assert actual == expected +def test_bash_compilation_error_en(): + original = """ + submission: line 1: syntaxfout nabij onverwacht symbool '(' + submission: line 1: `def isISBN10(code):' + """ + language_config = get_language("test", "bash") + expected = """ + :1: syntaxfout nabij onverwacht symbool '(' + :1: `def isISBN10(code):' + """ + actual = language_config.cleanup_stacktrace(original) + assert actual == expected + + def test_c_compilation_error(): original = """In file included from execution_0_0.c:6, from selector.c:6: