|
| 1 | +# Testing Organization |
| 2 | + |
| 3 | +This document describes the test organization in the setuptools-scm monorepo. |
| 4 | + |
| 5 | +## Directory Structure |
| 6 | + |
| 7 | +The repository contains two test suites: |
| 8 | + |
| 9 | +- **`vcs-versioning/testing_vcs/`** - Core VCS versioning functionality tests |
| 10 | +- **`setuptools-scm/testing_scm/`** - Setuptools integration and wrapper tests |
| 11 | + |
| 12 | +## Separation Principle |
| 13 | + |
| 14 | +Tests are organized by architectural layer: |
| 15 | + |
| 16 | +### Core VCS Layer (`vcs-versioning/testing_vcs/`) |
| 17 | + |
| 18 | +Tests for core version control system functionality: |
| 19 | +- VCS backend operations (Git, Mercurial parsing) |
| 20 | +- Version scheme and formatting logic |
| 21 | +- Configuration validation |
| 22 | +- Version inference |
| 23 | +- Error handling |
| 24 | +- Core utility functions |
| 25 | + |
| 26 | +**When to add tests here:** If the functionality is in `vcs_versioning` package and doesn't depend on setuptools. |
| 27 | + |
| 28 | +### Setuptools Integration Layer (`setuptools-scm/testing_scm/`) |
| 29 | + |
| 30 | +Tests for setuptools-specific functionality: |
| 31 | +- Setuptools hooks and entry points |
| 32 | +- `setup.py` integration (` use_scm_version`) |
| 33 | +- `pyproject.toml` reading and Configuration.from_file() |
| 34 | +- File finding for setuptools (sdist integration) |
| 35 | +- Distribution metadata |
| 36 | +- setuptools-scm CLI wrapper |
| 37 | + |
| 38 | +**When to add tests here:** If the functionality is in `setuptools_scm` package or requires setuptools machinery. |
| 39 | + |
| 40 | +## Running Tests |
| 41 | + |
| 42 | +### Run all tests |
| 43 | +```bash |
| 44 | +uv run pytest -n12 |
| 45 | +``` |
| 46 | + |
| 47 | +### Run core VCS tests only |
| 48 | +```bash |
| 49 | +uv run pytest vcs-versioning/testing_vcs -n12 |
| 50 | +``` |
| 51 | + |
| 52 | +### Run setuptools integration tests only |
| 53 | +```bash |
| 54 | +uv run pytest setuptools-scm/testing_scm -n12 |
| 55 | +``` |
| 56 | + |
| 57 | +### Run specific test file |
| 58 | +```bash |
| 59 | +uv run pytest vcs-versioning/testing_vcs/test_version_schemes.py -v |
| 60 | +``` |
| 61 | + |
| 62 | +## Test Fixtures |
| 63 | + |
| 64 | +Both test suites use `vcs_versioning.test_api` as a pytest plugin, providing common test infrastructure: |
| 65 | + |
| 66 | +- `WorkDir`: Helper for creating temporary test repositories |
| 67 | +- `TEST_SOURCE_DATE`: Consistent test time for reproducibility |
| 68 | +- `DebugMode`: Context manager for debug logging |
| 69 | +- Repository fixtures: `wd`, `repositories_hg_git`, etc. |
| 70 | + |
| 71 | +See `vcs-versioning/src/vcs_versioning/test_api.py` and `vcs-versioning/src/vcs_versioning/_test_utils.py` for details. |
| 72 | + |
| 73 | +## Migration Notes |
| 74 | + |
| 75 | +File finders remain in setuptools-scm because they're setuptools integration (registered as `setuptools.file_finders` entry points), not core VCS functionality. |
| 76 | + |
| 77 | +For deeper unit test conversions beyond basic reorganization, see `setuptools-scm/testing_scm/INTEGRATION_MIGRATION_PLAN.md`. |
| 78 | + |
0 commit comments