diff --git a/python/scripts/task_runner.py b/python/scripts/task_runner.py index a1331803cc..73b4dbae0d 100644 --- a/python/scripts/task_runner.py +++ b/python/scripts/task_runner.py @@ -44,7 +44,9 @@ def discover_projects(workspace_pyproject_file: Path) -> list[Path]: for project in projects: if "*" in project: globbed = glob.glob(str(project), root_dir=workspace_pyproject_file.parent) - globbed_paths = [Path(p) for p in globbed] + globbed_paths = [ + Path(path) for path in globbed if (workspace_pyproject_file.parent / path / "pyproject.toml").is_file() + ] all_projects.extend(globbed_paths) else: all_projects.append(Path(project)) diff --git a/python/scripts/tests/test_task_runner.py b/python/scripts/tests/test_task_runner.py new file mode 100644 index 0000000000..ae94f880aa --- /dev/null +++ b/python/scripts/tests/test_task_runner.py @@ -0,0 +1,17 @@ +# Copyright (c) Microsoft. All rights reserved. + +from pathlib import Path + +from scripts.task_runner import discover_projects + + +def test_discover_projects_ignores_glob_matches_without_pyproject(tmp_path: Path) -> None: + workspace_pyproject = tmp_path / "pyproject.toml" + workspace_pyproject.write_text('[tool.uv.workspace]\nmembers = ["packages/*"]\n') + + valid_project = tmp_path / "packages" / "valid" + valid_project.mkdir(parents=True) + (valid_project / "pyproject.toml").write_text('[project]\nname = "valid"\nversion = "1.0.0"\n') + (tmp_path / "packages" / "stale").mkdir() + + assert discover_projects(workspace_pyproject) == [Path("packages/valid")] diff --git a/python/scripts/workspace_poe_tasks.py b/python/scripts/workspace_poe_tasks.py index 5c8f82ebc7..984a838c79 100644 --- a/python/scripts/workspace_poe_tasks.py +++ b/python/scripts/workspace_poe_tasks.py @@ -520,6 +520,10 @@ def run_aggregate_test(project_pattern: str, cov: bool, extra_args: list[str]) - return test_dirs = [relative_path(path) for path in collect_test_dirs(projects)] + if project_pattern == "*": + script_test_dir = WORKSPACE_ROOT / "scripts" / "tests" + if script_test_dir.is_dir(): + test_dirs.append(relative_path(script_test_dir)) if not test_dirs: print("[yellow]No test directories found for the selected projects, skipping pytest.[/yellow]") return