From 41d211c24a6781843b174379d6d6538f5c17adb9 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Mon, 20 Jul 2020 17:24:39 +0300 Subject: [PATCH] testing: use a tighter check if `bash` is available (#7520) This fixes CI on Windows since GitHub Actions started installing WSL on their images which apparently installs some wrapper `bash` which does not run actual bash. --- testing/test_parseopt.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/testing/test_parseopt.py b/testing/test_parseopt.py index 8cfb9e4a9..59b729d94 100644 --- a/testing/test_parseopt.py +++ b/testing/test_parseopt.py @@ -1,7 +1,7 @@ import argparse import os import shlex -import shutil +import subprocess import sys import py @@ -288,8 +288,19 @@ class TestParser: def test_argcomplete(testdir, monkeypatch) -> None: - if not shutil.which("bash"): - pytest.skip("bash not available") + try: + bash_version = subprocess.run( + ["bash", "--version"], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + universal_newlines=True, + ).stdout + except OSError: + pytest.skip("bash is not available") + if "GNU bash" not in bash_version: + # See #7518. + pytest.skip("not a real bash") + script = str(testdir.tmpdir.join("test_argcomplete")) with open(str(script), "w") as fp: