diff --git a/tested/judge/utils.py b/tested/judge/utils.py index 19d50002..1daedef0 100644 --- a/tested/judge/utils.py +++ b/tested/judge/utils.py @@ -34,6 +34,7 @@ def run_command( timeout: float | None, command: list[str] | None = None, stdin: str | None = None, + check: bool = False, ) -> BaseExecutionResult | None: """ Run a command and get the result of said command. @@ -42,6 +43,7 @@ def run_command( :param command: Optional, the command to execute. :param stdin: Optional stdin for the process. :param timeout: The max time for this command. + :param check: Raise if the command fails. :return: The result of the execution if the command was not None. """ @@ -58,6 +60,7 @@ def run_command( capture_output=True, input=stdin, timeout=timeout, + check=check, ) except subprocess.TimeoutExpired as e: return BaseExecutionResult( diff --git a/tested/languages/javascript/config.py b/tested/languages/javascript/config.py index 1a8ed379..307d5f4b 100644 --- a/tested/languages/javascript/config.py +++ b/tested/languages/javascript/config.py @@ -126,18 +126,16 @@ def modify_solution(self, solution: Path): assert self.config parse_file = str(Path(__file__).parent / "parseAst.js") - try: - output = run_command( - solution.parent, - timeout=None, - command=["node", parse_file, str(solution.absolute())], - ) - if output: - namings = output.stdout.strip() - with open(solution, "a") as file: - print(f"\nmodule.exports = {{{namings}}};", file=file) - except TimeoutError: - pass + output = run_command( + solution.parent, + timeout=None, + command=["node", parse_file, str(solution.absolute())], + check=True, + ) + assert output, "Missing output from JavaScript's modify_solution" + namings = output.stdout.strip() + with open(solution, "a") as file: + print(f"\nmodule.exports = {{{namings}}};", file=file) # Add strict mode to the script. with open(solution, "r") as file: