From e567552b26cbe240e468d0c756bdd5f7964a5967 Mon Sep 17 00:00:00 2001
From: Jonathas-Conceicao <jadoliveira@inf.ufpel.edu.br>
Date: Sun, 1 Mar 2020 11:05:16 -0300
Subject: [PATCH] Fix test_restart_sync_actor occasional fail
Test failed due to race condition where the test would finish before the actor
had a change to stop. This moves the stop call to the actor, so it's always
called only when the actor actually stops.
Signed-off-by: Jonathas-Conceicao <jadoliveira@inf.ufpel.edu.br>
---
tests/test_actor.rs | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/tests/test_actor.rs b/tests/test_actor.rs
index cc24f2a..37f6bcb 100644
--- a/tests/test_actor.rs
+++ b/tests/test_actor.rs
@@ -73,6 +73,9 @@ impl Actor for MySyncActor {
}
fn stopped(&mut self, _: &mut Self::Context) {
self.stopped.fetch_add(1, Ordering::Relaxed);
+ if self.stopped.load(Ordering::Relaxed) >= 2 {
+ System::current().stop();
+ }
}
}
@@ -112,8 +115,6 @@ fn test_restart_sync_actor() {
actix_rt::spawn(async move {
let _ = addr.send(Num(4)).await;
- delay_for(Duration::new(0, 1_000_000)).await;
- System::current().stop();
});
})
.unwrap();
--
2.25.1