Skip to content

Commit

Permalink
Standard test attribute worked with mod, others didn't
Browse files Browse the repository at this point in the history
This fixes things with any foo::test attribute
  • Loading branch information
palfrey committed Apr 21, 2024
1 parent 2389412 commit fb32f74
Showing 1 changed file with 40 additions and 4 deletions.
44 changes: 40 additions & 4 deletions serial_test_derive/src/lib.rs
Original file line number Diff line number Diff line change
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 fb32f74

Please sign in to comment.