Skip to content

Commit

Permalink
test: gold files shouldn't be ignored
Browse files Browse the repository at this point in the history
I made a private copy of this repo to check something, and xml gold
tests were failing because my new private repo didn't have the
coverage.xml gold files, because they were in .gitignore.
  • Loading branch information
nedbat committed Jun 28, 2023
1 parent 44aa528 commit 7a32450
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
*.bak
.coverage
.coverage.*
coverage.xml
coverage.json
.metacov
.metacov.*
*.swp

# Data files we should ignore in the root, but need for gold files.
/coverage.xml
/coverage.json

# Stuff generated by editors.
.idea/
.vscode/
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ clean: clean_platform ## Remove artifacts of test execution, installation, etc
@rm -f *.bak */*.bak */*/*.bak */*/*/*.bak */*/*/*/*.bak */*/*/*/*/*.bak
@rm -f coverage/*,cover
@rm -f MANIFEST
@rm -f .coverage .coverage.* coverage.xml coverage.json .metacov*
@rm -f .coverage .coverage.* .metacov*
@rm -f coverage.xml coverage.json
@rm -f .tox/*/lib/*/site-packages/zzz_metacov.pth
@rm -f */.coverage */*/.coverage */*/*/.coverage */*/*/*/.coverage */*/*/*/*/.coverage */*/*/*/*/*/.coverage
@rm -f tests/covmain.zip tests/zipmods.zip tests/zip1.zip
Expand Down
4 changes: 2 additions & 2 deletions tests/goldtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ def save_mismatch(f: str) -> None:

assert not text_diff, "Files differ: " + "\n".join(text_diff)

assert not expected_only, f"Files in {expected_dir} only: {expected_only}"
assert not expected_only, f"Files in {os.path.abspath(expected_dir)} only: {expected_only}"
if not actual_extra:
assert not actual_only, f"Files in {actual_dir} only: {actual_only}"
assert not actual_only, f"Files in {os.path.abspath(actual_dir)} only: {actual_only}"


def contains(filename: str, *strlist: str) -> None:
Expand Down
3 changes: 2 additions & 1 deletion tests/test_goldtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ def test_actual_extra(self) -> None:
compare(gold_path("testing/getty"), "out", scrubs=SCRUBS, actual_extra=True)

# But not without it:
msg = r"Files in out only: \['another.more'\]"
# (test output is in files like /tmp/pytest-of-user/pytest-0/popen-gw3/t76/out)
msg = r"Files in .*[/\\]t\d+[/\\]out only: \['another.more'\]"
with pytest.raises(AssertionError, match=msg):
compare(gold_path("testing/getty"), "out", scrubs=SCRUBS)
self.assert_exists(os.path.join(TESTS_DIR, "actual/testing/getty/another.more"))
Expand Down

0 comments on commit 7a32450

Please sign in to comment.