ProcessesPipeline type

Undocumented

Methods

assert_exit_code(pp:ProcessesPipeline, expected:Int, title:Str=null) Source: autoload/test.ngs:177
Assert process exits with the specified exit code. Throws TestFail.

Returns

pp

Example

p = $(true); assert_exit_code(p, 0)   # OK
p = $(false); assert_exit_code(p, 1)  # OK
p = $(false); assert_exit_code(p, 0)  # Throws TestFail
assert_output_has(pp:ProcessesPipeline, expected:RegExp, title:Str=null) Source: autoload/test.ngs:190
Assert process has given output. Throws TestFail.

Example

assert_output_has($(echo abc), /xyz/)        # Throws TestFail
p = $(echo abc); assert_output_has(p, /c$/)  # OK
assert_output_has(pp:ProcessesPipeline, expected:Str, title:Str=null) Source: autoload/test.ngs:201
Assert process has given output. Throws TestFail.

Example

assert_output_has($(echo abc), "xyz")        # Throws TestFail
p = $(echo abc); assert_output_has(p, "bc")  # OK
Bool(pp:ProcessesPipeline) Source: stdlib.ngs:4824
Wait for all process to finish and see whether all exit codes are 0

Returns

Bool

Example

if $(test -f myfile) ... # if runs Bool() on any non-Bool condition expression
close(pp:ProcessesPipeline) Source: stdlib.ngs:5216
Close reading and writing pipes of ProcessesPipeline, if they exist
ExitCode(pp:ProcessesPipeline) Source: stdlib.ngs:4892
Convert ProcessesPipeline to exit code. Waits for the processes to finish. Returns first non-zero exit code. Returns zero if all exit codes are zero.
init(pp:ProcessesPipeline, cp:CommandsPipeline) Source: stdlib.ngs:4321
Undocumented
inspect(pp:ProcessesPipeline) Source: stdlib.ngs:6075
Inspect ProcessesPipeline

Returns

Lines
kill(pp:ProcessesPipeline, sig:Int=15) Source: stdlib.ngs:5276
Kill all processes in the ProcessesPipeline. Throws InvalidArgument if ProcessesPipeline is not running (yet).
lines(pp:ProcessesPipeline) Source: stdlib.ngs:5354
Wait for cp and return lines of stdout of the last process.

Returns

Arr of Str

Example

$(seq 3 | tac).lines().map(Int)  # [3,2,1]
lines(pp:ProcessesPipeline, cb:Fun) Source: stdlib.ngs:5362
Wait for pp and return call cb for each line of stdout of last process. Warning: current implementation waits for the processes to finish, accumulates all stdout of the last process, and only then starts calling cb for each line.

Returns

Arr of Str
read(pp:ProcessesPipeline, count:Any=null) Source: stdlib.ngs:5208
Read from last process of ProcessesPipeline

Example

p = $(seq 3 | tac |);
data = read(p);
p.close()
Str(pp:ProcessesPipeline) Source: stdlib.ngs:4901
Wait for the processes to finish and return standard output of the last process in pipeline.

Returns

Str
wait(pp:ProcessesPipeline) Source: stdlib.ngs:4870
Wait for all processes to finish.
write(pp:ProcessesPipeline, s:Str) Source: stdlib.ngs:5198
Write to first process of ProcessesPipeline

Example

p = (|cat -n | tac >/tmp/1)
p.write("one\n")
p.write("two\n")
p.close()