[Improvement] Add an integration test for checking that PRs do not leave unchecked files behind
Describe the bug
We have been having 2 cases in the last 2 weeks where tests/host_tools/uffd/Cargo.lock was left behind and not checked in as part of the PR changes that dirtied it.
Would be nice to avoid this situations by implementing a integ test for ensuring that git does not report any dirty file.
Checks
- [x] Have you searched the Firecracker Issues database for similar problems?
- [x] Have you read the existing relevant Firecracker documentation?
- [x] Are you certain the bug being reported is a Firecracker issue?
There is already a similar test here: https://github.com/firecracker-microvm/firecracker/blob/main/tests/integration_tests/style/test_repo.py Should be easy to extend.
However, the test would have to run last, and I think that's not easy to do with pytest.
Apparently it would be possible to use an "autouse" fixture that has an assert for this in its teardown logic: https://stackoverflow.com/questions/22627659/run-code-before-and-after-each-test-in-py-test
Ah yes, that's a good approach. Something like this should work then
@pytest.fixture(autouse=True, scope="session")
def check_nothing_added_after_all_tests_run():
yield None
# check that git working copy is clean
assert check_output("git status --porcelain") == ""