Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

integration tests' dependencies do not have a dedicated manifest section #12717

Closed
tamird opened this issue Sep 20, 2023 · 9 comments
Closed
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage.

Comments

@tamird
Copy link
Contributor

tamird commented Sep 20, 2023

Problem

integration tests are a useful concept, but in cases where additional test-only 3rd party crates are needed, they are unusable because they don't get to use dev-dependencies and do not have their own dependency section in the manifest.

Proposed Solution

The simplest solution would be to link dev-dependencies into integration tests.

Notes

No response

@tamird tamird added C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage. labels Sep 20, 2023
@epage
Copy link
Contributor

epage commented Sep 20, 2023

Could you provide an example scenario? I'm not too sure what the problem is you are trying to highlight.

@tamird
Copy link
Contributor Author

tamird commented Sep 20, 2023

When I write some unit tests, and I want to use test-only dependencies such as pretty_assertions, the documentation suggests using dev-dependencies.

Now suppose I want to write an integration test that uses pretty_assertions - where do I declare that my test needs that crate? As I write in the issue description: integration tests are compiled without dev-dependencies, and it would be inappropriate to add pretty_assertions to my crate's dependencies.

@epage
Copy link
Contributor

epage commented Sep 20, 2023

s I write in the issue description: integration tests are compiled without dev-dependencies

They should be compiled with dev-dependencies. Do you have a reproduction case?

@tamird
Copy link
Contributor Author

tamird commented Sep 20, 2023

I was attempting to reproduce this by writing a test in the cargo repo, but you are right - they seem to be getting the dev-dependencies. This was PEBKAC.

@tamird tamird closed this as completed Sep 20, 2023
@tamird
Copy link
Contributor Author

tamird commented Sep 20, 2023

The actual issue was that dev-dependencies are linked to both unit and integration tests, which can create poor interactions with the unused-crate-dependencies lint.

It would be good to have a separate section in the manifest for the dependencies of integration tests for this reason.

@tamird tamird reopened this Sep 20, 2023
@tamird tamird changed the title integration tests don't get access to dev-dependencies integration tests' dependencies do not have a dedicated manifest section Sep 20, 2023
@epage
Copy link
Contributor

epage commented Sep 20, 2023

dev-dependencies are for all development tasks including

  • unit tests
  • integration tests
  • examples

I'm assuming the unused-crate-dependencies lint won't just trigger if a dependency isn't used among any integration test but will trigger on each integration test that doesn't use that dependency. This means we'd need per-build-target dependencies. At that point, this is a duplicate of #1982.

@tamird
Copy link
Contributor Author

tamird commented Sep 20, 2023

Not only that, it will also trigger on the main crate if the dev-dependency isn't used in any unit tests.

@epage
Copy link
Contributor

epage commented Sep 20, 2023

Is there any reason we shouldn't close in favor of #1982?

@tamird
Copy link
Contributor Author

tamird commented Sep 20, 2023

Seems reasonable to do so.

@tamird tamird closed this as not planned Won't fix, can't repro, duplicate, stale Sep 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

2 participants