On this page
Shared test-running logic that auto-detects project types and invokes the correct test runner (pytest, go test, npm test) for releases and checks.
#rlsbl.testing
#rlsbl.testing
Shared test-running logic that auto-detects project types and invokes the correct test runner (pytest, go test, npm test) for releases and checks.
Extracted from the release pipeline so it can be reused by other commands (e.g., pre-push checks, CI, standalone test invocations).
#sync_workspace
def sync_workspace(workspace_root: str, *, verbose: bool=False, check_timeout: int=120) -> boolRun uv sync --all-packages at the workspace root.
Returns True on success, False on failure.
#_probe_pytest_location
def _probe_pytest_location(project_dir: str) -> tuple[str, str] | NoneDetect where pytest is declared in a project's pyproject.toml.
Checks in order:
- [dependency-groups].* -- any group containing a pytest entry
- [project.optional-dependencies].* -- any extra containing pytest
- [tool.uv].dev-dependencies -- uv legacy dev deps
Returns (source_type, group_name) on match, or None if not found. source_type is one of "dependency-group", "optional-dep", "uv-dev".
#_resolve_pytest_invocation
def _resolve_pytest_invocation(project_dir: str, workspace_root: str | None) -> list[str]Build the pytest command for a project based on its environment.
For workspace members, returns plain uv run pytest (the workspace venv has everything). For standalone projects, probes pyproject.toml to determine the correct uv flags.
Raises ConfigError if pytest is not declared anywhere in pyproject.toml.
#run_project_tests
def run_project_tests(target_name: str, *, project_dir: str | None=None, workspace_root: str | None=None, skip_sync: bool=False, config: dict | None=None, dry_run: bool=False) -> boolRun tests for the given project target type.
Args:
target_name: registry/target identifier (e.g., "pypi", "go", "npm").project_dir: working directory for subprocess calls. None means cwd.workspace_root: uv workspace root for monorepos. When set, uv sync
runs here instead of at project_dir.
skip_sync: if True, skip the uv sync step (caller already synced).config: project config dict. Used to read uv_sync_verbose for pypi.dry_run: if True, skip all subprocess execution and return True.
Returns True if tests pass (or are skipped), False on failure. Does NOT call sys.exit -- that is the caller's responsibility.
#_run_pypi_tests
def _run_pypi_tests(*, project_dir: str | None, workspace_root: str | None=None, skip_sync: bool=False, config: dict, check_timeout: int=120) -> boolRun Python tests via uv or bare pytest.
For workspace members: syncs at workspace root, then runs uv run pytest. For standalone projects: skips sync (uv run handles it), uses _resolve_pytest_invocation to build the correct command. Falls back to bare pytest when uv is not installed.
#_run_go_tests
def _run_go_tests(*, project_dir: str | None, check_timeout: int=120) -> boolRun Go tests.
#_run_maven_tests
def _run_maven_tests(*, project_dir: str | None, check_timeout: int=120) -> boolRun Maven/Gradle tests.
Prefers ./gradlew test if gradlew exists, otherwise falls back to mvn test if pom.xml exists.
#_run_npm_tests
def _run_npm_tests(*, project_dir: str | None, check_timeout: int=120) -> boolRun npm tests if a test script is defined in package.json.