From a35ba83db7102ef2ca3b1b46872bcde1c842bdd9 Mon Sep 17 00:00:00 2001 From: Alvis Date: Thu, 12 Mar 2026 16:10:04 +0000 Subject: [PATCH] Add use_cases test category with CLI startup test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- tests/use_cases/test_cli_startup.py | 46 +++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 tests/use_cases/test_cli_startup.py 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} ===")