File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -161,7 +161,7 @@ def _run_command(self, event_path):
161161 else :
162162 console .print (f"[red]✖ Command failed with exit code { process .returncode } .[/red]" )
163163 except Exception as e :
164- console .print (f"[bold red]Error executing command: { e } [/bold red]" )
164+ console .print (f"[bold red]Error executing command: { escape ( str ( e )) } [/bold red]" )
165165
166166 def _is_ignored_impl (self , path : str ) -> bool :
167167 if path .startswith (self ._abs_base_path ):
Original file line number Diff line number Diff line change 11import time
22from echo .watcher import CommandRunnerHandler
3+ import subprocess
4+
35from unittest .mock import MagicMock
46
57def test_rich_markup_crash_escaping ():
@@ -24,3 +26,23 @@ def test_rich_markup_crash_escaping():
2426 if handler .current_process :
2527 handler .current_process .terminate ()
2628 handler .current_process .wait ()
29+
30+
31+ def test_rich_error_crash ():
32+ handler = CommandRunnerHandler ("echo test" )
33+
34+ class MockException (Exception ):
35+ def __str__ (self ):
36+ return "File not found: [missing.py]"
37+
38+ original_popen = subprocess .Popen
39+
40+ def fake_popen (* args , ** kwargs ):
41+ raise MockException ()
42+
43+ subprocess .Popen = fake_popen
44+ try :
45+ # this should crash rich with MarkupError if not escaped
46+ handler ._run_command ("test.txt" )
47+ finally :
48+ subprocess .Popen = original_popen
You can’t perform that action at this time.
0 commit comments