diff --git a/serial_test/src/code_lock.rs b/serial_test/src/code_lock.rs index fd50b75..8ae716e 100644 --- a/serial_test/src/code_lock.rs +++ b/serial_test/src/code_lock.rs @@ -3,12 +3,11 @@ use lazy_static::lazy_static; #[cfg(feature = "logging")] use log::debug; use parking_lot::RwLock; -use std::time::Instant; use std::{ collections::HashMap, ops::{Deref, DerefMut}, sync::{atomic::AtomicU32, Arc}, - time::Duration, + time::{Duration, Instant}, }; pub(crate) struct UniqueReentrantMutex { diff --git a/serial_test/src/parallel_file_lock.rs b/serial_test/src/parallel_file_lock.rs index 1c752bb..dfc3abe 100644 --- a/serial_test/src/parallel_file_lock.rs +++ b/serial_test/src/parallel_file_lock.rs @@ -1,11 +1,16 @@ -use std::panic; +use std::{panic, time::Duration}; use futures::FutureExt; use crate::file_lock::make_lock_for_name_and_path; #[doc(hidden)] -pub fn fs_parallel_core(name: &str, path: Option<&str>, function: fn()) { +pub fn fs_parallel_core( + name: &str, + _max_wait: Option, + path: Option<&str>, + function: fn(), +) { make_lock_for_name_and_path(name, path).start_parallel(); let res = panic::catch_unwind(|| { function(); @@ -19,6 +24,7 @@ pub fn fs_parallel_core(name: &str, path: Option<&str>, function: fn()) { #[doc(hidden)] pub fn fs_parallel_core_with_return( name: &str, + _max_wait: Option, path: Option<&str>, function: fn() -> Result<(), E>, ) -> Result<(), E> { @@ -36,6 +42,7 @@ pub fn fs_parallel_core_with_return( #[doc(hidden)] pub async fn fs_async_parallel_core_with_return( name: &str, + _max_wait: Option, path: Option<&str>, fut: impl std::future::Future> + panic::UnwindSafe, ) -> Result<(), E> { @@ -53,6 +60,7 @@ pub async fn fs_async_parallel_core_with_return( #[doc(hidden)] pub async fn fs_async_parallel_core( name: &str, + _max_wait: Option, path: Option<&str>, fut: impl std::future::Future + panic::UnwindSafe, ) { @@ -84,6 +92,7 @@ mod tests { let _ = panic::catch_unwind(|| { fs_parallel_core( "unlock_on_assert_sync_without_return", + None, Some(&lock_path), || { assert!(false); @@ -99,6 +108,7 @@ mod tests { let _ = panic::catch_unwind(|| { fs_parallel_core_with_return( "unlock_on_assert_sync_with_return", + None, Some(&lock_path), || -> Result<(), Error> { assert!(false); @@ -118,6 +128,7 @@ mod tests { async fn call_serial_test_fn(lock_path: &str) { fs_async_parallel_core( "unlock_on_assert_async_without_return", + None, Some(&lock_path), demo_assert(), ) @@ -146,6 +157,7 @@ mod tests { async fn call_serial_test_fn(lock_path: &str) { fs_async_parallel_core_with_return( "unlock_on_assert_async_with_return", + None, Some(&lock_path), demo_assert(), ) diff --git a/serial_test/src/serial_file_lock.rs b/serial_test/src/serial_file_lock.rs index 23f128c..8c5576e 100644 --- a/serial_test/src/serial_file_lock.rs +++ b/serial_test/src/serial_file_lock.rs @@ -1,7 +1,9 @@ +use std::time::Duration; + use crate::file_lock::make_lock_for_name_and_path; #[doc(hidden)] -pub fn fs_serial_core(name: &str, path: Option<&str>, function: fn()) { +pub fn fs_serial_core(name: &str, _max_wait: Option, path: Option<&str>, function: fn()) { let mut lock = make_lock_for_name_and_path(name, path); lock.start_serial(); function(); @@ -11,6 +13,7 @@ pub fn fs_serial_core(name: &str, path: Option<&str>, function: fn()) { #[doc(hidden)] pub fn fs_serial_core_with_return( name: &str, + _max_wait: Option, path: Option<&str>, function: fn() -> Result<(), E>, ) -> Result<(), E> { @@ -24,6 +27,7 @@ pub fn fs_serial_core_with_return( #[doc(hidden)] pub async fn fs_async_serial_core_with_return( name: &str, + _max_wait: Option, path: Option<&str>, fut: impl std::future::Future>, ) -> Result<(), E> { @@ -37,6 +41,7 @@ pub async fn fs_async_serial_core_with_return( #[doc(hidden)] pub async fn fs_async_serial_core( name: &str, + _max_wait: Option, path: Option<&str>, fut: impl std::future::Future, ) { @@ -57,14 +62,14 @@ mod tests { #[test] fn test_serial() { - fs_serial_core("test", None, || {}); + fs_serial_core("test", None, None, || {}); } #[test] fn unlock_on_assert_sync_without_return() { let lock_path = path_for_name("unlock_on_assert_sync_without_return"); let _ = panic::catch_unwind(|| { - fs_serial_core("foo", Some(&lock_path), || { + fs_serial_core("foo", None, Some(&lock_path), || { assert!(false); }) }); diff --git a/serial_test_derive/src/lib.rs b/serial_test_derive/src/lib.rs index 63d4814..c830b09 100644 --- a/serial_test_derive/src/lib.rs +++ b/serial_test_derive/src/lib.rs @@ -309,6 +309,9 @@ fn local_parallel_core( fn fs_args(attr: proc_macro2::TokenStream) -> Vec> { let config = get_core_key(attr); + if config.timeout.is_some() { + panic!("Timeout is not supported for file_serial"); + } vec![ Box::new(config.name), Box::new(QuoteOption(config.timeout)),