Skip to content

Commit

Permalink
Fix line linking for Bash (in English)
Browse files Browse the repository at this point in the history
  • Loading branch information
niknetniko committed Jan 29, 2024
1 parent c8e789b commit 32e5faf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion tested/languages/bash/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"<code>:\2", stacktrace)
stacktrace = regex.sub("<testcode>:", stacktrace).replace(
submission_file(self), "<code>"
Expand Down
20 changes: 17 additions & 3 deletions tests/test_stacktrace_cleaners.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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(),
)
Expand Down Expand Up @@ -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):'
Expand All @@ -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 = """
<code>:1: syntaxfout nabij onverwacht symbool '('
<code>: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:
Expand Down

0 comments on commit 32e5faf

Please sign in to comment.