From 7e54039ed2c01702aff3ad20d4549c458690522c Mon Sep 17 00:00:00 2001 From: Jonathan Kelley Date: Mon, 5 Feb 2024 12:24:50 -0800 Subject: [PATCH] fix make tests --- packages/core/src/runtime.rs | 6 ++++-- packages/core/src/virtual_dom.rs | 1 + packages/core/tests/task.rs | 2 +- packages/plasmo/src/lib.rs | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/core/src/runtime.rs b/packages/core/src/runtime.rs index 4dbfc45a6..8493a901f 100644 --- a/packages/core/src/runtime.rs +++ b/packages/core/src/runtime.rs @@ -155,8 +155,10 @@ impl Runtime { /// This means the virtual dom is currently doing syncronous work /// The lock will be held until `release_flush_lock` is called - and then the OwnedLock will be dropped pub(crate) fn acquire_flush_lock(&self) { - self.flush_lock - .set(Some(self.flush_mutex.try_lock_owned().unwrap())); + // The flush lock might already be held... + if let Some(lock) = self.flush_mutex.try_lock_owned() { + self.flush_lock.set(Some(lock)); + } } /// Release the flush lock diff --git a/packages/core/src/virtual_dom.rs b/packages/core/src/virtual_dom.rs index 96e001e25..75ce4ffc7 100644 --- a/packages/core/src/virtual_dom.rs +++ b/packages/core/src/virtual_dom.rs @@ -450,6 +450,7 @@ impl VirtualDom { // When we're doing awaiting the rx, the lock will be dropped and tasks waiting on the lock will get waked // We have to own the lock since poll_tasks is cancel safe - the future that this is running in might get dropped // and if we held the lock in the scope, the lock would also get dropped prematurely + self.runtime.release_flush_lock(); self.runtime.acquire_flush_lock(); match self.rx.next().await.expect("channel should never close") { diff --git a/packages/core/tests/task.rs b/packages/core/tests/task.rs index 8bc120010..710f7e6c6 100644 --- a/packages/core/tests/task.rs +++ b/packages/core/tests/task.rs @@ -16,7 +16,7 @@ async fn run_vdom(app: fn() -> Element) { } #[tokio::test] -async fn it_works() { +async fn running_async() { static POLL_COUNT: AtomicUsize = AtomicUsize::new(0); fn app() -> Element { diff --git a/packages/plasmo/src/lib.rs b/packages/plasmo/src/lib.rs index 58fa1b29e..c5bc0d647 100644 --- a/packages/plasmo/src/lib.rs +++ b/packages/plasmo/src/lib.rs @@ -259,7 +259,7 @@ pub fn render( TermEvent::Resize(_, _) => updated = true, _ => {} }, - InputEvent::Close => panic!("ackkkk"), + InputEvent::Close => break, }; if let InputEvent::UserInput(evt) = evt.unwrap() {