Fix flakey windows tests (#2332)

This commit is contained in:
Evan Almloff authored and GitHub committed 2024-04-17 15:08:38 -07:00
1 parent c9ab09b348
commit 5ce91e1bfc
31 files changed
+217 -136

No files matched your search

+1 -1
View File
@@ -145,7 +145,7 @@ pub fn remove_future(id: Task) {
///
/// pub fn use_custom_state() -> CustomState {
/// use_hook(|| CustomState {
/// inner: Signal::new(InnerCustomState)
/// inner: Signal::new(InnerCustomState(0))
/// })
/// }
/// ```
+1 -1
View File
@@ -310,7 +310,7 @@ impl Scope {
///
/// pub fn use_custom_state() -> CustomState {
/// use_hook(|| CustomState {
/// inner: Signal::new(InnerCustomState)
/// inner: Signal::new(InnerCustomState(0))
/// })
/// }
/// ```
+4 -6
View File
@@ -138,7 +138,7 @@ use tracing::instrument;
///
/// let dom = VirtualDom::new(app);
///
/// real_dom.apply(dom.rebuild());
/// dom.rebuild(real_dom.apply());
///
/// loop {
/// select! {
@@ -258,7 +258,7 @@ impl VirtualDom {
///
/// ```rust, ignore
/// let mut dom = VirtualDom::new_with_props(Example, SomeProps { name: "jane" });
/// let mutations = dom.rebuild();
/// dom.rebuild_in_place();
/// ```
pub fn new_with_props<P: Clone + 'static, M: 'static>(
root: impl ComponentFunction<P, M>,
@@ -302,7 +302,7 @@ impl VirtualDom {
///
/// ```rust, ignore
/// let mut dom = VirtualDom::new_from_root(VComponent::new(Example, SomeProps { name: "jane" }, "Example"));
/// let mutations = dom.rebuild();
/// dom.rebuild(to_writer);
/// ```
#[instrument(skip(root), level = "trace", name = "VirtualDom::new")]
pub(crate) fn new_with_component(root: impl AnyProps + 'static) -> Self {
@@ -611,9 +611,7 @@ impl VirtualDom {
/// static app: Component = |cx| rsx!{ "hello world" };
///
/// let mut dom = VirtualDom::new();
/// let edits = dom.rebuild();
///
/// apply_edits(edits);
/// dom.rebuild(to_writer);
/// ```
#[instrument(skip(self, to), level = "trace", name = "VirtualDom::rebuild")]
pub fn rebuild(&mut self, to: &mut impl WriteMutations) {
-1
View File
@@ -1,4 +1,3 @@
use crate::dioxus_elements::SerializedMouseData;
use dioxus::prelude::*;
use dioxus_core::ElementId;
use dioxus_elements::SerializedHtmlEventConverter;
+4 -2
View File
@@ -66,7 +66,7 @@ async fn spawn_forever_persists() {
#[component]
fn Child() -> Element {
spawn_forever(async move {
loop {
for _ in 0..10 {
POLL_COUNT.fetch_add(1, Ordering::Relaxed);
tokio::time::sleep(Duration::from_millis(50)).await;
}
@@ -82,7 +82,9 @@ async fn spawn_forever_persists() {
tokio::select! {
_ = dom.wait_for_work() => {}
_ = tokio::time::sleep(Duration::from_millis(500)) => {}
// We intentionally wait a bit longer than 50ms*10 to make sure the test has time to finish
// Without the extra time, the test can fail on windows
_ = tokio::time::sleep(Duration::from_millis(1000)) => {}
};
// By the time the tasks are finished, we should've accumulated ticks from two tasks