-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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 library path argument for mdbook test
#340
Add library path argument for mdbook test
#340
Conversation
src/book/mod.rs
Outdated
@@ -379,7 +383,7 @@ impl MDBook { | |||
|
|||
println!("[*]: Testing file: {:?}", path); | |||
|
|||
let output_result = Command::new("rustdoc").arg(&path).arg("--test").output(); | |||
let output_result = Command::new("rustdoc").arg(&path).arg("--test").args(&library_args).output(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this going to work okay when no arguments are passed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. With no/empty arguments, it simply returns self
.
https://github.com/rust-lang/rust/blob/master/src/libstd/process.rs#L403
Thanks! |
src/book/mod.rs
Outdated
// read in the chapters | ||
self.parse_summary()?; | ||
let library_args: Vec<&str> = (0..library_paths.len()).map(|_| "-L") | ||
.zip(library_paths.into_iter()) | ||
.flat_map(|x| vec![x.0, x.1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a little annoying that tuple
does not implement IntoIterator
trait, causing this vec![x.0, x.1]
nonsense.
Thanks! And sorry for the delay :) |
It may be a good idea to thread this through the configuration system so you aren't continually writing the "-L" arguments. When #371 lands I'll move onto tidying up configuration and see if I can add an extra "tests" table to the |
@Michael-F-Bryan I don't see this as a permanent solution. The test command is currently just a wrapper around rustdoc, maybe with some additional checks, because it was needed for the Rust book. But ideally we would want this to be configurable and extendable by the user. Because there is no way we can anticipate everything the user would want to "tests". |
My thoughts were that you could add something like this to your [test]
runner = "rustdoc"
dependencies = ["error-chain", "rayon"] To me the test runner is pretty much just an alternate renderer, except instead of rendering content it'll give you a pass or a fail (because a Otherwise if you have your own custom test script it might be invoked like this: [test]
runner = "shell"
command = "test_docs.py" EDIT: Note that this would be more of a long-term goal. It relies on a more flexible system for rendering and configuration than what currently exists. |
That would be nice indeed! |
On the other hand rust-cookbook uses https://github.com/brson/rust-skeptic/. We never invoke But I understand why |
Hmm on the other hand I do not see a better way (I mean this general approach suggested by @Michael-F-Bryan) to support spell checking and link checking which are very much desired. So big 👍 |
…brary-path Add library path argument for `mdbook test`
Add
-L
/--library-path
argument and pass it intorustdoc
should be sufficient.Closes #339