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

ApplicationTest : Increase pause before checking process name (2nd attempt) #6165

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Fixes
- Fixed bug where the value dragged from the visualiser would be slightly different from the initial value on button press. (#6191)
- Fixed error when trying to visualise data unsupported data.
- TweakPlug : Fixed preservation of geometric interpretation when tweaking V3f values.
- ApplicationTest : Extended grace period when testing process name on slower hosts.

API
---
Expand Down
28 changes: 22 additions & 6 deletions python/GafferTest/ApplicationTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,29 @@ def testWrapperDoesntDuplicatePaths( self ) :
def testProcessName( self ) :

process = subprocess.Popen( [ str( Gaffer.executablePath() ), "env", "sleep", "100" ] )
time.sleep( 1 )
command = subprocess.check_output( [ "ps", "-p", str( process.pid ), "-o", "command=" ], universal_newlines = True ).strip()
name = subprocess.check_output( [ "ps", "-p", str( process.pid ), "-o", "comm=" ], universal_newlines = True ).strip()
process.kill()
try :
startTime = time.time()
while True :
time.sleep( 0.1 )
command = subprocess.check_output( [ "ps", "-p", str( process.pid ), "-o", "command=" ], universal_newlines = True ).strip()
name = subprocess.check_output( [ "ps", "-p", str( process.pid ), "-o", "comm=" ], universal_newlines = True ).strip()
try :
self.assertEqual( command, "gaffer env sleep 100" )
self.assertEqual( name, "gaffer" )

except self.failureException :
# It can take some time for gaffer to change its own process name, which varies
# based on the host's performance.
# For that reason, we check until 3 seconds have passed before giving up.
if time.time() - startTime > 3.0 :
raise

else :
break

finally :
process.kill()

self.assertEqual( command, "gaffer env sleep 100" )
self.assertEqual( name, "gaffer" )

if __name__ == "__main__":
unittest.main()