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

Add warning message when no tests are run. #11875

Open
Kuly14 opened this issue Mar 22, 2023 · 2 comments
Open

Add warning message when no tests are run. #11875

Kuly14 opened this issue Mar 22, 2023 · 2 comments
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-test S-blocked-external Status: ❌ blocked on something out of the direct control of the Cargo project, e.g., upstream fix

Comments

@Kuly14
Copy link

Kuly14 commented Mar 22, 2023

Problem

When trying to run a specific test with a command like:

cargo test tests::test_lib

If you make a mistake in the path to the test it won't display any warning, it will just not run any tests:

Screenshot 2023-03-22 at 14 32 23

As you can see in the screenshot if you make a typo in the path it will still look like it passed even though the test doesn't exist:

Screenshot 2023-03-22 at 14 32 30

Proposed Solution

In my opinion, we should add a warning when the path leads to a nonexistent test e.g.:

WARNING: The test doesn't exist

Notes

No response

@Kuly14 Kuly14 added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Mar 22, 2023
@ehuss
Copy link
Contributor

ehuss commented Mar 22, 2023

This may be a difficult issue to address due to the way tests are coordinated. When running cargo test, there are multiple potential binaries that get executed (lib, bin, integration tests, etc.). Passing a test name filter shouldn't also require passing the cargo target to test. That means a test could run in one target, but all the others report 0 tests. I wouldn't want those emitting warnings that were too visible (as I would be concerned about that being confusing or too noisy).

This may be more feasible to address using the JSON output of the test harness, but that hasn't been stabilized yet or had much momentum in a while. And rust-lang/rust#108659 illustrates some of the difficulties of using the JSON interface, among other potential hazards.

@weihanglo weihanglo added Command-test S-blocked-external Status: ❌ blocked on something out of the direct control of the Cargo project, e.g., upstream fix labels Apr 20, 2023
edmorley added a commit to heroku/buildpacks-python that referenced this issue Oct 23, 2023
These tests had stopped running as of the module rename in #105,
since `cargo test` silently ignores invalid test names, ref:
rust-lang/cargo#11875

I'm going to be changing the way tests are split up in CI soon, which
will also make this less fragile - so for now I'm just fixing the module
name to restore test coverage on Heroku-20.
@edmorley
Copy link

edmorley commented Oct 23, 2023

I'd love it if the warning could be optionally made fatal (eg via a cargo test CLI arg) - which would help prevent the case where tests are silently not being run in CI (in our case a module name changed, wasn't updated in the CI workflow, and wasn't spotted for some time since Cargo happily exits zero even though nothing was tested).

edmorley added a commit to heroku/buildpacks-python that referenced this issue Oct 23, 2023
These tests had stopped running as of the module rename in #105,
since `cargo test` silently ignores invalid test names, ref:
rust-lang/cargo#11875

I'm going to be changing the way tests are split up in CI soon, which
will also make this less fragile - so for now I'm just fixing the module
name to restore test coverage on Heroku-20.

GUS-W-14346746.
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` Command-test S-blocked-external Status: ❌ blocked on something out of the direct control of the Cargo project, e.g., upstream fix
Projects
Status: No status
Development

No branches or pull requests

4 participants