Skip to content

Make source rewrite tests work with coarse timestamps - #538

Merged
iskandr merged 4 commits into
openvax:mainfrom
nicozdeb:fix-coarse-timestamp-tests
Nov 22, 2026
Merged

iskandr merged 4 commits into
openvax:mainfrom
nicozdeb:fix-coarse-timestamp-tests

Conversation

@nicozdeb

Copy link
Copy Markdown
Contributor

On kernels without multigrain timestamps (Linux < 6.13) a same-size rewrite in the same clock tick keeps the ctime, so four tests fail with "DID NOT RAISE" or read stale data. The tests now repeat the write until ctime changes. Test-only change, bumped to 2.34.8.

Found in a Debian rebuild on Linux 6.12: https://bugs.debian.org/1154342

On Linux before 6.13 (no multigrain timestamps) two writes in the same
clock tick get the same ctime, so a same-size rewrite keeps the whole
stat() identity and the tests can't see the change. Repeat the write
until ctime moves on. Bump to 2.34.8.
@iskandr

iskandr commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Review

Clean, minimal fix for Linux < 6.13 / coarse-timestamp filesystems (Debian bug #1154342). Two small polish suggestions:

  1. Bound the retry loop: while before is not None and path.stat().st_ctime_ns == before: has no timeout/max-iteration guard. Adding a short deadline (e.g. 5 seconds, raising an AssertionError if ctime never advances) prevents an infinite hang on unusual FUSE/mocked-clock environments.
  2. Avoid duplicating rewrite_bytes: The helper is identical in tests/test_annotation_genetic_code.py and tests/test_local_fasta_identity.py—putting it in a shared test helper module (or conftest.py) avoids drift.

Give up after 5 seconds with an AssertionError if ctime never changes,
instead of looping forever.
@nicozdeb

Copy link
Copy Markdown
Contributor Author

Thanks, done: the helper is now in tests/common.py and the loop gives up after 5 seconds with an AssertionError.

Review

Clean, minimal fix for Linux < 6.13 / coarse-timestamp filesystems (Debian bug #1154342). Two small polish suggestions:

1. **Bound the retry loop**: `while before is not None and path.stat().st_ctime_ns == before:` has no timeout/max-iteration guard. Adding a short deadline (e.g. 5 seconds, raising an `AssertionError` if `ctime` never advances) prevents an infinite hang on unusual FUSE/mocked-clock environments.

2. **Avoid duplicating `rewrite_bytes`**: The helper is identical in `tests/test_annotation_genetic_code.py` and `tests/test_local_fasta_identity.py`—putting it in a shared test helper module (or `conftest.py`) avoids drift.

Thanks, done: the helper is now in tests/common.py and the loop gives up after 5 seconds with an AssertionError.

@iskandr

iskandr commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

LGTM on the test helper (tests/common.py:rewrite_bytes with the 5s deadline) — thanks for the quick follow-up! One small rebase note: 2.34.8 shipped via #539, so RELEASE_NOTES.md (and pyensembl/version.py) should bump to 2.34.9 before merge/release.

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 93.656%. remained the same — nicozdeb:fix-coarse-timestamp-tests into openvax:main

@iskandr
iskandr merged commit c526b5b into openvax:main Nov 22, 2026
9 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.

3 participants