|
| 1 | +## Setuptools integration test migration plan |
| 2 | + |
| 3 | +Purpose: streamline/simplify integration codepaths and make tests faster and easier to write by preferring unit-level inference over setuptools-driven E2E where possible. |
| 4 | + |
| 5 | +Reference helper for unit tests: |
| 6 | + |
| 7 | +```python |
| 8 | +from setuptools_scm._integration.pyproject_reading import PyProjectData |
| 9 | +from setuptools_scm._integration.version_inference import infer_version_string |
| 10 | + |
| 11 | +version = infer_version_string( |
| 12 | + dist_name="pkg", |
| 13 | + pyproject_data=PyProjectData.for_testing(project_present=True, section_present=True, project_name="pkg"), |
| 14 | + overrides={"fallback_version": "1.2.3"}, |
| 15 | +) |
| 16 | +``` |
| 17 | + |
| 18 | +### Completed |
| 19 | +- [x] Introduced `infer_version_string` pure helper to compute versions without a `Distribution` or `setup.py`. |
| 20 | + |
| 21 | +### Migration candidates (replace E2E/Distribution-hook tests with unit inference) |
| 22 | +- [ ] `testing/test_integration.py::test_pyproject_support` |
| 23 | + - Proposed unit: `test_infer_fallback_version_from_pyproject` |
| 24 | + - Notes: Use `PyProjectData.for_testing(..., section_present=True, project_present=True)` + overrides `{fallback_version: "12.34"}`. |
| 25 | + |
| 26 | +- [ ] `testing/test_integration.py::test_setuptools_version_keyword_ensures_regex` |
| 27 | + - Proposed unit: `test_infer_tag_regex_from_overrides` |
| 28 | + - Notes: Create repo/tag in `wd`, call `infer_version_string(..., overrides={"tag_regex": "(1.0)"})`. |
| 29 | + |
| 30 | +- [ ] `testing/test_basic_api.py::test_parentdir_prefix` |
| 31 | + - Proposed unit: `test_infer_parentdir_prefix_version` |
| 32 | + - Notes: Use directory name prefix and `{parentdir_prefix_version: "projectname-"}`. |
| 33 | + |
| 34 | +- [ ] `testing/test_basic_api.py::test_fallback` |
| 35 | + - Proposed unit: `test_infer_fallback_version` |
| 36 | + - Notes: `{fallback_version: "12.34"}`. |
| 37 | + |
| 38 | +- [ ] `testing/test_basic_api.py::test_empty_pretend_version` |
| 39 | + - Proposed unit: `test_infer_with_empty_pretend_uses_fallback` |
| 40 | + - Notes: Set `SETUPTOOLS_SCM_PRETEND_VERSION=""`, infer with fallback. |
| 41 | + |
| 42 | +- [ ] `testing/test_basic_api.py::test_empty_pretend_version_named` |
| 43 | + - Proposed unit: `test_infer_with_empty_named_pretend_uses_fallback` |
| 44 | + - Notes: Use named pretend env var and fallback. |
| 45 | + |
| 46 | +- [ ] `testing/test_regressions.py::test_use_scm_version_callable` |
| 47 | + - Proposed unit: `test_infer_with_callable_version_scheme` |
| 48 | + - Notes: Pass callable via `overrides={"version_scheme": callable}` to `infer_version_string`. |
| 49 | + |
| 50 | +- [ ] `testing/test_git.py::test_root_relative_to` |
| 51 | + - Proposed unit: `test_configuration_absolute_root_resolution` |
| 52 | + - Notes: Assert `Configuration.absolute_root` behavior or use `Configuration.from_data(..., root/relative_to)`; avoid `setup.py`. |
| 53 | + |
| 54 | +- [ ] `testing/test_git.py::test_root_search_parent_directories` |
| 55 | + - Proposed unit: `test_configuration_search_parent_directories` |
| 56 | + - Notes: Prefer `Configuration(search_parent_directories=True)` + direct `_get_version` or `infer_version_string`. |
| 57 | + |
| 58 | +### Tests to keep as integration/E2E |
| 59 | +- `testing/test_integration.py::test_integration_function_call_order` |
| 60 | + - Validates precedence/ordering between `infer_version` and `version_keyword` hooks on `Distribution`. |
| 61 | + |
| 62 | +- `testing/test_integration.py::test_distribution_provides_extras` |
| 63 | + - Verifies installed distribution metadata (extras exposure). |
| 64 | + |
| 65 | +- `testing/test_integration.py::test_git_archival_plugin_ignored` |
| 66 | + - Entry point filtering behavior. |
| 67 | + |
| 68 | +- `testing/test_git.py::test_git_version_unnormalized_setuptools` (parameterized) |
| 69 | + - Asserts difference between file write (`write_to` non-normalized) vs setuptools-normalized dist metadata. Requires setuptools behavior; not reproducible by pure helper. |
| 70 | + |
| 71 | +- Maintain a minimal smoke test to ensure `setup.py --version` works end-to-end (one per major path). |
| 72 | + |
| 73 | +### Already covered by unit-level decision tests (no action) |
| 74 | +- `testing/test_version_inference.py` suite |
| 75 | + - Exercises `get_version_inference_config` across configuration matrices using `PyProjectData.for_testing`. |
| 76 | + |
| 77 | +### New unit tests to add (pure inference) |
| 78 | +- [ ] `test_infer_local_scheme_no_local_version` |
| 79 | + - Use `PyProjectData.for_testing(section_present=True, project_present=True, local_scheme="no-local-version")`. |
| 80 | + |
| 81 | +- [ ] `test_infer_with_env_pretend_version_and_metadata` |
| 82 | + - Set pretend version + metadata env vars; assert combined result via `infer_version_string`. |
| 83 | + |
| 84 | +- [ ] `test_infer_respects_nested_scm_git_config` |
| 85 | + - Provide nested TOML-equivalent via `overrides={"scm": {"git": {"pre_parse": "fail_on_missing_submodules"}}}`. |
| 86 | + |
| 87 | +### Notes and pitfalls |
| 88 | +- Some behaviors are specific to setuptools (normalization of dist metadata vs written file contents) and should remain integration tests. |
| 89 | +- Prefer `PyProjectData.for_testing(...)` to avoid file I/O in new unit tests. |
| 90 | +- For tests that assert version-file writing, call `infer_version_string(..., force_write_version_files=True)` and set `write_to`/`version_file` in overrides. |
| 91 | + |
| 92 | + |
0 commit comments