Skip to content

Commit fe95793

Browse files
authored
Fix test runner warning caused by previous commit, and rename calculateDuration() to calculateElapsed() to avoid confusing/overloading similar terms. (#24402)
I removed the odd stub `addDuration()` function in the previous PR: https://github.com/emscripten-core/emscripten/pull/24396/files#diff-fd5a5983b044aa841287bf197f2b5e46781162bf0e6a0ca8d1ccaddf1cc1c969L110-L111 turns out that Python unit test runner starts to warn if this function is not present. ``` test_sse4 (test_core.strict_js.test_sse4) ... ok (1.14s) C:\python\Lib\unittest\case.py:580: RuntimeWarning: TestResult has no addDuration method warnings.warn("TestResult has no addDuration method", test_sse4 (test_core.bigint.test_sse4) ... ok (1.10s) C:\python\Lib\unittest\case.py:580: RuntimeWarning: TestResult has no addDuration method warnings.warn("TestResult has no addDuration method", test_sse4 (test_core.instance.test_sse4) ... ok (1.13s) C:\python\Lib\unittest\case.py:580: RuntimeWarning: TestResult has no addDuration method warnings.warn("TestResult has no addDuration method", test_sse4 (test_core.core_2gb.test_sse4) ... ok (1.25s) ``` Add it back in, and use it to register the elapsed time in the test (looks like Python internally tracks it). Rename the `calculateDuration()` function to a `calculateElapsed()` method so it doesn't look too similar to the `addDuration()` one.
1 parent bf3c986 commit fe95793

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

test/parallel_testsuite.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,11 @@ def __init__(self):
109109
def test(self):
110110
return self.buffered_result.test
111111

112-
def calculateDuration(self):
113-
self.test_duration = time.perf_counter() - self.start_time
114-
return self.test_duration
112+
def addDuration(self, test, elapsed):
113+
self.test_duration = elapsed
114+
115+
def calculateElapsed(self):
116+
return time.perf_counter() - self.start_time
115117

116118
def updateResult(self, result):
117119
result.startTest(self.test)
@@ -130,17 +132,17 @@ def stopTest(self, test):
130132

131133
def addSuccess(self, test):
132134
if hasattr(time, 'perf_counter'):
133-
print(test, '... ok (%.2fs)' % (self.calculateDuration()), file=sys.stderr)
135+
print(test, '... ok (%.2fs)' % (self.calculateElapsed()), file=sys.stderr)
134136
self.buffered_result = BufferedTestSuccess(test)
135137

136138
def addExpectedFailure(self, test, err):
137139
if hasattr(time, 'perf_counter'):
138-
print(test, '... expected failure (%.2fs)' % (self.calculateDuration()), file=sys.stderr)
140+
print(test, '... expected failure (%.2fs)' % (self.calculateElapsed()), file=sys.stderr)
139141
self.buffered_result = BufferedTestExpectedFailure(test, err)
140142

141143
def addUnexpectedSuccess(self, test):
142144
if hasattr(time, 'perf_counter'):
143-
print(test, '... unexpected success (%.2fs)' % (self.calculateDuration()), file=sys.stderr)
145+
print(test, '... unexpected success (%.2fs)' % (self.calculateElapsed()), file=sys.stderr)
144146
self.buffered_result = BufferedTestUnexpectedSuccess(test)
145147

146148
def addSkip(self, test, reason):

0 commit comments

Comments
 (0)