rustdoc: Use --crate-name with --test#16157
Closed
alexcrichton wants to merge 1 commit intorust-lang:masterfrom
Closed
rustdoc: Use --crate-name with --test#16157alexcrichton wants to merge 1 commit intorust-lang:masterfrom
alexcrichton wants to merge 1 commit intorust-lang:masterfrom
Conversation
src/librustdoc/test.rs
Outdated
Contributor
There was a problem hiding this comment.
This just seems weird. I'd rather see something like
if crate_name.is_some() { krate.name = crate_name.unwrap(); }
Contributor
There was a problem hiding this comment.
Or match crate_name { Some(n) => krate.name = n, None => {} } or for n in crate_name.move_iter() { krate.name = n } or crate_name.map(|n| krate.name = n).
Contributor
There was a problem hiding this comment.
I considered suggesting the match, but I figured a multi-line solution like that would not be as desired.
If we had rust-lang/rfcs#160 this would be a good candidate for if let:
if let Some(crate_name) = crate_name { krate.name = crate_name; }This ensures that the name of the crate is set from the command line for tests so the auto-injection of `extern crate <name>` in doc tests works correctly.
Member
Author
|
Updated with a |
bors
added a commit
that referenced
this pull request
Aug 1, 2014
This ensures that the name of the crate is set from the command line for tests so the auto-injection of `extern crate <name>` in doc tests works correctly.
alexcrichton
added a commit
to alexcrichton/cargo
that referenced
this pull request
Aug 5, 2014
Whenever `cargo test` is run and a testable library target is available, the doc tests will be run. This can be opted out of with `test = false` as usual. This is currently not super useful due to rust-lang/rust#16157, but I expect that to be merged soon. In the meantime examples will need to `extern crate foo` explicitly.
bors
added a commit
to rust-lang/cargo
that referenced
this pull request
Aug 6, 2014
Whenever `cargo test` is run and a testable library target is available, the doc tests will be run. This can be opted out of with `test = false` as usual. This is currently not super useful due to rust-lang/rust#16157, but I expect that to be merged soon. In the meantime examples will need to `extern crate foo` explicitly. Closes #334
alexcrichton
added a commit
to alexcrichton/cargo
that referenced
this pull request
Sep 2, 2014
Whenever `cargo test` is run and a testable library target is available, the doc tests will be run. This can be opted out of with `test = false` as usual. This is currently not super useful due to rust-lang/rust#16157, but I expect that to be merged soon. In the meantime examples will need to `extern crate foo` explicitly.
bors
added a commit
to alexcrichton/cargo
that referenced
this pull request
Sep 2, 2014
Whenever `cargo test` is run and a testable library target is available, the doc tests will be run. This can be opted out of with `test = false` as usual. This is currently not super useful due to rust-lang/rust#16157, but I expect that to be merged soon. In the meantime examples will need to `extern crate foo` explicitly. Closes rust-lang#334
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This ensures that the name of the crate is set from the command line for tests
so the auto-injection of
extern crate <name>in doc tests works correctly.