Skip to content

Add to Testing docs to make more clear #29089

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

Merged
merged 2 commits into from
Oct 17, 2015

Conversation

kickinbahk
Copy link
Contributor

When going through the docs, it is not clear that binary files cannot be tested. Additionally, it is hard to find the proper structure of a Rust crate and it took me several hours of looking through the docs to find the crates and modules section. I think we can link to it from here and it will be beneficial to those who are coming to the language.

When going through the docs, it is not clear that binary files cannot be tested. Additionally, it is hard to find the proper structure of a Rust crate and it took me several hours of looking through the docs to find the crates and modules section. I think we can link to it from here and it will be beneficial to those who are coming to the language.
@rust-highfive
Copy link
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@@ -504,3 +504,5 @@ you add more examples.

We haven’t covered all of the details with writing documentation tests. For more,
please see the [Documentation chapter](documentation.html)

One final note: Tests *cannot* be run on the binary (main) file. To see more on file arrangement see the [Crates and Modules](https://doc.rust-lang.org/stable/book/crates-and-modules.html) Section
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few things:

  1. Can you make the link relative, please. See the line right about your diff.
  2. Section should be lower case, at the end of the sentence.
  3. End with a period please!
  4. I mean, you can run tests on a binary, you can't urn unit tests defined in the binary. You can test binaries through integration tests. So I'm not sure about this wording.
  5. I would prefer to just remove the main bit, and make it "a binary" rather than "the binary (main) file"

@steveklabnik
Copy link
Member

Some nits! I do think this is a good improvement 👍

@kickinbahk
Copy link
Contributor Author

@steveklabnik thanks for the feedback. I will definitely change 1-3.

I was having trouble running tests from a tests directory on a binary or main.rs file and based off the feedback in IRC as well as the docs, it made it seem that it is not possible. Rather, would need to have the code in a lib.rs file for it to be tested and call that from the main.rs file. If I am not correct on any of this understanding, I would love for further clarification.

I think the part that I am not clear on is "You can test binaries through integration tests". Would this be by using an crate rather than the built in test framework?

@steveklabnik
Copy link
Member

Well, the lib.rs/main.rs thing is the Cargo convention, but not always true. Like, binaries in src/bins/, for example, which have different names.

Would this be by using an crate rather than the built in test framework?

No, you'd use std::process::Command, basically. I was trying to say that it is possible to test binaries, somehow.

Fixed some typos and changed the link to the link to crates-and-modules to be dynamic.
@kickinbahk
Copy link
Contributor Author

@steveklabnik Thank you for clarifying that. I have made those changes that you recommended.

@steveklabnik
Copy link
Member

@bors: r+ rollup

@bors
Copy link
Collaborator

bors commented Oct 16, 2015

📌 Commit cf926f1 has been approved by steveklabnik

@steveklabnik
Copy link
Member

Thanks so much!

@bors
Copy link
Collaborator

bors commented Oct 17, 2015

⌛ Testing commit cf926f1 with merge 971856d...

bors added a commit that referenced this pull request Oct 17, 2015
When going through the docs, it is not clear that binary files cannot be tested. Additionally, it is hard to find the proper structure of a Rust crate and it took me several hours of looking through the docs to find the crates and modules section. I think we can link to it from here and it will be beneficial to those who are coming to the language.
@bors bors merged commit cf926f1 into rust-lang:master Oct 17, 2015
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.

5 participants