Stabilize Jupyter terminal wrapper execution

This commit is contained in:
wuyang6
2026-06-15 17:14:54 +08:00
parent c795ec1b5d
commit 1d38753d08
2 changed files with 65 additions and 6 deletions
+23
View File
@@ -3,6 +3,7 @@ from __future__ import annotations
import unittest
from src.jupyter_runtime import (
build_terminal_script_launcher,
clean_terminal_output,
extract_terminal_command_output,
)
@@ -43,6 +44,28 @@ class TestJupyterRuntimeOutputFiltering(unittest.TestCase):
self.assertEqual(cleaned, 'real-output')
def test_clean_terminal_output_drops_continuation_prompt(self) -> None:
cleaned = clean_terminal_output('real-output\r\n# >\r\n')
self.assertEqual(cleaned, 'real-output')
def test_terminal_script_launcher_hides_complex_wrapper_from_shell(self) -> None:
launcher = build_terminal_script_launcher(
script_path='/workspace/scratchpad/.run_scripts/run.sh',
marker='__ZK_AGENT_EXIT_test__',
)
self.assertNotIn('setsid bash -lc', launcher)
self.assertEqual(
launcher,
'bash /workspace/scratchpad/.run_scripts/run.sh; '
'__zk_outer_status=$?; '
'rm -f /workspace/scratchpad/.run_scripts/run.sh; '
'if [ "$__zk_outer_status" -ne 0 ]; then '
'printf "\\n__ZK_AGENT_EXIT_test__:%s\\n" "$__zk_outer_status"; '
'fi',
)
if __name__ == '__main__':
unittest.main()