Skip to content

fix: incompatibility with rstest parametrized tests - #132

Open
Adam Cooper (super-cooper) wants to merge 1 commit into
microsoft:mainfrom
super-cooper:rstest
Open

Adam Cooper (super-cooper) wants to merge 1 commit into
microsoft:mainfrom
super-cooper:rstest

Conversation

@super-cooper

@super-cooper Adam Cooper (super-cooper) commented May 31, 2026 •

Copy link
Copy Markdown

rstest generates parametrized tests (#[case]) as one helper function that is called by each test generated for the different cases. Because of this, injectorpp's internal static counter is reused between these test cases. The same would hold true for an injector created in any helper function.

This patch resets the static counter to zero when the verifier is dropped so it can be reused in these scenarios.

Additionally:

  • rstest is added as a dev dependency
  • An new test validates the desired behavior

rstest generates parametrized tests (`#[case]`) as one helper function
that is called by each test generated for the different cases. Because
of this, injectorpp's internal static counter is reused between these
test cases. The same would hold true for an injector created in any
helper function.

This patch resets the static counter to zero when the verifier is
dropped so it can be reused in these scenarios.

Additionally:
* rstest is added as a dev dependency
* An new test validates the desired behavior
@super-cooper

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@mazong1123

Copy link
Copy Markdown
Contributor

Thanks for making the change. Would you mind taking a look at the failed tests? Looks like rstest still failed with the change.

@super-cooper

Copy link
Copy Markdown
Author

It looks like the lint regression is in an untouched portion of the file that I had edited. I fixed it, but this may not be desirable for you as part of this patch.

Regarding the test failures:

  • MacOS is very difficult for me to test. I just spent a few hours trying to get https://github.com/darlinghq/darling working for Rust development, but there are too many barriers and I don't own any Mac hardware. Perhaps you could investigate? If you're able to pinpoint the bug, I'm happy to implement.
  • For the other bug, I tried to build with cross, but had tons of trouble for this target, which is based on Ubuntu 16.04 and tries to link against an incompatible, very old release of OpenSSL.

I would like to fix these issues, but unfortunately, these two platforms have proven very difficult to iterate on. Do the maintainers have any solutions for this that I could use?

@mazong1123

Copy link
Copy Markdown
Contributor

Thanks! Let me take a look to see if there's any way to get it done.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants