Skip to content

Commit 696d83c

Browse files
committed
test: fix coverage issues due to monkeypatch.chdir()
1 parent 0443e22 commit 696d83c

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

tests/capture_tools_output/test_database_path.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def test_db_detection(
3838
expected_args: List[str],
3939
):
4040
"""test clang-tidy using a implicit path to the compilation database."""
41+
monkeypatch.setenv("COVERAGE_FILE", str(Path.cwd() / ".coverage"))
4142
monkeypatch.chdir(PurePath(__file__).parent.parent.as_posix())
4243
monkeypatch.setenv("CPP_LINTER_PYTEST_NO_RICH", "1")
4344
CACHE_PATH.mkdir(exist_ok=True)
@@ -78,6 +79,7 @@ def test_ninja_database(monkeypatch: pytest.MonkeyPatch, tmp_path: Path):
7879
ignore=shutil.ignore_patterns("compile_flags.txt"),
7980
)
8081
(tmp_path_demo / "build").mkdir(parents=True)
82+
monkeypatch.setenv("COVERAGE_FILE", str(Path.cwd() / ".coverage"))
8183
monkeypatch.chdir(str(tmp_path_demo))
8284
monkeypatch.setattr(sys, "argv", ["meson", "init"])
8385
meson()

tests/capture_tools_output/test_tools_output.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ def prep_tmp_dir(
115115
copy_configs: bool = False,
116116
):
117117
"""Some extra setup for test's temp directory to ensure needed files exist."""
118+
monkeypatch.setenv("COVERAGE_FILE", str(Path.cwd() / ".coverage"))
118119
monkeypatch.chdir(str(tmp_path))
119120
gh_client = prep_api_client(
120121
monkeypatch,
@@ -382,6 +383,7 @@ def test_tidy_annotations(
382383

383384
def test_all_ok_comment(tmp_path: Path, monkeypatch: pytest.MonkeyPatch):
384385
"""Verify the comment is affirmative when no attention is needed."""
386+
monkeypatch.setenv("COVERAGE_FILE", str(Path.cwd() / ".coverage"))
385387
monkeypatch.chdir(str(tmp_path))
386388

387389
files: List[FileObj] = [] # no files to test means no concerns to note

tests/reviews/test_pr_review.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ def test_post_review(
9393
monkeypatch.setenv("GITHUB_TOKEN", "123456")
9494
if summary_only:
9595
monkeypatch.setenv("CPP_LINTER_PR_REVIEW_SUMMARY_ONLY", "true")
96+
monkeypatch.setenv("COVERAGE_FILE", str(Path.cwd() / ".coverage"))
9697
monkeypatch.chdir(str(tmp_path))
9798
(tmp_path / "src").mkdir()
9899
demo_dir = Path(__file__).parent.parent / "demo"

0 commit comments

Comments
 (0)