Skip to content

Commit

Permalink
Fix nightly breakage of doctests in workspaces
Browse files Browse the repository at this point in the history
In rust-lang/cargo#8954 the working directory for the runner executable changed for doctests. Before, the working directory was the crate dir, now it is the workspace dir. This lead to a bug in bootimage because it now looked for the `test-args` and other config option in the workpace root `Cargo.toml`, instead of the crate-specific `Cargo.toml`.

This commit fixes this by using the `CARGO_MANIFEST_DIR` environment variable for determining the `Cargo.toml` path, instead of directly using `cargo locate-project` as before.
  • Loading branch information
phil-opp committed Dec 10, 2020
1 parent 0a5fa3d commit 54492a9
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,18 @@ impl Builder {
///
/// If None is passed for `manifest_path`, it is automatically searched.
pub fn new(manifest_path: Option<PathBuf>) -> Result<Self, BuilderError> {
let manifest_path = manifest_path.unwrap_or(locate_cargo_manifest::locate_manifest()?);
let manifest_path = match manifest_path.or_else(|| {
std::env::var("CARGO_MANIFEST_DIR")
.ok()
.map(|dir| Path::new(&dir).join("Cargo.toml"))
}) {
Some(path) => path,
None => {
println!("WARNING: `CARGO_MANIFEST_DIR` env variable not set");
locate_cargo_manifest::locate_manifest()?
}
};

Ok(Builder {
manifest_path,
project_metadata: None,
Expand Down

0 comments on commit 54492a9

Please sign in to comment.