Skip to content

Commit ad73342

Browse files
authored
Merge pull request #92 from tschm/rhiza_v1.3.3_tests
chore: update .rhiza/tests to the rhiza v1.3.3 layout, and make it pass
2 parents a624690 + da3690a commit ad73342

26 files changed

Lines changed: 462 additions & 2628 deletions

‎.rhiza/tests/README.md‎

Lines changed: 40 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,41 @@
1-
# Rhiza Test Suite
1+
# Rhiza Test Suite (`.rhiza/tests/`)
22

3-
This directory contains the comprehensive test suite for the Rhiza project.
3+
This directory is **synced from [jebel-quant/rhiza](https://github.com/jebel-quant/rhiza)**
4+
and runs in your project with `make rhiza-test`. Its job is to validate the parts of *your*
5+
repository that Rhiza cares about — the metadata, release config, docs and docstrings that
6+
vary per project — using the shared fixtures below.
47

5-
## Test Organization
8+
> Tests that only exercise Rhiza's *own* template files (Makefile targets, workflow stubs,
9+
> the project skeleton) live in Rhiza's mother-repo `tests/` suite and are **not** synced
10+
> here — they would be identical in every consumer and can't be changed downstream. Put
11+
> your project's own tests under your `tests/` directory, not here.
612
7-
Tests are organized into purpose-driven subdirectories:
13+
## Layout
814

9-
### `structure/`
10-
Static assertions about file and directory presence. These tests verify that the repository contains the expected files, directories, and configuration structure without executing any subprocesses.
15+
The suite is flat — one file per concern — but **which files you get depends on the
16+
bundles you sync**. Each is owned by whichever bundle the assertion belongs to, so a Rust
17+
project gets the Rust manifest checks and none of the Python ones:
1118

12-
- `test_project_layout.py` — Validates root-level files and directories
13-
- `test_requirements.py` — Validates `.rhiza/requirements/` structure
19+
| file | owned by | checks |
20+
| --- | --- | --- |
21+
| `conftest.py` | `core` | shared fixtures (`root`, `logger`, `latest_tag`) |
22+
| `test_release_tags.py` | `core` | the newest tag is reachable from a branch |
23+
| `test_readme.py` | `core` | README exists; every `bash` fence parses |
24+
| `test_pyproject.py` | `python-core` | `pyproject.toml` structure, and its `[tool.bumpversion]` block |
25+
| `test_docstrings.py` | `python-core` | doctests across the modules in your source folder |
26+
| `test_readme_validation.py` | `tests` | executes `python` fences and diffs them against `result` (see below) |
27+
| `test_cargo_toml.py` | `rust-core` | `Cargo.toml` structure and the `.bumpversion.toml` wiring |
28+
| `test_go_module.py` | `go-core` | `go.mod`, the `Version` constant, and the same wiring |
1429

15-
### `api/`
16-
Makefile target validation via dry-runs. These tests verify that Makefile targets are properly defined and would execute the expected commands.
30+
Every profile pairs `core` with exactly one language layer, so `conftest.py` is always
31+
present alongside whichever layer's modules arrived.
1732

18-
- `test_makefile_targets.py` — Core Makefile targets (install, test, fmt, etc.)
19-
- `test_makefile_api.py` — Makefile API (delegation, extension, hooks, overrides)
20-
- `test_github_targets.py` — GitHub-specific Makefile targets
33+
### Skipping README code blocks with `+RHIZA_SKIP`
2134

22-
### `integration/`
23-
Tests requiring sandboxed git repositories or subprocess execution. These tests verify end-to-end workflows.
24-
25-
- `test_release.py` — Release script functionality
26-
- `test_book_targets.py` — Documentation book build targets
27-
28-
### `sync/`
29-
Template sync, workflows, versioning, and content validation tests. These tests ensure that template synchronization and content validation work correctly.
30-
31-
- `test_rhiza_version.py` — Version reading and workflow validation
32-
- `test_readme_validation.py` — README code block execution and validation
33-
- `test_docstrings.py` — Doctest validation across source modules
34-
35-
#### Skipping README code blocks with `+RHIZA_SKIP`
36-
37-
By default, every `python` and `bash` code block in `README.md` is executed or
38-
syntax-checked by `test_readme_validation.py`. To mark a block as intentionally
39-
non-runnable (e.g. illustrative snippets or environment-specific commands), add
40-
`+RHIZA_SKIP` to the opening fence line:
35+
By default, every `bash` fence in `README.md` is syntax-checked (`test_readme.py`, any
36+
language) and every `python` fence is executed (`test_readme_validation.py`, Python
37+
projects). To mark a block as intentionally non-runnable — an illustrative snippet, an
38+
environment-specific command — add `+RHIZA_SKIP` to the opening fence line:
4139

