Skip to content

Commit e96c350

Browse files
authored
test: take the repo root from pytest so the ADR check can run from a fetched copy (#119)
1 parent 821753a commit e96c350

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎tests/test_adr_citations.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
import re
55
import typing
66

7+
import pytest
8+
79

8-
_REPO_ROOT: typing.Final = pathlib.Path(__file__).resolve().parent.parent
910
_ADR_DIR: typing.Final = "docs/adr/"
1011
_CITATION: typing.Final = re.compile(r"docs/adr/\d{4}(?:-[a-z0-9-]+\.md)?")
1112
_UNWALKED_DIR: typing.Final = "node_modules"
@@ -38,7 +39,7 @@ def unresolved_citations(root: pathlib.Path) -> list[tuple[str, str]]:
3839
)
3940

4041

41-
def test_every_adr_path_cited_from_python_resolves() -> None:
42+
def test_every_adr_path_cited_from_python_resolves(pytestconfig: pytest.Config) -> None:
4243
"""INVARIANT: a `docs/adr/NNNN-<slug>.md` path named anywhere in this repo's Python exists.
4344
4445
Broken by renaming, renumbering or pruning an ADR without following its citations. The
@@ -48,7 +49,7 @@ def test_every_adr_path_cited_from_python_resolves() -> None:
4849
A bare `docs/adr/NNNN` is reported as well: it names no file, so it would survive the same
4950
rename or drop unnoticed and point at whatever record holds that number next.
5051
"""
51-
unresolved = unresolved_citations(_REPO_ROOT)
52+
unresolved = unresolved_citations(pytestconfig.rootpath)
5253

5354
assert unresolved == [], "\n".join(f"{file} cites {cited}" for file, cited in unresolved)
5455

0 commit comments

Comments
 (0)