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

Docs for Cargo Test mislieadingly imply that examples can be built and run as tests #11528

Closed
Farmadupe opened this issue Jan 2, 2023 · 1 comment · Fixed by #12032
Closed
Labels
A-documenting-cargo-itself Area: Cargo's documentation C-bug Category: bug Command-test S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review

Comments

@Farmadupe
Copy link

Farmadupe commented Jan 2, 2023

Problem

(Possible alternative title: Cargo Test does not run examples as tests when commanded)

(Relevant confusion in reddit thread here)

When read literally, line 140 of Cargo Test docs states that Cargo can reinterpret the main function of an example binary as a test, and execute it.

Since cargo does not appear to do this, a wording that does not have the misleading reading might be appropriate here.

Steps

No response

Possible Solution(s)

No response

Notes

No response

Version

No response

@Farmadupe Farmadupe added the C-bug Category: bug label Jan 2, 2023
@epage
Copy link
Contributor

epage commented Jan 3, 2023

Not having tried this, I'm assuming what is implicit here is that the default test harness is used, like any other test executable. This means it will discover and run #[test] functions. You'd have to disable the default test harness to do your own thing.

@epage epage added A-documenting-cargo-itself Area: Cargo's documentation Command-test labels Jan 3, 2023
bors added a commit that referenced this issue Apr 25, 2023
Clarify documentation around test target setting.

There was some confusion about the wording in this section regarding what happens with an example's `main` function. This tries to be more explicit to clarify what happens when an example is marked as a test.

This also adds a few other clarifications and a link to the reference documentation.

Closes #11528
@weihanglo weihanglo added the S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review label Apr 25, 2023
@bors bors closed this as completed in 03a5d8f Apr 25, 2023
charles-r-earp pushed a commit to charles-r-earp/cargo that referenced this issue May 3, 2023
There was some confusion about the wording in this section regarding
what happens with an example's `main` function. This tries to be more
explicit to clarify what happens when an example is marked as a test.

This also adds a few other clarifications and a link to the reference
documentation.

Closes rust-lang#11528
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-documenting-cargo-itself Area: Cargo's documentation C-bug Category: bug Command-test S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants