feat(scheduler-sim-repl-verbosity): task 6.1 - RED-phase REPL prompt tests

Adds 2 tests in a new test_repl_prompt_context.c covering the dynamic
prompt's plain-before-first-session baseline and its session/timestamp
content in both step and continue modes (Requirement 5.5).

Required genuinely new test infrastructure: libedit's readline() only
writes its prompt text when both stdin and stdout are real ptys, which
no existing REPL test in this codebase's freopen()-from-file harness
can observe. Built a PTY-based capture technique (openpty(), ECHO
disabled via termios) instead - independently reproduced via a
standalone probe and stress-tested 15x with zero flakiness during
review.

New file rather than extending test_repl_execution_control.c (already
at 948 lines, over the 800-line cap), per this spec's established
split precedent.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YAWMhfRJFnmmnG8h97yUDd
This commit is contained in:
Rongsong Shen 2026-09-02 15:49:41 +00:00
parent d9109b7c4b
commit 99fa45c41a
No known key found for this signature in database
GPG key ID: 5BCDAAE0123E9FE2
3 changed files with 705 additions and 1 deletions

View file

@ -962,6 +962,34 @@ sched_repl_event_echo_test = executable(
dependencies: [scheduler_test_deps, libedit_dep],
install: false)
# Contract test for the interactive simulation REPL's Prompt Context
# component (scheduler-sim-repl-verbosity spec, task 6.1, Requirement 5.5
# "REPL prompt shows session/timestamp"): the readline() prompt is the
# plain "(sim) " before any session has completed, and becomes "(sim
# session=<N> t=<ISO8601-ts>) " (bare rs->session_count) once at least one
# session has run, in both `step` and `continue` modes, without altering
# any command's own printed output. Same white-box #include pattern as
# sched_repl_execution_control_test above (core.c, core_clock.c,
# core_events.c, core_session.c, decision.c, plugin.c,
# plugins/builtin_fcfs.c, recording.c, recording_session.c, sim.c,
# sim_loop.c, sim_record.c, sim_verify.c,
# snapshot.c/snapshot_wire.c/snapshot_load.c, repl.c, repl_rollup.c,
# repl_break.c, repl_info.c, repl_params.c). Split into its own file rather
# than appended to test_repl_execution_control.c (948 lines today, already
# over this project's 800-line cap and grown past the 937-line figure
# design.md's own File Structure Plan cited when it named that file as this
# task's home) -- same reasoning that already split test_repl_round_
# rollup.c/test_repl_event_echo.c out; see this file's own header comment
# for the full rationale, including why a pty (openpty(), <pty.h>) is
# required instead of this file family's usual freopen()-from-a-file
# capture technique to make readline()'s prompt text observable at all.
sched_repl_prompt_context_test = executable(
'sched_repl_prompt_context_test',
['test_repl_prompt_context.c'],
include_directories:[incdir],
dependencies: [scheduler_test_deps, libedit_dep],
install: false)
# Contract test for the interactive simulation REPL's `sim_print_decision`
# Gate component (scheduler-sim-repl-verbosity spec, task 4.1, Requirements
# 2.3, 5.1, 5.4 "retire the redundant per-decision echo during continuous
@ -1445,6 +1473,9 @@ test('scheduler repl round rollup test',
test('scheduler repl event echo test',
sched_repl_event_echo_test, suite: 'scheduler',
env: ['ASAN_OPTIONS=detect_leaks=0'])
test('scheduler repl prompt context test',
sched_repl_prompt_context_test, suite: 'scheduler',
env: ['ASAN_OPTIONS=detect_leaks=0'])
test('scheduler sim print decision gate test',
sched_sim_print_decision_gate_test, suite: 'scheduler',
env: ['ASAN_OPTIONS=detect_leaks=0'])