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

TestCase : Temp directory access improvements #6204

Merged
merged 3 commits into from
Jan 13, 2025

Conversation

ericmehl
Copy link
Collaborator

This improves a few things with TestCase.tearDown :

  • We were always creating the temporary directory when setting descendant files to read / write / execute permissions. Now we are only setting those permissions if the directory exists.
  • Windows uses a somewhat strange permissions scheme, this ensures the temporary directory is able to be deleted in tearDown(). I did a double check to make sure the call to icacls doesn't increase the overall test times too much. It does increase the time relatively, but when testing GafferSceneTest, it was adding up to only a bit over half a second.
  • We had been skipping the GafferImage.CatalogueTest.testNonWritableDirectory on Windows because it was thought Windows couldn't make a directory truly read-only. Using extended permissions allows that, so this test can be adapted and enabled.

Checklist

  • I have read the contribution guidelines.
  • I have updated the documentation, if applicable.
  • I have tested my change(s) in the test suite, and added new test cases where necessary.
  • My code follows the Gaffer project's prevailing coding style and conventions.

@ericmehl ericmehl changed the base branch from 1.5_maintenance to 1.4_maintenance January 10, 2025 16:22
Copy link
Member

@johnhaddon johnhaddon left a comment

Choose a reason for hiding this comment

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

Thanks Eric! Could you address my minor quibbles and then go ahead and merge please?

if self.__temporaryDirectory is not None :
for root, dirs, files in os.walk( self.temporaryDirectory() ) :
Copy link
Member

Choose a reason for hiding this comment

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

Minor quibble - let's use __temporaryDirectory here rather than temporaryDirectory(), to match the other uses in this block. We're saying "the directory we made it earlier" rather than "make the directory".

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sounds good, fixed in 2d73134

@@ -115,6 +115,9 @@ def tearDown( self ) :
IECore.RefCounted.collectGarbage()

if self.__temporaryDirectory is not None :
if os.name == "nt" :
subprocess.check_call( [ "icacls", self.temporaryDirectory(), "/grant", "Users:(OI)(CI)(W)" ] )
Copy link
Member

Choose a reason for hiding this comment

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

Same quibble again.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in f0575ef

@ericmehl
Copy link
Collaborator Author

Great! Fixed up, squashed down and merging.

@ericmehl ericmehl merged commit 04f38a7 into GafferHQ:1.4_maintenance Jan 13, 2025
5 checks passed
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.

2 participants