@@ -676,21 +676,25 @@ def custom_user_workspace(request):
676676
677677
678678@pytest .fixture (scope = "session" )
679- def llm_venv (llm_root , custom_user_workspace ):
679+ def llm_venv (request , llm_root , custom_user_workspace ):
680680 workspace_dir = custom_user_workspace
681681 subdir = datetime .datetime .now ().strftime ("ws-%Y-%m-%d-%H-%M-%S" )
682682 if workspace_dir is None :
683683 workspace_dir = "llm-test-workspace"
684684 workspace_dir = os .path .join (workspace_dir , subdir )
685+ keep_workspace = request .config .getoption ("--keep-workspace" , default = False )
685686 from defs .local_venv import PythonVenvRunnerImpl
686687
687688 venv = PythonVenvRunnerImpl ("" , "" , "python3" ,
688689 os .path .join (os .getcwd (), workspace_dir ))
689690 yield venv
690691 # Remove the workspace directory
691692 if os .path .exists (workspace_dir ):
692- print (f"Cleaning up workspace: { workspace_dir } " )
693- shutil .rmtree (workspace_dir , ignore_errors = True )
693+ if keep_workspace :
694+ print (f"Keeping workspace (--keep-workspace): { workspace_dir } " )
695+ else :
696+ print (f"Cleaning up workspace: { workspace_dir } " )
697+ shutil .rmtree (workspace_dir , ignore_errors = True )
694698
695699
696700@pytest .fixture (scope = "session" )
@@ -2071,6 +2075,13 @@ def pytest_addoption(parser):
20712075 help = "Enable GPU clock locking during tests. "
20722076 "By default, GPU clock locking is disabled." ,
20732077 )
2078+ parser .addoption (
2079+ "--keep-workspace" ,
2080+ action = "store_true" ,
2081+ default = False ,
2082+ help =
2083+ "Skip workspace cleanup at session end (useful for inspecting logs after a failure)." ,
2084+ )
20742085 parser .addoption (
20752086 "--periodic-save-unfinished-test" ,
20762087 action = "store_true" ,
0 commit comments