Skip to content

🩹 Fix macOS compatibility and adjust test timing for reliability#164

Merged
gimlichael merged 2 commits into
mainfrom
v10.5.3/mac-fix-ii
Jun 4, 2026
Merged

🩹 Fix macOS compatibility and adjust test timing for reliability#164
gimlichael merged 2 commits into
mainfrom
v10.5.3/mac-fix-ii

Conversation

@gimlichael

Copy link
Copy Markdown
Member

This pull request adjusts test timing and platform compatibility in several test files. The main changes are increased latency and jitter values in resilience and diagnostics test cases to better accommodate timing variability, and improved cross-platform support for native library loading on Unix systems.

Test timing adjustments:

  • Increased the jitter buffer in TimeMeasureTest from 100ms to 250ms to allow for more timing variability in test execution.
  • Increased the expected maximum allowed latency in TransientOperationTest from 250ms to 500ms, making the test more tolerant to delays.
  • Increased latency in the following transient operation test methods from 250–350ms to 750ms to simulate longer fault scenarios:
    • TriggerLatencyException in ActionTransientOperation.cs
    • TriggerLatencyExceptionAsync in AsyncActionTransientOperation.cs
    • TriggerLatencyExceptionAsync in AsyncFuncTransientOperation.cs
    • TriggerLatencyException in FuncTransientOperation.cs

Platform compatibility improvements:

  • Updated native library loading in UnmanagedDisposable to use libSystem.B.dylib on macOS and libc.so.6 on Linux, improving cross-platform support for Unix-based systems.

Add macOS platform detection in UnmanagedDisposable to use libSystem.B.dylib.
Increase test timeouts and sleep durations in resilience test assets to improve stability on slower systems.
@gimlichael gimlichael self-assigned this Jun 4, 2026
@greptile-apps

greptile-apps Bot commented Jun 4, 2026

Copy link
Copy Markdown

Greptile Summary

This PR improves test reliability on macOS and CI environments by increasing timing tolerances and fixing a native library loading issue. All changes are confined to test assets and test files.

  • macOS native library fix: UnmanagedDisposable now uses RuntimeInformation.IsOSPlatform(OSPlatform.OSX) inside the PlatformID.Unix branch to load libSystem.B.dylib on macOS and libc.so.6 on Linux, correctly handling the fact that macOS reports PlatformID.Unix at runtime.
  • Async test helpers improved: AsyncActionTransientOperation and AsyncFuncTransientOperation replace Thread.Sleep with await Task.Delay(750, ct), making them non-blocking and respecting the passed CancellationToken.
  • Timing thresholds raised: Jitter in TimeMeasureTest (100 ms → 250 ms), latency sleeps in sync operations (250 ms → 750 ms), and ExpectedMaximumAllowedLatency (250 ms → 500 ms) are all widened to reduce flakiness on slower CI runners.

Confidence Score: 5/5

Safe to merge — all changes are isolated to test assets and test configuration, with no production code affected.

The changes widen timing tolerances in test helpers and fix a real macOS library-loading bug. The async helpers now correctly use await Task.Delay instead of blocking Thread.Sleep, and the native-library detection properly distinguishes macOS from Linux within the Unix platform branch. Nothing in production paths is touched.

No files require special attention.

Important Files Changed

Filename Overview
test/Cuemon.Core.Tests/Assets/UnmanagedDisposable.cs Adds RuntimeInformation.IsOSPlatform(OSPlatform.OSX) check inside the Unix branch to load the correct native library on macOS; System.Runtime.InteropServices is already imported so no additional using is needed.
test/Cuemon.Diagnostics.Tests/TimeMeasureTest.cs Jitter tolerance increased from 100 ms to 250 ms to reduce timing-related flakiness; no logic changes.
test/Cuemon.Resilience.Tests/Assets/AsyncActionTransientOperation.cs Replaced blocking Thread.Sleep(250) with await Task.Delay(750, ct) and added async keyword, making the method non-blocking and cancellation-aware.
test/Cuemon.Resilience.Tests/Assets/AsyncFuncTransientOperation.cs Same async fix as AsyncActionTransientOperation; Thread.Sleep(350) replaced with await Task.Delay(750, ct).
test/Cuemon.Resilience.Tests/Assets/ActionTransientOperation.cs Synchronous Thread.Sleep increased from 250 ms to 750 ms; appropriate for a synchronous method with no cancellation token.
test/Cuemon.Resilience.Tests/Assets/FuncTransientOperation.cs Same timing adjustment as ActionTransientOperation; 250 ms to 750 ms sleep.
test/Cuemon.Resilience.Tests/TransientOperationTest.cs ExpectedMaximumAllowedLatency widened from 250 ms to 500 ms; consistent with the 750 ms latency injection ensuring latency-exception tests still trigger as intended.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[UnmanagedDisposable constructor] --> B{PlatformID.Win32NT?}
    B -- Yes --> C[Load kernel32.dll]
    B -- No --> D{PlatformID.Unix?}
    D -- Yes --> E{RuntimeInformation.IsOSPlatform OSX?}
    E -- Yes --> F[Load libSystem.B.dylib]
    E -- No --> G[Load libc.so.6]
    F --> H[Assign _libHandle]
    G --> H
Loading

Reviews (2): Last reviewed commit: "🩹 fix latency exception handling to use..." | Re-trigger Greptile

Comment thread test/Cuemon.Resilience.Tests/Assets/AsyncActionTransientOperation.cs Outdated
@gimlichael gimlichael merged commit d271f94 into main Jun 4, 2026
2 of 6 checks passed
@gimlichael gimlichael deleted the v10.5.3/mac-fix-ii branch June 4, 2026 11:24
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