diff --git a/tests/use_cases/test_cli_startup.py b/tests/use_cases/test_cli_startup.py new file mode 100644 index 0000000..f4bd32d --- /dev/null +++ b/tests/use_cases/test_cli_startup.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python3 +""" +Use case: CLI startup and clean exit. + +Starts the Adolf CLI, reads its welcome banner, then closes it by sending +EOF (simulating Ctrl+D). Prints a structured transcript for the Claude Code +agent to evaluate. + +Expected: + - Banner line contains "Adolf CLI" + - Prompt "> " appears + - Process exits with code 0 after EOF +""" + +import os +import subprocess +import sys +import time + +CLI = os.path.join(os.path.dirname(__file__), "../../cli.py") + +proc = subprocess.Popen( + [sys.executable, CLI, "--session", "use-case-cli-startup"], + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + text=True, +) + +# Give the process time to print its banner before closing stdin +time.sleep(0.3) + +try: + stdout, stderr = proc.communicate(input="", timeout=10) +except subprocess.TimeoutExpired: + proc.kill() + stdout, stderr = proc.communicate() + print("RESULT: TIMEOUT — process did not exit within 10s after EOF") + sys.exit(1) + +print("=== stdout ===") +print(stdout) +if stderr.strip(): + print("=== stderr ===") + print(stderr) +print(f"=== exit code: {proc.returncode} ===")