Skip to content

Commit

Permalink
Allow merging across tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
niknetniko committed Sep 6, 2023
1 parent f00e8ff commit 9e50541
Show file tree
Hide file tree
Showing 28 changed files with 539 additions and 488 deletions.
4 changes: 2 additions & 2 deletions tested/configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def options(self) -> Options:
class Bundle:
"""A bundle of arguments and configs for running everything."""

lang_config: "Language"
language: "Language"
global_config: GlobalConfig
out: IO

Expand Down Expand Up @@ -194,4 +194,4 @@ def create_bundle(
suite=suite,
)
lang_config = langs.get_language(global_config, language)
return Bundle(lang_config=lang_config, global_config=global_config, out=output)
return Bundle(language=lang_config, global_config=global_config, out=output)
2 changes: 1 addition & 1 deletion tested/descriptions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def process_problem_statement(

bundle = Bundle(
global_config=global_config,
lang_config=language,
language=language,
out=open(os.devnull, "w"),
)

Expand Down
2 changes: 1 addition & 1 deletion tested/descriptions/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def convert_templated_problem(bundle: Bundle, raw_description: str) -> str:
description_template = Template(
source=raw_description, autoescape=False, keep_trailing_newline=True
)
language = bundle.lang_config
language = bundle.language
set_locale(bundle.config.natural_language)
return description_template.render(
# Conventionalize functions
Expand Down
4 changes: 2 additions & 2 deletions tested/descriptions/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def render_one_statement(bundle: Bundle, statement: str) -> str:
parsed_string = parse_string(statement)
generated_statement = generate_statement(bundle, parsed_string)
# Allow the language to modify the template a bit.
return bundle.lang_config.cleanup_description(generated_statement)
return bundle.language.cleanup_description(generated_statement)


class TestedRenderer(MarkdownRenderer):
Expand All @@ -40,7 +40,7 @@ def _render_doctest(self, element: block.FencedCode) -> str:
doctests = self._doctest_parser.get_examples(raw_code)

resulting_lines = []
prompt = self.bundle.lang_config.get_declaration_metadata().get("prompt", ">")
prompt = self.bundle.language.get_declaration_metadata().get("prompt", ">")

# Both the doctests and the results are parsed as values in the DSL.
for examples in doctests:
Expand Down
12 changes: 6 additions & 6 deletions tested/judge/compilation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
from typing import List, Optional, Tuple, Union

from tested.configs import Bundle
from tested.dodona import AnnotateCode, Message, Status
from tested.dodona import Status
from tested.internationalization import get_i18n_string
from tested.judge.planning import CompilationResult
from tested.judge.utils import BaseExecutionResult, run_command
from tested.languages.config import FileFilter, Language
from tested.languages.utils import convert_stacktrace_to_clickable_feedback
Expand Down Expand Up @@ -53,7 +54,7 @@ def run_compilation(
decide to fallback to individual mode if the compilation result is
not positive.
"""
command, files = bundle.lang_config.compilation(dependencies)
command, files = bundle.language.compilation(dependencies)
_logger.debug(
"Generating files with command %s in directory %s", command, directory
)
Expand All @@ -64,25 +65,24 @@ def run_compilation(

def process_compile_results(
language_config: Language, results: Optional[BaseExecutionResult]
) -> Tuple[List[Message], Status, List[AnnotateCode]]:
) -> CompilationResult:
"""
Process the output of a compilation step. It will convert the result of the
command into a list of messages and a status. If the status is not correct,
the messages and status may be passed to Dodona unchanged. Alternatively, they
can be kept to show them with the first context.
"""
messages = []

# There was no compilation
if results is None:
return messages, Status.CORRECT, []
return [], Status.CORRECT, []

show_stdout = False
_logger.debug("Received stderr from compiler: " + results.stderr)
compiler_messages, annotations, stdout, stderr = language_config.compiler_output(
results.stdout, results.stderr
)
messages.extend(compiler_messages)
messages = compiler_messages
shown_messages = annotations or compiler_messages

# Report stderr.
Expand Down
Loading

0 comments on commit 9e50541

Please sign in to comment.