Skip to content

Commit

Permalink
Auto merge of #3229 - martinhath:master, r=alexcrichton
Browse files Browse the repository at this point in the history
Add fix and test for #3224

This commit fixes #3224, and adds a test for it.
First time contributor to Cargo here, so I'm sorry if I put stuff the wrong places :)
  • Loading branch information
bors authored Oct 25, 2016
2 parents 62b5992 + 84fe070 commit ad47f0a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/cargo/ops/cargo_rustc/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ use std::io;
use std::path::{PathBuf, Path};

use core::{Package, Workspace};
use util::{Config, FileLock, CargoResult, Filesystem};
use util::{Config, FileLock, CargoResult, Filesystem, human};
use util::hex::short_hash;
use super::Unit;

Expand Down Expand Up @@ -78,7 +78,8 @@ impl Layout {
// the target triple as a Path and then just use the file stem as the
// component for the directory name.
if let Some(triple) = triple {
path.push(Path::new(triple).file_stem().unwrap());
path.push(try!(Path::new(triple).file_stem()
.ok_or(human(format!("target was empty")))));
}
path.push(dest);
Layout::at(ws.config(), path)
Expand Down
12 changes: 12 additions & 0 deletions tests/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2374,3 +2374,15 @@ fn no_warn_about_package_metadata() {
.with_stderr("[..] foo v0.0.1 ([..])\n\
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]\n"));
}

#[test]
fn cargo_build_empty_target() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/main.rs", "fn main() {}");
p.build();

assert_that(p.cargo_process("build").arg("--target").arg(""),
execs().with_status(101)
.with_stderr_contains("[..] target was empty"));
}

0 comments on commit ad47f0a

Please sign in to comment.