fix lints in miri

This commit is contained in:
Evan Almloff committed 2023-12-17 16:46:32 -06:00
1 parent b0586843b2
commit c48788270e
2 files changed
+21 -21

No files matched your search

+1 -1
View File
@@ -98,7 +98,7 @@ impl Runtime {
} }
} }
/// A gaurd for a new runtime. This must be used to override the current runtime when importing components from a dynamic library that has it's own runtime. /// A guard for a new runtime. This must be used to override the current runtime when importing components from a dynamic library that has it's own runtime.
/// ///
/// ```rust /// ```rust
/// use dioxus::prelude::*; /// use dioxus::prelude::*;
+20 -20
View File
@@ -1,29 +1,12 @@
//! Verify that tasks get polled by the virtualdom properly, and that we escape wait_for_work safely //! Verify that tasks get polled by the virtualdom properly, and that we escape wait_for_work safely
use dioxus::prelude::*;
use std::{sync::atomic::AtomicUsize, time::Duration};
static POLL_COUNT: AtomicUsize = AtomicUsize::new(0);
#[cfg(not(miri))] #[cfg(not(miri))]
#[tokio::test] #[tokio::test]
async fn it_works() { async fn it_works() {
let mut dom = VirtualDom::new(app); use dioxus::prelude::*;
use std::{sync::atomic::AtomicUsize, time::Duration};
let _ = dom.rebuild(); static POLL_COUNT: AtomicUsize = AtomicUsize::new(0);
tokio::select! {
_ = dom.wait_for_work() => {}
_ = tokio::time::sleep(Duration::from_millis(500)) => {}
};
// By the time the tasks are finished, we should've accumulated ticks from two tasks
// Be warned that by setting the delay to too short, tokio might not schedule in the tasks
assert_eq!(
POLL_COUNT.fetch_add(0, std::sync::atomic::Ordering::Relaxed),
135
);
}
fn app(cx: Scope) -> Element { fn app(cx: Scope) -> Element {
cx.use_hook(|| { cx.use_hook(|| {
@@ -44,3 +27,20 @@ fn app(cx: Scope) -> Element {
cx.render(rsx!(())) cx.render(rsx!(()))
} }
let mut dom = VirtualDom::new(app);
let _ = dom.rebuild();
tokio::select! {
_ = dom.wait_for_work() => {}
_ = tokio::time::sleep(Duration::from_millis(500)) => {}
};
// By the time the tasks are finished, we should've accumulated ticks from two tasks
// Be warned that by setting the delay to too short, tokio might not schedule in the tasks
assert_eq!(
POLL_COUNT.fetch_add(0, std::sync::atomic::Ordering::Relaxed),
135
);
}