From 5dd99c7ee154befa89a399ad3dac4ef352b333c4 Mon Sep 17 00:00:00 2001 From: rafael Date: Tue, 23 Mar 2021 11:35:37 +0100 Subject: [PATCH 1/4] add stdin pipe to popen call --- reframe/utility/osext.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/reframe/utility/osext.py b/reframe/utility/osext.py index 25bf69c96d..1608317e7b 100644 --- a/reframe/utility/osext.py +++ b/reframe/utility/osext.py @@ -77,6 +77,7 @@ def run_command(cmd, check=False, timeout=None, shell=False, log=True): def run_command_async(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, + stdin=subprocess.PIPE, shell=False, log=True, **popen_args): @@ -112,6 +113,7 @@ def run_command_async(cmd, return subprocess.Popen(args=cmd, stdout=stdout, stderr=stderr, + stdin=stdin, universal_newlines=True, shell=shell, **popen_args) From dc7d35ff774c63d928d373d00e557d88db1bf505 Mon Sep 17 00:00:00 2001 From: rafael Date: Wed, 24 Mar 2021 13:25:02 +0100 Subject: [PATCH 2/4] add unittest --- unittests/test_utility.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/unittests/test_utility.py b/unittests/test_utility.py index 2350ad1762..fb5f03a415 100644 --- a/unittests/test_utility.py +++ b/unittests/test_utility.py @@ -29,6 +29,13 @@ def test_command_success(): assert completed.stdout == 'foobar\n' +def test_command_stdin_isatty(): + completed = osext.run_command( + "python -c 'import sys; print(sys.stdin.isatty())'") + assert completed.returncode == 0 + assert completed.stdout == 'False\n' + + def test_command_success_cmd_seq(): completed = osext.run_command(['echo', 'foobar']) assert completed.returncode == 0 From 925419653df28fde07894baa5d7a8d887d4bfb32 Mon Sep 17 00:00:00 2001 From: Vasileios Karakasis Date: Mon, 29 Mar 2021 20:04:59 +0200 Subject: [PATCH 3/4] Revert "add unittest" This reverts commit dc7d35ff774c63d928d373d00e557d88db1bf505. --- unittests/test_utility.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/unittests/test_utility.py b/unittests/test_utility.py index fb5f03a415..2350ad1762 100644 --- a/unittests/test_utility.py +++ b/unittests/test_utility.py @@ -29,13 +29,6 @@ def test_command_success(): assert completed.stdout == 'foobar\n' -def test_command_stdin_isatty(): - completed = osext.run_command( - "python -c 'import sys; print(sys.stdin.isatty())'") - assert completed.returncode == 0 - assert completed.stdout == 'False\n' - - def test_command_success_cmd_seq(): completed = osext.run_command(['echo', 'foobar']) assert completed.returncode == 0 From 775057af508326a2ce3717efbdc30f8081065dea Mon Sep 17 00:00:00 2001 From: Vasileios Karakasis Date: Mon, 29 Mar 2021 20:36:51 +0200 Subject: [PATCH 4/4] Pass DEVNULL to Popen stdin --- reframe/utility/osext.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/reframe/utility/osext.py b/reframe/utility/osext.py index 1608317e7b..1ef9045bae 100644 --- a/reframe/utility/osext.py +++ b/reframe/utility/osext.py @@ -77,7 +77,6 @@ def run_command(cmd, check=False, timeout=None, shell=False, log=True): def run_command_async(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, - stdin=subprocess.PIPE, shell=False, log=True, **popen_args): @@ -113,7 +112,7 @@ def run_command_async(cmd, return subprocess.Popen(args=cmd, stdout=stdout, stderr=stderr, - stdin=stdin, + stdin=subprocess.DEVNULL, universal_newlines=True, shell=shell, **popen_args)