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

[ci] Correct file management in tests #18341

Merged
merged 1 commit into from Aug 16, 2019

Conversation

jugglinmike
Copy link
Contributor

The mkstemp function creates a file and opens that file [1], so these
tests erroneously attempted to delete an open file. This mistake was not
identified during development or automated testing because it only leads
to a runtime exception in Windows environments [2].

Refactor the helper function to close the file immediately after writing
to it.

[1] > mkstemp() returns a tuple containing an OS-level handle to an
> open file (as would be returned by os.open()) and the absolute
> pathname of that file, in that order.

https://docs.python.org/2/library/tempfile.html#tempfile.mkstemp

[2] > On Windows, attempting to remove a file that is in use causes an
> exception to be raised; on Unix, the directory entry is removed
> but the storage allocated to the file is not made available until
> the original file is no longer in use.

https://docs.python.org/2/library/os.html#os.remove

This resolves gh-18255.

The `mkstemp` function creates a file and opens that file [1], so these
tests erroneously attempted to delete an open file. This mistake was not
identified during development or automated testing because it only leads
to a runtime exception in Windows environments [2].

Refactor the helper function to close the file immediately after writing
to it.

[1] > `mkstemp()` returns a tuple containing an OS-level handle to an
    > open file (as would be returned by `os.open()`) and the absolute
    > pathname of that file, in that order.

    https://docs.python.org/2/library/tempfile.html#tempfile.mkstemp

[2] > On Windows, attempting to remove a file that is in use causes an
    > exception to be raised; on Unix, the directory entry is removed
    > but the storage allocated to the file is not made available until
    > the original file is no longer in use.

    https://docs.python.org/2/library/os.html#os.remove
@jugglinmike jugglinmike merged commit 7f35d6c into web-platform-tests:master Aug 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tools\ci\tests\test_update_pr_preview.py fails on Windows
5 participants