diff --git a/judges/__init__.py b/judges/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/judges/judge_c.py b/judges/judge_c.py new file mode 100644 index 0000000000000000000000000000000000000000..9134d7b27d6559416cfbc28e4742208e896fcb0a --- /dev/null +++ b/judges/judge_c.py @@ -0,0 +1 @@ +import task_common \ No newline at end of file diff --git a/task_common.py b/task_common.py index a1987447928fa85bf99db9b3a76e09add7271b65..5dd44dcdaa0884c97b1f4046be6fe1b7c1ee3536 100644 --- a/task_common.py +++ b/task_common.py @@ -206,7 +206,7 @@ def student_code_pre_compile(task: TaskData, command: str, check_and_feedback: C return _command_and_feedback(task, command, check_and_feedback) -def student_code_compile(task: TaskData, command: str, check_and_feedback: Callable[[int, str], None]): +def student_code_compile(task: TaskData, command: str, check_and_feedback: Callable[[int, str, Optional[Path], Optional[List[Path]]], None]): """ Performs the compilation of the student code and performs the test related to it task: structure containing the data related to the task we're testing @@ -214,7 +214,11 @@ def student_code_compile(task: TaskData, command: str, check_and_feedback: Calla check_and_feedback: a callable taking the status code of the process to be called by command and the output of said command, it does the feedback accordingly. """ - return _command_and_feedback(task, command, check_and_feedback) + if(len(command) >= 0): + p = subprocess.Popen(shlex.split(command.format(task.student_code)), stderr=subprocess.STDOUT, stdout=subprocess.PIPE) + output = p.communicate()[0].decode('utf-8') + return check_and_feedback(p.returncode, output) + return True def student_code_post_compile(task: TaskData, command: str, check_and_feedback: Callable[[int, str], None]): @@ -247,7 +251,47 @@ def student_code_test_external(task: TaskData, command: str, check_and_feedback: - +class FrameWorkBuilder: + """ + This class handles the state between the steps of creating a task framework. First add the commands and functions + then call the builder to get a task runner function. This allows for modularity as you can modify the state between + successive calls to the build method + """ + def __init__(self): + + self.pre_compile_pair = (None, None) + self.compile_pair = (None, None) + self.post_compile_pair = (None, None) + self.test_pair = (None, None) + self.test_external = (None, None) + + + def set_pre_compile_pair(self, command: str, fun: Callable[[int, str], None]): + + self.pre_compile_pair = (command, fun) + + + def set_compile_pair(self, command: str, fun: Callable[[int, str, Optional[Path], Optional[List[Path]]], None]): + + self.compile_pair = (command, fun) + + + def set_post_compile_pair(self, command: str, fun: Callable[[int, str], None]): + + self.post_compile_pair = (command, fun) + + + def set_test_pair(self, command: str, fun: Callable[[Any], None]): + + self.test_pair = (command, fun) + + + def set_test_external(self, command: str, fun: Callable[[int, str], None]): + + self.test_external = (command, fun) + def build_framework(self): + def run_task(task_dir: Path): + \ No newline at end of file