mirror of
https://gitlab.postmarketos.org/postmarketOS/pmbootstrap.git
synced 2025-07-24 21:15:10 +03:00
pmb.helpers.run_core: add output=pipe (MR 1996)
This adds a new output mode "pipe" that is identical to the existing "background" mode except for that its stdout is redirected into a pipe so that it can be retrieved.
This commit is contained in:
parent
82d149c85d
commit
45dbeca587
2 changed files with 40 additions and 10 deletions
|
@ -56,6 +56,20 @@ def test_background(args):
|
|||
assert process.poll() is None
|
||||
|
||||
|
||||
def test_pipe(args):
|
||||
# Sleep in background
|
||||
process = pmb.helpers.run_core.pipe(args, ["sleep", "1"], "/")
|
||||
|
||||
# Check if it is still running
|
||||
assert process.poll() is None
|
||||
|
||||
# Print output in background
|
||||
process = pmb.helpers.run_core.pipe(args, ["echo", "-n", "hello"], "/")
|
||||
|
||||
# Read output
|
||||
assert process.communicate()[0].decode('utf-8') == "hello"
|
||||
|
||||
|
||||
def test_foreground_pipe(args):
|
||||
func = pmb.helpers.run_core.foreground_pipe
|
||||
cmd = ["echo", "test"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue