Executors
Executor (ABC)
¶
file_extension: str
property
readonly
¶
compile(self, tempdir, source_filename)
¶
Source code in testcase_maker/executor.py
def compile(self, tempdir: Union["Path", str], source_filename: Union["Path", str]) -> Union["Path", str]:
raise NotImplementedError
execute(self, tempdir, exec_filename, stdin)
¶
Source code in testcase_maker/executor.py
def execute(self, tempdir: Union["Path", str], exec_filename: Union["Path", str], stdin: str) -> str:
raise NotImplementedError
CPPExecutor (Executor)
¶
Run your answer script in C++!
file_extension: str
property
readonly
¶
compile(self, tempdir, source_filename)
¶
Source code in testcase_maker/executors/cpp.py
def compile(self, tempdir: Union["Path", str], source_filename: Union["Path", str]) -> Union["Path", str]:
args = ["g++", "-o", str(source_filename.stem), str(source_filename.absolute())]
run_command(args, cwd=tempdir)
return tempdir.joinpath(f"{source_filename.stem}.exe")
execute(self, tempdir, exec_filename, stdin)
¶
Source code in testcase_maker/executors/cpp.py
def execute(self, tempdir: Union["Path", str], exec_filename: Union["Path", str], stdin: str) -> str:
args = [str(exec_filename)]
return run_command(args, stdin, exec_filename.parent)
JavaExecutor (Executor)
¶
Run your answer script in java!
file_extension: str
property
readonly
¶
compile(self, tempdir, source_filename)
¶
Source code in testcase_maker/executors/java.py
def compile(self, tempdir: Union["Path", str], source_filename: Union["Path", str]) -> Union["Path", str]:
args = ["javac", str(source_filename), "-d", str(tempdir)]
run_command(args, cwd=tempdir)
return tempdir.joinpath(f"{source_filename.stem}.class")
execute(self, tempdir, exec_filename, stdin)
¶
Source code in testcase_maker/executors/java.py
def execute(self, tempdir: Union["Path", str], exec_filename: Union["Path", str], stdin: str) -> str:
args = ["java", str(exec_filename.stem)]
return run_command(args, stdin, exec_filename.parent)
PythonExecutor (Executor)
¶
file_extension: str
property
readonly
¶
compile(self, tempdir, source_filename)
¶
Source code in testcase_maker/executors/python.py
def compile(self, tempdir: Union["Path", str], source_filename: Union["Path", str]) -> Union["Path", str]:
copy_source = tempdir.joinpath(source_filename.name)
shutil.copy(source_filename, copy_source)
args = [sys.executable, "-m", "compileall", str(copy_source)]
run_command(args, cwd=tempdir)
return next(tempdir.joinpath("__pycache__").glob('*.pyc'))
execute(self, tempdir, exec_filename, stdin)
¶
Source code in testcase_maker/executors/python.py
def execute(self, tempdir: Union["Path", str], exec_filename: Union["Path", str], stdin: str) -> str:
args = [sys.executable, str(exec_filename)]
return run_command(args, stdin)