Skip to content
rlsbl.testing
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).

#_overlay_exclusions

python
def _overlay_exclusions(overlays: list[dict] | None) -> list[str]

Return the --no-install-package <pkg> arguments that keep declared dev overlays out of a sync, or [] in registry mode.

Paired with --inexact (which stops the sync removing packages uv did not install), this is the same pair rlsbl dev sync and the sandboxed test runner use. Without it an exact sync reinstalls the locked registry wheel over the editable checkout, with no output saying so.

#collect_active_overlays

python
def collect_active_overlays(project_dirs) -> list[dict]

Union the active dev overlays declared by project_dirs.

A workspace's members share one environment, so a sync at the workspace root must exclude every member's overlaid packages, not just one project's. Raises :class:OverlayModeConflictError when two projects overlay the same package from different checkouts -- one shared environment cannot hold both, and picking either silently would wipe the other.

#_sync_selector_args

python
def _sync_selector_args(run_cmd: list[str]) -> list[str]

Extract the --group/--extra selectors from a resolved uv run invocation, so an explicit uv sync installs exactly what the suite runs with. Reading them back off the command keeps one source for the choice.

#sync_workspace

python
def sync_workspace(workspace_root: str, *, verbose: bool=False, check_timeout: int=120, overlays: list[dict] | None=None) -> bool

Run uv sync --all-packages at the workspace root.

In overlay mode (overlays non-empty) the sync additionally carries --inexact and one --no-install-package per overlaid package, so a workspace whose environment holds editable sibling checkouts is synced without wiping them.

Returns True on success, False on failure.

#_probe_pytest_location

python
def _probe_pytest_location(project_dir: str) -> tuple[str, str] | None

Detect where pytest is declared in a project's pyproject.toml.

Checks in order:

  1. [dependency-groups].* -- any group containing a pytest entry
  2. [project.optional-dependencies].* -- any extra containing pytest
  3. [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

python
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 python -P -m 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.

#_pytest_marker_args

python
def _pytest_marker_args(config: dict) -> list[str]

Return ["-m", <markers>] when a test.pypi.markers string is configured, else [].

Reads the per-target test block via config.get("test", {}).get("pypi", {}) so future per-target options (go tags, npm script selection) slot into the same shape. An absent section/key -- or an empty/falsy markers value -- yields no arguments, keeping the pytest invocation byte-identical to the no-config case. Structural validation (unknown keys, non-string/empty markers) is enforced upstream by config.validate_test_config.

#resolve_test_timeout

python
def resolve_test_timeout(config: dict | None, check_timeout: int | None) -> int

Resolve the subprocess budget for a test run.

An explicit check_timeout from the caller wins; otherwise the project's configured check timeout applies.

#run_project_tests

python
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)

Run the built-in test suite for the given target.

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.

Returns a SuiteRunOutcome. Does NOT call sys.exit -- that is the caller's responsibility.

The dispatch is the target protocol. This function used to be a chain of name comparisons ending in return True, so a target with no runner -- or a name that was not a target at all -- reported a PASSING test step for a suite that never ran. A target that cannot run tests now answers SKIPPED naming itself, and the caller renders that as a visible skip line.

No dry-run parameter: the test suite reaches this through the impure test-suite check, which the check framework already lists rather than runs under --dry-run. The parameter this function used to carry was never passed by any caller, and a second, hand-rolled skip would be a second place for the two answers to disagree.

#_run_pypi_tests

python
def _run_pypi_tests(*, project_dir: str | None, workspace_root: str | None=None, skip_sync: bool=False, config: dict, check_timeout: int=120) -> bool

Run Python tests via uv or bare pytest.

For workspace members: syncs at workspace root, then runs uv run python -P -m pytest. For standalone projects: skips sync (uv run handles it), uses _resolve_pytest_invocation to build the correct command. Falls back to python -P -m pytest when uv is not installed.

When the project declares dev overlays and the sentinel agrees, every uv invocation here is overlay-preserving: the sync excludes the overlaid packages and uv run is given --no-sync. Otherwise this runner would reinstall the locked registry wheels over the editable checkouts -- testing released code while destroying the state dev-overlay-drift then fails on. A declaration and a sentinel that disagree are a hard error, since neither mode is then true.

#_run_go_tests

python
def _run_go_tests(*, project_dir: str | None, check_timeout: int=120) -> bool

Run Go tests.

#_run_maven_tests

python
def _run_maven_tests(*, project_dir: str | None, check_timeout: int=120) -> bool

Run Maven/Gradle tests.

Prefers ./gradlew test if gradlew exists, otherwise falls back to mvn test if pom.xml exists.

#_run_npm_tests

python
def _run_npm_tests(*, project_dir: str | None, check_timeout: int=120) -> bool

Run npm tests if a test script is defined in package.json.

More tools from this site

  • claudestream Drive Claude Code from Python: run it as a subprocess and read its output as typed events, with async and sync sessions, sandbox policies, and tools you define in Python
  • claudewheel A TUI Claude Code Launcher that lets you have more than one profile, manage sessions lifecycle, pick the exact CC version, model to use (even older unlisted ones), pick which GitHub account to use, etc.
  • dirstat Fast, single-binary directory statistics CLI: every file under a tree grouped by format, with counts, sizes, and lines of code, as a colored terminal table or as JSON
  • fastware A batteries-included ASGI framework: msgspec JSON, a managed Granian server, dependency injection, SSE, WebSockets, auth, and a test client
  • go-toml-edit Zero-dep TOML editing library for Go with comment preservation
  • howmuchleft The fastest Claude Code statusline: context window, 5-hour, and weekly limit usage as three customizable gradient bars, rendering in about 6 ms
  • orxtra
  • pgdesign
  • predraw Declarative rendering pipeline: describe a scene in JSON and get SVG, PNG and WebP out, with light and dark style tokens, reusable components and text converted to path outlines
  • reposummary Turn a git repository's history into a Markdown journal: pick a time window or revision range and get a readable digest of what changed, optionally narrated by an LLM
  • safegit git wrapper CLI that gives each commit its own temporary index and retries ref updates on conflict, so concurrent agents share one repository
  • saferm Command-line replacement for rm that archives every deletion with a mandatory reason and the context it ran in, so deleted files can be listed, inspected and restored
  • selfdoc Static Site Generator that builds a project's documentation site directly from its source code, so the docs can never drift from the code they describe, with SEO/AEO, first-class blog, search, and cross-project linking built in
  • strictcli
  • stricttest An always-on test-isolation floor: a pytest plugin and a Go env-hygiene module that make a test suite structurally unable to reach real credentials, the real HOME, the network, or the development repository.
  • wesktop A Python framework that turns an ASGI web app into a desktop application, serving it from a local Granian server and displaying it in a native OS window via pywebview
Search