Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

#[serial(crate = ...)] parameter #123

Open
stepancheg opened this issue Dec 31, 2024 · 3 comments
Open

#[serial(crate = ...)] parameter #123

stepancheg opened this issue Dec 31, 2024 · 3 comments

Comments

@stepancheg
Copy link

#[serial_test(crate = wrapper::__derive_refs::serial)]

This is for proc-macros generating #[serial_test] annotations: they should rely on reexports of serial crate.

@palfrey
Copy link
Owner

palfrey commented Dec 31, 2024

I haven't seen this problem before. Can you provide a demo of the problem and why the current setup doesn't enable things?

@stepancheg
Copy link
Author

stepancheg commented Dec 31, 2024

This is how serde is doing it for example: https://serde.rs/container-attrs.html#crate

Use case is this: I'm developing a macro like #[my_test_utils::my_test] in a crate my_test_utils. It should expand to:

#[serial_test::serial]
#[test]
fn xxx() {
  // custom my test logic...
  ...
}

However, serial_test may not be imported where this my_test_utils crate is imported (or imported, but wrong version).

#[my_test] could be expanded instead into

#[my_test_utils::__derive_refs::serial_test::serial(crate = my_test_utils::__derive_refs::serial_test)]
#[test]
fn xxx() {
  // custom init...
  ...
}

so that when #[serial] ireferences serial_test crate functions, it references them as my_test_utils::__derive_refs::serial_test::xxx instead of serial_test::xxx.

Please let me know, if this explanation does not help.

@palfrey
Copy link
Owner

palfrey commented Dec 31, 2024

Yeah, it makes more sense now. I'm busy with a whole bunch of things at the moment, and won't get to this anytime soon. OTOH, if you're able to provide a PR for this, I'm happy to review.

@stepancheg stepancheg changed the title Add crate parameter #[serial(crate = ...)] parameter Dec 31, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants