Skip to content

Commit

Permalink
Merge pull request #114 from pgerber/tokio
Browse files Browse the repository at this point in the history
Stop using tokio in test which runs all futures sync
  • Loading branch information
palfrey authored Jul 14, 2024
2 parents b39310b + 56baed6 commit 870d278
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 21 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions serial_test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ env_logger = {version="0.10", optional=true}

[dev-dependencies]
itertools = "0.10"
tokio = { version = "^1.27", features = ["macros", "rt"] }

[features]
default = ["logging", "async"]
Expand All @@ -52,4 +51,4 @@ rustdoc-args = ["--cfg", "docsrs"]

[package.metadata.cargo-all-features]
skip_optional_dependencies = true
denylist = ["docsrs", "test_logging"]
denylist = ["docsrs", "test_logging"]
12 changes: 4 additions & 8 deletions serial_test/src/parallel_code_lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ mod tests {
);
}

#[tokio::test]
#[test]
#[cfg(feature = "async")]
async fn unlock_on_assert_async_without_return() {
fn unlock_on_assert_async_without_return() {
async fn demo_assert() {
assert!(false);
}
Expand All @@ -149,8 +149,6 @@ mod tests {
}
// as per https://stackoverflow.com/a/66529014/320546
let _ = panic::catch_unwind(|| {
let handle = tokio::runtime::Handle::current();
let _enter_guard = handle.enter();
futures::executor::block_on(call_serial_test_fn());
});
assert_eq!(
Expand All @@ -163,9 +161,9 @@ mod tests {
);
}

#[tokio::test]
#[test]
#[cfg(feature = "async")]
async fn unlock_on_assert_async_with_return() {
fn unlock_on_assert_async_with_return() {
async fn demo_assert() -> Result<(), Error> {
assert!(false);
Ok(())
Expand All @@ -183,8 +181,6 @@ mod tests {

// as per https://stackoverflow.com/a/66529014/320546
let _ = panic::catch_unwind(|| {
let handle = tokio::runtime::Handle::current();
let _enter_guard = handle.enter();
futures::executor::block_on(call_serial_test_fn());
});
assert_eq!(
Expand Down
14 changes: 4 additions & 10 deletions serial_test/src/parallel_file_lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ mod tests {
unlock_ok(&lock_path);
}

#[tokio::test]
#[test]
#[cfg(feature = "async")]
async fn unlock_on_assert_async_without_return() {
fn unlock_on_assert_async_without_return() {
let lock_path = path_for_name("unlock_on_assert_async_without_return");
async fn demo_assert() {
assert!(false);
Expand All @@ -147,18 +147,15 @@ mod tests {
.await
}

// as per https://stackoverflow.com/a/66529014/320546
let _ = panic::catch_unwind(|| {
let handle = tokio::runtime::Handle::current();
let _enter_guard = handle.enter();
futures::executor::block_on(call_serial_test_fn(&lock_path));
});
unlock_ok(&lock_path);
}

#[tokio::test]
#[test]
#[cfg(feature = "async")]
async fn unlock_on_assert_async_with_return() {
fn unlock_on_assert_async_with_return() {
let lock_path = path_for_name("unlock_on_assert_async_with_return");

async fn demo_assert() -> Result<(), Error> {
Expand All @@ -176,10 +173,7 @@ mod tests {
.await;
}

// as per https://stackoverflow.com/a/66529014/320546
let _ = panic::catch_unwind(|| {
let handle = tokio::runtime::Handle::current();
let _enter_guard = handle.enter();
futures::executor::block_on(call_serial_test_fn(&lock_path));
});
unlock_ok(&lock_path);
Expand Down

0 comments on commit 870d278

Please sign in to comment.