Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: don't delete open files #1346

Merged
merged 3 commits into from
Apr 12, 2021
Merged

Conversation

jku
Copy link
Member

@jku jku commented Apr 12, 2021

All three commits are basically the same thing: make sure tests remove temporary directories after any other teardown (most importantly: kill test servers before removing temp directories). First commit should actually fix a visible bug on windows CI (#1344), second is just good practice, third commit fixes a bug that is currently hidden by Modified_Testcase.

Long term thoughts:

  • having a helper that handles server process and tempdir cleanup might be a good idea but I'm not sure Modified_Testcase is helping more than it's obfuscating? I'm not sure if the temp dir stuff is even directly needed in the tests, the common needs are these I think:
    • class must be able to serve repository that all its tests run against
    • test instance must be able to serve it's own repository (because it wants to modify the contents)
    • the served repository paths must be exposed so the content can be modified during test
    • So we could just always have one test server per class, and the repos are just copied in the served directory: either a repo dir per class or test-specific ones
  • creating temp directories in current working directory is a bit obnoxious...

Jussi Kukkonen added 3 commits April 12, 2021 11:55
Make sure test server processes are killed before the temporary
directories are removed.

Let Modified_Testcase handle the top-level temporary directory.
Don't let Modified_testcase handle any subdirectories because:
 * teardown will try to remove them in the wrong order
 * removing the top level is enough

Fixes theupdateframework#1344

Signed-off-by: Jussi Kukkonen <[email protected]>
Call the parent (Modified_Testcase) tearDown as the last thing in
tearDown(). This is good practice anyway and in practice may prevent
bugs where the instance needs to cleanup something before
Modified_Testcase removes the temp dir.

In practice there does not seem to be visible bugs in these tests
(as the all have top level temp directory handling in tearDownClass())

Signed-off-by: Jussi Kukkonen <[email protected]>
These tests seem to try to remove temp files before the processes
using those files had stopped. This likely lead to an error (and
dangling temp files) on Windows, but Modified_Testcase hides the error

Make sure temp directories are removed as the last thing in teardown.

Signed-off-by: Jussi Kukkonen <[email protected]>
@jku
Copy link
Member Author

jku commented Apr 12, 2021

This does seem to fix #1344 (I tested by running the tests a few times with rzr's interpreter commit: all green).

@jku jku marked this pull request as ready for review April 12, 2021 10:24
@jku jku changed the title Windows file in use tests: don't delete open files Apr 12, 2021
@jku jku linked an issue Apr 12, 2021 that may be closed by this pull request
Copy link
Member

@joshuagl joshuagl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes LGTM, thanks @jku ! Could you capture your long-term thoughts in an Issue before closing this PR?

@jku jku merged commit 58b1a75 into theupdateframework:develop Apr 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tests: WinError 32 on CI again
3 participants