Add use_cases test category with CLI startup test
tests/use_cases/ holds scenario-driven tests run by the Claude Code agent, which acts as both the test runner and mock user. Each test prints a structured transcript; Claude evaluates correctness. First test: test_cli_startup.py — spawns cli.py with a subprocess, reads the welcome banner, sends EOF, and verifies exit code 0. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
46
tests/use_cases/test_cli_startup.py
Normal file
46
tests/use_cases/test_cli_startup.py
Normal file
@@ -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} ===")
|
||||||
Reference in New Issue
Block a user