firecracker icon indicating copy to clipboard operation
firecracker copied to clipboard

[Improvement] Add an integration test for checking that PRs do not leave unchecked files behind

Open dianpopa opened this issue 3 years ago • 4 comments

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?

dianpopa avatar Dec 12 '22 14:12 dianpopa

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.

pb8o avatar Dec 27 '22 09:12 pb8o

However, the test would have to run last, and I think that's not easy to do with pytest.

pb8o avatar Dec 27 '22 12:12 pb8o

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

roypat avatar Feb 17 '23 16:02 roypat

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") == ""

pb8o avatar Feb 22 '23 13:02 pb8o