Skip to content

Commit

Permalink
Merge pull request #110 from palfrey/serial-mod-non-core
Browse files Browse the repository at this point in the history
Standard test attribute worked with mod, others didn't
  • Loading branch information
palfrey committed Apr 21, 2024
2 parents 2389412 + fb32f74 commit 4ccc6bd
Showing 1 changed file with 40 additions and 4 deletions.
44 changes: 40 additions & 4 deletions serial_test_derive/src/lib.rs
Expand Up @@ -342,10 +342,10 @@ fn core_setup(
attr.meta
.path()
.segments
.first()
.unwrap()
.ident
.to_string()
.iter()
.map(|s| s.ident.to_string())
.collect::<Vec<String>>()
.join("::")
.contains("test")
}) =>
{
Expand Down Expand Up @@ -739,4 +739,40 @@ mod tests {
};
compare_streams(compare, stream);
}

#[test]
fn test_later_test_mod() {
init();
let attrs = proc_macro2::TokenStream::new();
let input = quote! {
#[cfg(test)]
#[serial]
mod serial_attr_tests {
pub fn foo() {
println!("Nothing");
}

#[demo_library::test]
fn bar() {}
}
};
let stream = local_serial_core(
proc_macro2::TokenStream::from_iter(attrs.into_iter()),
input,
);
let compare = quote! {
#[cfg(test)]
mod serial_attr_tests {
pub fn foo() {
println!("Nothing");
}

#[demo_library::test]
fn bar() {
serial_test::local_serial_core(vec![""], ::std::option::Option::None, || {} );
}
}
};
compare_streams(compare, stream);
}
}

0 comments on commit 4ccc6bd

Please sign in to comment.