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.
This commit is contained in:
Ran Benita 2020-07-20 17:24:39 +03:00 committed by GitHub
parent 07ed197247
commit 41d211c24a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 3 deletions

View File

@ -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: