@@ -74,12 +74,11 @@ def __init__(
7474 self ._output_type = task_node [Tags .OUTPUT_TYPE_TAG ]
7575 self ._student_task_folder = student_task_folder
7676 self ._binary_name = task_node [Tags .BINARY_NAME_TAG ]
77- self ._pipe_through = task_node [Tags .PIPE_TAG ]
7877 self ._build_timeout = task_node [Tags .BUILD_TIMEOUT_TAG ]
78+
79+ self ._test_nodes = []
7980 if Tags .TESTS_TAG in task_node :
8081 self ._test_nodes = task_node [Tags .TESTS_TAG ]
81- else :
82- self ._test_nodes = [] # Sometimes we don't have tests.
8382 self .__test_counter = 0
8483
8584 def __with_number_prefix (self : Task , test_name : str ) -> str :
@@ -187,7 +186,7 @@ class CppTask(Task):
187186
188187 CMAKE_BUILD_CMD = "cmake .. && make -j2"
189188 REMAKE_AND_TEST = "make clean && rm -r * && cmake .. && make -j2 && ctest -VV"
190- BUILD_CMD_SIMPLE = "clang++ -std=c++14 -o {binary} {compiler_flags } {binary}.cpp"
189+ BUILD_CMD_SIMPLE = "clang++ {compiler_flags} -o {binary} {binary}.cpp"
191190
192191 def __init__ (self : CppTask , task_node : dict , root_folder : Path , job_file : Path ):
193192 """Initialize the C++ Task."""
@@ -247,17 +246,28 @@ def _run_test(self: CppTask, test_node: dict, executable_folder: Path):
247246 cwd = executable_folder ,
248247 timeout = test_node [Tags .TIMEOUT_TAG ],
249248 )
249+
250+ output_pipe_args = None
251+ if Tags .OUTPUT_PIPE_TAG in test_node :
252+ output_pipe_args = test_node [Tags .OUTPUT_PIPE_TAG ]
253+ input_pipe_args = None
254+ if Tags .INPUT_PIPE_TAG in test_node :
255+ input_pipe_args = test_node [Tags .INPUT_PIPE_TAG ]
256+
250257 input_str = ""
251- if Tags .INPUT_TAG in test_node :
252- input_str = test_node [Tags .INPUT_TAG ]
258+ if Tags .INPUT_ARGS_TAG in test_node :
259+ input_str = test_node [Tags .INPUT_ARGS_TAG ]
253260 run_cmd = "./{binary_name} {args}" .format (
254261 binary_name = self ._binary_name , args = input_str
255262 )
256- if self ._pipe_through :
257- run_cmd += " " + self ._pipe_through
263+ if input_pipe_args :
264+ run_cmd = input_pipe_args + " | " + run_cmd
265+ if output_pipe_args :
266+ run_cmd += " | " + output_pipe_args
258267 run_result = tools .run_command (
259268 run_cmd , cwd = executable_folder , timeout = test_node [Tags .TIMEOUT_TAG ]
260269 )
270+
261271 if not run_result .succeeded ():
262272 return run_result
263273 # TODO(igor): do I need explicit error here?
@@ -294,12 +304,21 @@ def _code_style_errors(self: BashTask):
294304 def _run_test (
295305 self : BashTask , test_node : dict , executable_folder : Path
296306 ) -> tools .CmdResult :
307+ output_pipe_args = None
308+ if Tags .OUTPUT_PIPE_TAG in test_node :
309+ output_pipe_args = test_node [Tags .OUTPUT_PIPE_TAG ]
310+ input_pipe_args = None
311+ if Tags .INPUT_PIPE_TAG in test_node :
312+ input_pipe_args = test_node [Tags .INPUT_PIPE_TAG ]
313+
297314 input_str = ""
298- if Tags .INPUT_TAG in test_node :
299- input_str = test_node [Tags .INPUT_TAG ]
315+ if Tags .INPUT_ARGS_TAG in test_node :
316+ input_str = test_node [Tags .INPUT_ARGS_TAG ]
300317 run_cmd = BashTask .RUN_CMD .format (binary_name = self ._binary_name , args = input_str )
301- if self ._pipe_through :
302- run_cmd += " " + self ._pipe_through
318+ if input_pipe_args :
319+ run_cmd = input_pipe_args + " | " + run_cmd
320+ if output_pipe_args :
321+ run_cmd += " | " + output_pipe_args
303322 run_result = tools .run_command (
304323 run_cmd , cwd = executable_folder , timeout = test_node [Tags .TIMEOUT_TAG ]
305324 )
0 commit comments