Skip to content

gh-127146: Some expected failures in Emscripten time tests #127843

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
Dec 12, 2024
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
28 changes: 21 additions & 7 deletions Lib/test/test_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -805,14 +805,28 @@ def _test_utime(self, set_time, filename=None):
set_time(filename, (atime_ns, mtime_ns))
st = os.stat(filename)

if support_subsecond:
self.assertAlmostEqual(st.st_atime, atime_ns * 1e-9, delta=1e-6)
self.assertAlmostEqual(st.st_mtime, mtime_ns * 1e-9, delta=1e-6)
if support.is_emscripten:
# Emscripten timestamps are roundtripped through a 53 bit integer of
# nanoseconds. If we want to represent ~50 years which is an 11
# digits number of seconds:
# 2*log10(60) + log10(24) + log10(365) + log10(60) + log10(50)
# is about 11. Because 53 * log10(2) is about 16, we only have 5
# digits worth of sub-second precision.
# Some day it would be good to fix this upstream.
delta=1e-5
self.assertAlmostEqual(st.st_atime, atime_ns * 1e-9, delta=1e-5)
self.assertAlmostEqual(st.st_mtime, mtime_ns * 1e-9, delta=1e-5)
self.assertAlmostEqual(st.st_atime_ns, atime_ns, delta=1e9 * 1e-5)
self.assertAlmostEqual(st.st_mtime_ns, mtime_ns, delta=1e9 * 1e-5)
else:
self.assertEqual(st.st_atime, atime_ns * 1e-9)
self.assertEqual(st.st_mtime, mtime_ns * 1e-9)
self.assertEqual(st.st_atime_ns, atime_ns)
self.assertEqual(st.st_mtime_ns, mtime_ns)
if support_subsecond:
self.assertAlmostEqual(st.st_atime, atime_ns * 1e-9, delta=1e-6)
self.assertAlmostEqual(st.st_mtime, mtime_ns * 1e-9, delta=1e-6)
else:
self.assertEqual(st.st_atime, atime_ns * 1e-9)
self.assertEqual(st.st_mtime, mtime_ns * 1e-9)
self.assertEqual(st.st_atime_ns, atime_ns)
self.assertEqual(st.st_mtime_ns, mtime_ns)

def test_utime(self):
def set_time(filename, ns):
Expand Down
4 changes: 4 additions & 0 deletions Lib/test/test_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def test_clock_monotonic(self):
'need time.pthread_getcpuclockid()')
@unittest.skipUnless(hasattr(time, 'clock_gettime'),
'need time.clock_gettime()')
@unittest.skipIf(support.is_emscripten, "Fails to find clock")
def test_pthread_getcpuclockid(self):
clk_id = time.pthread_getcpuclockid(threading.get_ident())
self.assertTrue(type(clk_id) is int)
Expand Down Expand Up @@ -539,6 +540,9 @@ def test_perf_counter(self):
@unittest.skipIf(
support.is_wasi, "process_time not available on WASI"
)
@unittest.skipIf(
support.is_emscripten, "process_time present but doesn't exclude sleep"
)
def test_process_time(self):
# process_time() should not include time spend during a sleep
start = time.process_time()
Expand Down
Loading