From 21e9b9b41fa57ef9d6b43a36a55f545ec0c896d2 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 1 Oct 2019 11:54:18 +0200 Subject: [PATCH] Specify 'check' with subprocess.run --- scripts/asciidoc2html.py | 4 ++-- scripts/dev/build_release.py | 2 +- scripts/dev/check_doc_changes.py | 4 ++-- scripts/dev/run_profile.py | 8 ++++---- scripts/dev/run_pylint_on_tests.py | 2 +- tests/end2end/features/conftest.py | 4 ++-- tests/end2end/test_invocations.py | 6 ++++-- tests/unit/misc/test_checkpyver.py | 3 ++- 8 files changed, 18 insertions(+), 15 deletions(-) diff --git a/scripts/asciidoc2html.py b/scripts/asciidoc2html.py index 2825c2ac4..8a691b067 100755 --- a/scripts/asciidoc2html.py +++ b/scripts/asciidoc2html.py @@ -226,7 +226,7 @@ class AsciiDoc: try: subprocess.run(['asciidoc'], stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL) + stderr=subprocess.DEVNULL, check=True) except OSError: pass else: @@ -234,7 +234,7 @@ class AsciiDoc: try: subprocess.run(['asciidoc.py'], stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL) + stderr=subprocess.DEVNULL, check=True) except OSError: pass else: diff --git a/scripts/dev/build_release.py b/scripts/dev/build_release.py index 2af7dd2b1..964aa5636 100755 --- a/scripts/dev/build_release.py +++ b/scripts/dev/build_release.py @@ -222,7 +222,7 @@ def build_mac(): smoke_test(binary) finally: time.sleep(5) - subprocess.run(['hdiutil', 'detach', tmpdir]) + subprocess.run(['hdiutil', 'detach', tmpdir], check=False) except PermissionError as e: print("Failed to remove tempdir: {}".format(e)) diff --git a/scripts/dev/check_doc_changes.py b/scripts/dev/check_doc_changes.py index 37a061da6..1ba18610f 100755 --- a/scripts/dev/check_doc_changes.py +++ b/scripts/dev/check_doc_changes.py @@ -25,7 +25,7 @@ import subprocess import os code = subprocess.run(['git', '--no-pager', 'diff', - '--exit-code', '--stat']).returncode + '--exit-code', '--stat'], check=False).returncode if os.environ.get('TRAVIS_PULL_REQUEST', 'false') != 'false': if code != 0: @@ -43,6 +43,6 @@ if code != 0: if 'TRAVIS' in os.environ: print() print("travis_fold:start:gitdiff") - subprocess.run(['git', '--no-pager', 'diff']) + subprocess.run(['git', '--no-pager', 'diff'], check=True) print("travis_fold:end:gitdiff") sys.exit(code) diff --git a/scripts/dev/run_profile.py b/scripts/dev/run_profile.py index ff13da7a3..e7ff564e2 100755 --- a/scripts/dev/run_profile.py +++ b/scripts/dev/run_profile.py @@ -85,15 +85,15 @@ def main(): # yep, shell=True. I know what I'm doing. subprocess.run( 'gprof2dot -f pstats {} | dot -Tpng | feh -F -'.format( - shlex.quote(profilefile)), shell=True) + shlex.quote(profilefile)), shell=True, check=True) elif args.profile_tool == 'kcachegrind': callgraphfile = os.path.join(tempdir, 'callgraph') subprocess.run(['pyprof2calltree', '-k', '-i', profilefile, - '-o', callgraphfile]) + '-o', callgraphfile], check=True) elif args.profile_tool == 'snakeviz': - subprocess.run(['snakeviz', profilefile]) + subprocess.run(['snakeviz', profilefile], check=True) elif args.profile_tool == 'tuna': - subprocess.run(['tuna', profilefile]) + subprocess.run(['tuna', profilefile], check=True) shutil.rmtree(tempdir) diff --git a/scripts/dev/run_pylint_on_tests.py b/scripts/dev/run_pylint_on_tests.py index 53528734c..c041d9f70 100644 --- a/scripts/dev/run_pylint_on_tests.py +++ b/scripts/dev/run_pylint_on_tests.py @@ -75,7 +75,7 @@ def main(): env = os.environ.copy() env['PYTHONPATH'] = os.pathsep.join(pythonpath) - ret = subprocess.run(['pylint'] + args, env=env).returncode + ret = subprocess.run(['pylint'] + args, env=env, check=False).returncode return ret diff --git a/tests/end2end/features/conftest.py b/tests/end2end/features/conftest.py index 2774b0961..a6291a07a 100644 --- a/tests/end2end/features/conftest.py +++ b/tests/end2end/features/conftest.py @@ -403,12 +403,12 @@ def update_documentation(): try: subprocess.run(['asciidoc'], stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL) + stderr=subprocess.DEVNULL, check=True) except OSError: pytest.skip("Docs outdated and asciidoc unavailable!") update_script = os.path.join(script_path, 'asciidoc2html.py') - subprocess.run([sys.executable, update_script]) + subprocess.run([sys.executable, update_script], check=True) ## Then diff --git a/tests/end2end/test_invocations.py b/tests/end2end/test_invocations.py index 29f720c5e..0d1de4e16 100644 --- a/tests/end2end/test_invocations.py +++ b/tests/end2end/test_invocations.py @@ -325,8 +325,10 @@ def test_command_on_start(request, quteproc_new): def test_launching_with_python2(): try: - proc = subprocess.run(['python2', '-m', 'qutebrowser', - '--no-err-windows'], stderr=subprocess.PIPE) + proc = subprocess.run( + ['python2', '-m', 'qutebrowser', '--no-err-windows'], + stderr=subprocess.PIPE, + check=False) except FileNotFoundError: pytest.skip("python2 not found") assert proc.returncode == 1 diff --git a/tests/unit/misc/test_checkpyver.py b/tests/unit/misc/test_checkpyver.py index d77a028ed..8df84129b 100644 --- a/tests/unit/misc/test_checkpyver.py +++ b/tests/unit/misc/test_checkpyver.py @@ -39,7 +39,8 @@ def test_python2(): proc = subprocess.run( ['python2', checkpyver.__file__, '--no-err-windows'], stdout=subprocess.PIPE, - stderr=subprocess.PIPE) + stderr=subprocess.PIPE, + check=False) except FileNotFoundError: pytest.skip("python2 not found") assert not proc.stdout