From ca7c6b923dd5719eebdae3ffbe06de602f9788d9 Mon Sep 17 00:00:00 2001 From: jia xin Date: Sun, 22 Mar 2026 15:36:56 +0800 Subject: [PATCH 1/2] Add e2e tests for REPL --- tests/e2e/test_repl.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/e2e/test_repl.py diff --git a/tests/e2e/test_repl.py b/tests/e2e/test_repl.py new file mode 100644 index 0000000..8c36331 --- /dev/null +++ b/tests/e2e/test_repl.py @@ -0,0 +1,29 @@ +from .result import RunResult +from .runner import BinaryRunner + + +def _run_repl(runner: BinaryRunner, stdin_text: str = "") -> RunResult: + return runner.run([], stdin_text=stdin_text, timeout=10) + + +def test_repl_invocation(runner: BinaryRunner) -> None: + """REPL starts, shows intro message and prompt.""" + result = _run_repl(runner, stdin_text="/exit\n") + result.assert_success() + result.assert_stdout_contains("Welcome to the Git-Mastery REPL!") + result.assert_stdout_matches(r"gitmastery \[.+\]>") + + +def test_repl_shell_command(runner: BinaryRunner) -> None: + """Shell commands are passed through and executed.""" + result = _run_repl(runner, stdin_text="echo hello_repl_test\n") + result.assert_success() + result.assert_stdout_contains("hello_repl_test") + + +def test_repl_slash_prefix_dispatches_gitmastery_command(runner: BinaryRunner) -> None: + """/command syntax is converted to 'gitmastery command' by the REPL.""" + result = _run_repl(runner, stdin_text="/version\n") + result.assert_success() + result.assert_stdout_contains("Git-Mastery app is") + result.assert_stdout_matches(r"v\d+\.\d+\.\d+") From c85038fea9180ae0b316b5ef4c4bc50144b432d9 Mon Sep 17 00:00:00 2001 From: jia xin Date: Sun, 22 Mar 2026 15:46:05 +0800 Subject: [PATCH 2/2] Condense test cases --- tests/e2e/test_repl.py | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/tests/e2e/test_repl.py b/tests/e2e/test_repl.py index 8c36331..7357916 100644 --- a/tests/e2e/test_repl.py +++ b/tests/e2e/test_repl.py @@ -1,29 +1,16 @@ -from .result import RunResult from .runner import BinaryRunner -def _run_repl(runner: BinaryRunner, stdin_text: str = "") -> RunResult: - return runner.run([], stdin_text=stdin_text, timeout=10) - - -def test_repl_invocation(runner: BinaryRunner) -> None: - """REPL starts, shows intro message and prompt.""" - result = _run_repl(runner, stdin_text="/exit\n") +def test_repl(runner: BinaryRunner) -> None: + """REPL starts, handles shell commands, and dispatches /command syntax.""" + result = runner.run( + [], + stdin_text="echo hello_repl_test\n/version\n/exit\n", + timeout=30, + ) result.assert_success() result.assert_stdout_contains("Welcome to the Git-Mastery REPL!") result.assert_stdout_matches(r"gitmastery \[.+\]>") - - -def test_repl_shell_command(runner: BinaryRunner) -> None: - """Shell commands are passed through and executed.""" - result = _run_repl(runner, stdin_text="echo hello_repl_test\n") - result.assert_success() result.assert_stdout_contains("hello_repl_test") - - -def test_repl_slash_prefix_dispatches_gitmastery_command(runner: BinaryRunner) -> None: - """/command syntax is converted to 'gitmastery command' by the REPL.""" - result = _run_repl(runner, stdin_text="/version\n") - result.assert_success() result.assert_stdout_contains("Git-Mastery app is") result.assert_stdout_matches(r"v\d+\.\d+\.\d+")