Skip to content

Commit

Permalink
Improve the robustness of the timing-sensitive tests on Windows (#320)
Browse files Browse the repository at this point in the history
The Windows pipelines have been behaving badly lately; this is an
attempt to improve them.
  • Loading branch information
pavel-kirienko authored Jan 8, 2024
1 parent d02f84e commit eddd2b3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pycyphal/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.17.0"
__version__ = "1.17.1"
1 change: 1 addition & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,5 @@ def doctest_await(future: Awaitable[_T]) -> _T:
This is a hack; when the proper solution is available it should be removed:
https://github.com/Erotemic/xdoctest/issues/115
"""
asyncio.get_event_loop().slow_callback_duration = max(asyncio.get_event_loop().slow_callback_duration, 10.0)
return asyncio.get_event_loop().run_until_complete(future)
Original file line number Diff line number Diff line change
Expand Up @@ -58,45 +58,45 @@ def ts() -> SynchronizedTimestamp_1:
await pub_a.publish(force.Scalar_1(ts(), reference))
await pub_b.publish(power.Scalar_1(ts(), reference))
await pub_c.publish(angle.Scalar_1(ts(), reference))
await asyncio.sleep(0.1)
await asyncio.sleep(1.0)
assert 1 == cb_count

reference += 1
await pub_c.publish(angle.Scalar_1(ts(), reference)) # Reordered.
await pub_b.publish(power.Scalar_1(ts(), reference))
await pub_a.publish(force.Scalar_1(ts(), reference))
await asyncio.sleep(0.1)
await asyncio.sleep(1.0)
assert 2 == cb_count

reference += 1
await pub_b.publish(power.Scalar_1(ts(), 999999999)) # Incorrect, will be overridden next.
await pub_b.publish(power.Scalar_1(ts(), reference)) # Override the incorrect value.
await asyncio.sleep(0.1)
await asyncio.sleep(1.0)
await pub_a.publish(force.Scalar_1(ts(), reference))
await pub_c.publish(angle.Scalar_1(ts(), reference))
await asyncio.sleep(0.1)
await asyncio.sleep(1.0)
assert 3 == cb_count

reference += 1
await pub_a.publish(force.Scalar_1(ts(), reference))
# b skip
await pub_c.publish(angle.Scalar_1(ts(), reference))
await asyncio.sleep(0.1)
await asyncio.sleep(1.0)
assert 3 == cb_count

reference += 1
# a skip
await pub_b.publish(power.Scalar_1(ts(), reference))
await pub_c.publish(angle.Scalar_1(ts(), reference))
await asyncio.sleep(0.1)
await asyncio.sleep(1.0)
assert 3 == cb_count

for i in range(10):
reference += 1
await pub_a.publish(force.Scalar_1(ts(), reference))
await pub_b.publish(power.Scalar_1(ts(), reference))
await pub_c.publish(angle.Scalar_1(ts(), reference))
await asyncio.sleep(0.1)
await asyncio.sleep(1.0)
assert 4 + i == cb_count

pres.close()
Expand Down

0 comments on commit eddd2b3

Please sign in to comment.