test_driver: support Python 3.8 for now

Our docker tests are currently broken since we no longer seem to install
"build_root".  When I sidestep this issue for now and run

	sudo docker/docker_run_tests.sh --shell-before docker/focal.Dockerfile
	cd /fish-source
	CARGO_TARGET_DIR=$HOME/out
	tests/test_driver.py ~/out/debug

the test driver fails in various ways.
This is because Ubuntu Focal provides Python 3.8.

Fix some of the typing incompatibilities.  Fix a hang in tests like
"tests/checks/init-command.fish"; apparently fish believes it's interactive
because Python 3.8's create_subprocess_shell() makes the fish child believe
that stdin is a TTY, so it's implicitly interactive.
This commit is contained in:
Johannes Altmanninger
2025-06-13 12:23:50 +02:00
parent 535a09a5b3
commit ec27b418e4
2 changed files with 17 additions and 4 deletions

View File

@@ -388,8 +388,13 @@ def runproc(cmd, env=None):
async def runproc_async(cmd, env=None):
"""Wrapper around subprocess.Popen to save typing"""
PIPE = asyncio.subprocess.PIPE
DEVNULL = asyncio.subprocess.DEVNULL
return await asyncio.create_subprocess_shell(
cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE, env=env
cmd,
stdin=DEVNULL,
stdout=PIPE,
stderr=PIPE,
env=env,
)

View File

@@ -11,6 +11,12 @@ import sys
import tempfile
from typing import Optional
# TODO(python>3.8): use dict
from typing import Dict
# TODO(python>3.8): use |
from typing import Union
import littlecheck
try:
@@ -26,7 +32,7 @@ BLUE = "\033[34m"
RED = "\033[31m"
def makeenv(script_path: Path, home: Path) -> dict[str, str]:
def makeenv(script_path: Path, home: Path) -> Dict[str, str]:
xdg_config = home / "xdg_config_home"
func_dir = xdg_config / "fish" / "functions"
os.makedirs(func_dir)
@@ -103,7 +109,8 @@ async def main():
print("Usage: test_driver.py FISH_DIRECTORY TESTS")
return 1
script_path = Path(__file__).parent
# TODO(python>3.8): no need for abspath
script_path = Path(os.path.abspath(__file__)).parent
argparser = argparse.ArgumentParser(
description="test_driver: Run fish's test suite"
@@ -175,6 +182,7 @@ async def main():
]
for task in asyncio.as_completed(tasks):
result = await task
# TODO(python>3.8): use match statement
if isinstance(result, TestSkip):
arg = result.arg
skipcount += 1
@@ -219,7 +227,7 @@ class TestPass:
duration_ms: int
TestResult = TestSkip | TestFail | TestPass
TestResult = Union[TestSkip, TestFail, TestPass]
async def run_test(