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

Conversation

juj
Copy link
Collaborator

@juj juj commented May 23, 2025

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.

@juj juj force-pushed the fix_test_runner_warning branch from 92ea19d to d1aa3ab Compare May 23, 2025 12:39
@@ -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.

…teDuration() to calculateElapsed() to avoid confusing/overloading similar terms.
@juj juj force-pushed the fix_test_runner_warning branch from d1aa3ab to 7163a26 Compare May 23, 2025 15:05
@juj juj enabled auto-merge (squash) May 23, 2025 15:05
@juj juj disabled auto-merge May 24, 2025 15:51
@juj juj merged commit fe95793 into emscripten-core:main May 24, 2025
27 of 30 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