1
0
Fork 1
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:
Johannes Marbach 2020-11-27 20:37:26 +01:00 committed by Oliver Smith
parent 82d149c85d
commit 45dbeca587
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
2 changed files with 40 additions and 10 deletions

View file

@ -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"]