Skip to content

Commit

Permalink
Rollup merge of rust-lang#57338 - QuietMisdreavus:doctest-file-name, …
Browse files Browse the repository at this point in the history
…r=GuillaumeGomez

rustdoc: force binary filename for compiled doctests

Fixes rust-lang#57317, needed for rust-lang/rust-by-example#1137

Right now, when building a doctest, rustdoc provides the compiler an output directory (a temp dir) but lets the compiler name the executable. If the doctest needs to be executed, it then tries to run a binary named `rust_out` from that directory. For the most part, this works fine. However, if the doctest sets its own crate name, the compiler uses that name for the output binary instead. This causes rustdoc to try to execute a nonexistent binary, causing the test to fail.

This PR changes the paths rustdoc gives to the compiler when building doctests to force the output *filename* instead of just the *directory*.
  • Loading branch information
kennytm authored Jan 5, 2019
2 parents a3afdd4 + 0b55c79 commit 284a419
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/librustdoc/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ fn run_test(test: &str, cratename: &str, filename: &FileName, line: usize,
target_features::add_configuration(&mut cfg, &sess, &*codegen_backend);
sess.parse_sess.config = cfg;

let out = Some(outdir.lock().unwrap().path().to_path_buf());
let out = Some(outdir.lock().unwrap().path().join("rust_out"));

if no_run {
control.after_analysis.stop = Compilation::Stop;
Expand All @@ -291,8 +291,8 @@ fn run_test(test: &str, cratename: &str, filename: &FileName, line: usize,
&cstore,
&None,
&input,
&out,
&None,
&out,
None,
&control
)
Expand Down
7 changes: 7 additions & 0 deletions src/test/rustdoc/doctest-manual-crate-name.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// compile-flags:--test

//! ```
//! #![crate_name="asdf"]
//!
//! println!("yo");
//! ```

0 comments on commit 284a419

Please sign in to comment.