@@ -74,12 +74,11 @@ def __init__(
74
74
self ._output_type = task_node [Tags .OUTPUT_TYPE_TAG ]
75
75
self ._student_task_folder = student_task_folder
76
76
self ._binary_name = task_node [Tags .BINARY_NAME_TAG ]
77
- self ._pipe_through = task_node [Tags .PIPE_TAG ]
78
77
self ._build_timeout = task_node [Tags .BUILD_TIMEOUT_TAG ]
78
+
79
+ self ._test_nodes = []
79
80
if Tags .TESTS_TAG in task_node :
80
81
self ._test_nodes = task_node [Tags .TESTS_TAG ]
81
- else :
82
- self ._test_nodes = [] # Sometimes we don't have tests.
83
82
self .__test_counter = 0
84
83
85
84
def __with_number_prefix (self : Task , test_name : str ) -> str :
@@ -187,7 +186,7 @@ class CppTask(Task):
187
186
188
187
CMAKE_BUILD_CMD = "cmake .. && make -j2"
189
188
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"
191
190
192
191
def __init__ (self : CppTask , task_node : dict , root_folder : Path , job_file : Path ):
193
192
"""Initialize the C++ Task."""
@@ -247,17 +246,28 @@ def _run_test(self: CppTask, test_node: dict, executable_folder: Path):
247
246
cwd = executable_folder ,
248
247
timeout = test_node [Tags .TIMEOUT_TAG ],
249
248
)
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
+
250
257
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 ]
253
260
run_cmd = "./{binary_name} {args}" .format (
254
261
binary_name = self ._binary_name , args = input_str
255
262
)
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
258
267
run_result = tools .run_command (
259
268
run_cmd , cwd = executable_folder , timeout = test_node [Tags .TIMEOUT_TAG ]
260
269
)
270
+
261
271
if not run_result .succeeded ():
262
272
return run_result
263
273
# TODO(igor): do I need explicit error here?
@@ -294,12 +304,21 @@ def _code_style_errors(self: BashTask):
294
304
def _run_test (
295
305
self : BashTask , test_node : dict , executable_folder : Path
296
306
) -> 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
+
297
314
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 ]
300
317
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
303
322
run_result = tools .run_command (
304
323
run_cmd , cwd = executable_folder , timeout = test_node [Tags .TIMEOUT_TAG ]
305
324
)
0 commit comments