Skip to content

Commit f99f316

Browse files
committed
don't use tokio::test for now
1 parent 7f46970 commit f99f316

File tree

3 files changed

+15
-20
lines changed

3 files changed

+15
-20
lines changed

src/db/overrides.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ mod test {
9696
use crate::{db::Overrides, test::*};
9797
use std::time::Duration;
9898

99-
#[tokio::test]
100-
async fn retrieve_overrides() {
99+
#[test]
100+
fn retrieve_overrides() {
101101
async_wrapper(|env| async move {
102102
let db = env.async_db().await;
103103
let mut conn = db.async_conn().await;
@@ -143,6 +143,5 @@ mod test {
143143

144144
Ok(())
145145
})
146-
.await;
147146
}
148147
}

src/docbuilder/limits.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ mod test {
7373
use super::*;
7474
use crate::test::*;
7575

76-
#[tokio::test]
77-
async fn retrieve_limits() {
76+
#[test]
77+
fn retrieve_limits() {
7878
async_wrapper(|env| async move {
7979
let db = env.async_db().await;
8080
let mut conn = db.async_conn().await;
@@ -129,11 +129,10 @@ mod test {
129129
);
130130
Ok(())
131131
})
132-
.await;
133132
}
134133

135-
#[tokio::test]
136-
async fn targets_default_to_one_with_timeout() {
134+
#[test]
135+
fn targets_default_to_one_with_timeout() {
137136
async_wrapper(|env| async move {
138137
let db = env.async_db().await;
139138
let mut conn = db.async_conn().await;
@@ -152,11 +151,10 @@ mod test {
152151

153152
Ok(())
154153
})
155-
.await;
156154
}
157155

158-
#[tokio::test]
159-
async fn config_default_memory_limit() {
156+
#[test]
157+
fn config_default_memory_limit() {
160158
async_wrapper(|env| async move {
161159
env.override_config(|config| {
162160
config.build_default_memory_limit = Some(6 * GB);
@@ -170,11 +168,10 @@ mod test {
170168

171169
Ok(())
172170
})
173-
.await;
174171
}
175172

176-
#[tokio::test]
177-
async fn overrides_dont_lower_memory_limit() {
173+
#[test]
174+
fn overrides_dont_lower_memory_limit() {
178175
async_wrapper(|env| async move {
179176
let db = env.async_db().await;
180177
let mut conn = db.async_conn().await;
@@ -196,6 +193,5 @@ mod test {
196193

197194
Ok(())
198195
})
199-
.await;
200196
}
201197
}

src/test/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub(crate) fn wrapper(f: impl FnOnce(&TestEnvironment) -> Result<()>) {
5656
}
5757
}
5858

59-
pub(crate) async fn async_wrapper<F, Fut>(f: F)
59+
pub(crate) fn async_wrapper<F, Fut>(f: F)
6060
where
6161
F: FnOnce(Rc<TestEnvironment>) -> Fut,
6262
Fut: Future<Output = Result<()>>,
@@ -65,13 +65,13 @@ where
6565

6666
let fut = f(env.clone());
6767

68+
let runtime = env.runtime();
69+
6870
// if we didn't catch the panic, the server would hang forever
69-
let maybe_panic = panic::AssertUnwindSafe(fut).catch_unwind().await;
71+
let maybe_panic = runtime.block_on(panic::AssertUnwindSafe(fut).catch_unwind());
7072

7173
let env = Rc::into_inner(env).unwrap();
72-
tokio::task::spawn_blocking(move || env.cleanup())
73-
.await
74-
.unwrap();
74+
env.cleanup();
7575

7676
let result = match maybe_panic {
7777
Ok(r) => r,

0 commit comments

Comments
 (0)