From 5f7dd453617e1efaedbb02e9e1d2b29611d1b13b Mon Sep 17 00:00:00 2001 From: Kenneth Loeffler Date: Sat, 20 Jul 2024 09:52:05 -0700 Subject: [PATCH] Sleep between file copies and serve for macOS serve tests (#945) --- tests/rojo_test/serve_util.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/rojo_test/serve_util.rs b/tests/rojo_test/serve_util.rs index df0ac235..2c33e952 100644 --- a/tests/rojo_test/serve_util.rs +++ b/tests/rojo_test/serve_util.rs @@ -83,6 +83,15 @@ impl TestServeSession { .expect("Couldn't copy project to temporary directory"); }; + // This is an ugly workaround for FSEvents sometimes reporting events + // for the above copy operations, similar to this Stack Overflow question: + // https://stackoverflow.com/questions/47679298/howto-avoid-receiving-old-events-in-fseventstream-callback-fsevents-framework-o + // We'll hope that 100ms is enough for FSEvents to get whatever it is + // out of its system. + // TODO: find a better way to avoid processing these spurious events. + #[cfg(target_os = "macos")] + std::thread::sleep(Duration::from_millis(100)); + let port = get_port_number(); let port_string = port.to_string();