Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

test(windows): retry the timer check so a busy host cannot fail the build

EtienneLescotab7d9dd5cddc
diff --git a/electron/native/wgc-capture/src/audio_sample_utils_test.cpp b/electron/native/wgc-capture/src/audio_sample_utils_test.cpp
index 2998a5d5d..3b3da4317 100644
--- a/electron/native/wgc-capture/src/audio_sample_utils_test.cpp
+++ b/electron/native/wgc-capture/src/audio_sample_utils_test.cpp
@@ -235,7 +235,13 @@ int main() {
};
const double before = medianSleepMs();
const HighResolutionTiming timing;
- const double after = medianSleepMs();
+ // Load only ever lengthens a sleep, so a median under 8 ms cannot be
+ // faked by a busy host, and at the default tick it cannot happen at all.
+ // A failing round is retried, so a transient load does not fail the build.
+ double after = medianSleepMs();
+ for (int retry = 0; retry < 2 && after >= 8.0; retry += 1) {
+ after = std::min(after, medianSleepMs());
+ }
char detail[96]{};
sprintf_s(detail, "5 ms sleep: median %.2f ms before, %.2f ms after", before, after);
std::cout << "TIMER_RAW " << detail << std::endl;