Skip to content

Fix test runner warning caused by previous commit, and rename calculateDuration() to calculateElapsed() to avoid confusing/overloading similar terms. #24402

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

Merged
merged 1 commit into from
May 24, 2025
Merged
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
14 changes: 8 additions & 6 deletions test/parallel_testsuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,11 @@ def __init__(self):
def test(self):
return self.buffered_result.test

def calculateDuration(self):
self.test_duration = time.perf_counter() - self.start_time
return self.test_duration
def addDuration(self, test, elapsed):
self.test_duration = elapsed

def calculateElapsed(self):
return time.perf_counter() - self.start_time

def updateResult(self, result):
result.startTest(self.test)
Expand All @@ -130,17 +132,17 @@ def stopTest(self, test):

def addSuccess(self, test):
if hasattr(time, 'perf_counter'):
print(test, '... ok (%.2fs)' % (self.calculateDuration()), file=sys.stderr)
print(test, '... ok (%.2fs)' % (self.calculateElapsed()), file=sys.stderr)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is this different to reporting self.test_duration ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is an processing order thing with Python's test harness. self.test_duration has not been calculated yet at this point, i.e. BufferedParallelTestResult.addDuration() has not yet been called by the time this function is called, so self.test_duration would still report zero.

self.buffered_result = BufferedTestSuccess(test)

def addExpectedFailure(self, test, err):
if hasattr(time, 'perf_counter'):
print(test, '... expected failure (%.2fs)' % (self.calculateDuration()), file=sys.stderr)
print(test, '... expected failure (%.2fs)' % (self.calculateElapsed()), file=sys.stderr)
self.buffered_result = BufferedTestExpectedFailure(test, err)

def addUnexpectedSuccess(self, test):
if hasattr(time, 'perf_counter'):
print(test, '... unexpected success (%.2fs)' % (self.calculateDuration()), file=sys.stderr)
print(test, '... unexpected success (%.2fs)' % (self.calculateElapsed()), file=sys.stderr)
self.buffered_result = BufferedTestUnexpectedSuccess(test)

def addSkip(self, test, reason):
Expand Down