4240
~~~markdown
4341
```python +RHIZA_SKIP
@@ -56,114 +54,28 @@ Markdown renderers (including GitHub) ignore everything after the first word on
5654
a fence line, so the block still renders as a normal highlighted code block.
5755
Blocks without `+RHIZA_SKIP` continue to be validated as before.
5856

59-
### `utils/`
60-
Tests for utility code and test infrastructure. These tests validate the testing framework itself and utility scripts.
61-
62-
- `test_git_repo_fixture.py` — Validates the `git_repo` fixture
63-
64-
### `deps/`
65-
Dependency validation tests. These tests ensure that project dependencies are correctly specified and healthy.
66-
67-
- `test_dependency_health.py` — Validates pyproject.toml and requirements files
68-
69-
### `stress/`
70-
Stress tests that verify Rhiza's stability under heavy load. These tests execute Rhiza-specific operations under concurrent load and repeated execution to detect race conditions, resource leaks, and performance degradation.
71-
72-
- `test_makefile_stress.py` — Makefile operations under concurrent/repeated load
73-
- `test_git_stress.py` — Git operations under concurrent load
74-
75-
See [stress/README.md](stress/README.md) for detailed documentation.
76-
7757
## Running Tests
7858

79-
### Run all tests
80-
```bash
81-
uv run pytest .rhiza/tests/
82-
# or
83-
make test
84-
```
85-
86-
### Run tests from a specific category
87-
```bash
88-
uv run pytest .rhiza/tests/structure/
89-
uv run pytest .rhiza/tests/api/
90-
uv run pytest .rhiza/tests/integration/
91-
uv run pytest .rhiza/tests/sync/
92-
uv run pytest .rhiza/tests/utils/
93-
uv run pytest .rhiza/tests/deps/
94-
uv run pytest .rhiza/tests/stress/
95-
```
96-
97-
### Run stress tests with custom parameters
98-
```bash
99-
# Run all stress tests (default: 100 iterations, 10 workers)
100-
uv run pytest .rhiza/tests/stress/ -v
101-
102-
# Run with fewer iterations (faster)
103-
uv run pytest .rhiza/tests/stress/ -v --iterations=10
104-
105-
# Skip stress tests when running full test suite
106-
uv run pytest .rhiza/tests/ -v -m "not stress"
107-
```
108-
109-
### Run a specific test file
110-
```bash
111-
uv run pytest .rhiza/tests/structure/test_project_layout.py
112-
```
113-
114-
### Run with verbose output
115-
```bash
116-
uv run pytest .rhiza/tests/ -v
117-
```
118-
119-
### Run with coverage
12059
```bash
121-
uv run pytest .rhiza/tests/ --cov
60+
make rhiza-test # run this suite (the usual entry point)
61+
uv run pytest .rhiza/tests/ # equivalent, direct invocation
62+
uv run pytest .rhiza/tests/test_pyproject.py # a single file
63+
uv run pytest .rhiza/tests/ -v # verbose
12264
```
12365

12466
## Fixtures
12567

126-
### Root-level fixtures (`conftest.py`)
127-
- `root` — Repository root path (session-scoped)
128-
- `logger` — Configured logger instance (session-scoped)
129-
- `git_repo` — Sandboxed git repository (function-scoped)
68+
Defined in `conftest.py` and available to every test without import:
13069

131-
### Category-specific fixtures
132-
- `api/conftest.py` — `setup_tmp_makefile`, `run_make`, `setup_rhiza_git_repo`
133-
- `sync/conftest.py` — `setup_sync_env`
70+
- `root` — repository root path (session-scoped)
71+
- `logger` — configured logger instance (session-scoped)
72+
73+
`.rhiza/tests` is on `pythonpath` (see `pytest.ini`), so intra-suite imports resolve
74+
without any `sys.path` manipulation.
13475

13576
## Writing Tests
13677

137-
### Conventions
13878
- Use descriptive test names that explain what is being tested
13979
- Group related tests in classes when appropriate
140-
- Use appropriate fixtures for setup/teardown
14180
- Add docstrings to test modules and complex test functions
14281
- Use `pytest.mark.skip` for tests that depend on optional features
143-
144-
### Import Patterns
145-
```python
146-
# Import shared helpers from test_utils
147-
from test_utils import strip_ansi, run_make, setup_rhiza_git_repo
148-
149-
# Import from local category conftest (for fixtures and category-specific helpers)
150-
from api.conftest import SPLIT_MAKEFILES, setup_tmp_makefile
151-
152-
# Note: Fixtures defined in conftest.py are automatically available in tests
153-
# and don't need to be explicitly imported
154-
```
155-
156-
## Test Coverage
157-
158-
The test suite aims for high coverage across:
159-
- Configuration validation (structure, dependencies)
160-
- Makefile target correctness (api)
161-
- End-to-end workflows (integration)
162-
- Template synchronization (sync)
163-
- Utility code (utils)
164-
165-
## Notes
166-
167-
- Benchmarks are located in `tests/benchmarks/` and run via `make benchmark`
168-
- Integration tests use sandboxed git repositories to avoid affecting the working tree
169-
- All Makefile tests use dry-run mode (`make -n`) to avoid side effects

‎.rhiza/tests/api/conftest.py‎

Lines changed: 0 additions & 98 deletions
This file was deleted.

‎.rhiza/tests/api/test_github_targets.py‎

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)