From b8732dfc6f451785c8b2fb6ae749e49eb8f1148c Mon Sep 17 00:00:00 2001 From: CleverThis Date: Tue, 14 Apr 2026 18:06:03 +0000 Subject: [PATCH] fix(tests): resolve nox unit_tests timeout for agent_skills_loader and skill_search features Adjusted test running and file-detection logic to stabilize unit tests in overlayfs environments and improve target feature handling. - Modified scripts/run_behave_parallel.py to run sequentially when there are 2 or fewer feature files, avoiding fork deadlocks on overlayfs and reducing nox-based unit test timeouts for agent_skills_loader and skill_search features. - Updated noxfile.py to correctly detect feature files in posargs, fixing the prior logic that appended the "features/" directory when specific feature files were provided. This ensures precise test selection and avoids unnecessary path expansion. Rationale: These changes address the root causes of flaky unit test timeouts by preventing problematic forking behavior with small feature sets and by ensuring nox respects explicitly provided feature file paths. ISSUES CLOSED: #9374 --- noxfile.py | 8 +++++--- scripts/run_behave_parallel.py | 13 ++++++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/noxfile.py b/noxfile.py index 4a3cca99f..957467855 100644 --- a/noxfile.py +++ b/noxfile.py @@ -173,8 +173,9 @@ def unit_tests(session: nox.Session): behave_cmd = session.bin + "/behave-parallel" parallel_args = _behave_parallel_args(session.posargs) - # If a specific feature file is passed, run only that file - if session.posargs and session.posargs[0].endswith(".feature"): + # If specific feature files are passed, run only those files + has_feature_files = any(arg.endswith(".feature") for arg in session.posargs) + if has_feature_files: args = [ behave_cmd, "-q", @@ -562,7 +563,8 @@ def coverage_report(session: nox.Session): # Build behave-parallel args (sequential for coverage). behave_cmd = session.bin + "/behave-parallel" - if session.posargs and session.posargs[0].endswith(".feature"): + has_feature_files = any(arg.endswith(".feature") for arg in session.posargs) + if has_feature_files: behave_args = [ behave_cmd, "-q", diff --git a/scripts/run_behave_parallel.py b/scripts/run_behave_parallel.py index 14721d779..b3d6e4d80 100644 --- a/scripts/run_behave_parallel.py +++ b/scripts/run_behave_parallel.py @@ -337,7 +337,18 @@ def main(argv: list[str] | None = None) -> None: start = time.monotonic() - if processes <= 1 or coverage_mode or len(feature_paths) == 1: + # Run sequentially if: + # - processes <= 1 (explicitly requested) + # - coverage_mode (slipcover requires single process) + # - only 1 feature file (no parallelism benefit) + # - very few feature files relative to processes (fork overhead > benefit) + # When feature_paths <= 2, sequential is faster and avoids fork deadlocks + if ( + processes <= 1 + or coverage_mode + or len(feature_paths) == 1 + or len(feature_paths) <= 2 + ): # ---- sequential in-process mode ---- _, total = _run_features_inprocess(feature_paths, other_args) else: -- 2.52.0