let dst = root.join("bin");
try!(check_overwrites(&dst, &pkg, &opts.filter, &list));
- let target_dir = config.cwd().join("target-install");
+ let target_dir = if source_id.is_path() {
+ config.target_dir(&pkg)
+ } else {
+ config.cwd().join("target-install")
+ };
config.set_target_dir(&target_dir);
let compile = try!(ops::compile_pkg(&pkg, Some(source), opts).chain_error(|| {
human(format!("failed to compile `{}`, intermediate artifacts can be \
}));
t.bins.push(dst);
}
- try!(fs::remove_dir_all(&target_dir));
+
+ if !source_id.is_path() {
+ try!(fs::remove_dir_all(&target_dir));
+ }
list.v1.entry(pkg.package_id().clone()).or_insert_with(|| {
BTreeSet::new()
use std::fs::{self, File};
use std::io::prelude::*;
use std::path::{Path, PathBuf};
+use support::paths::CargoPathExt;
use cargo::util::ProcessBuilder;
use hamcrest::{assert_that, existing_file, is_not, Matcher, MatchResult};
error: main function not found
error: aborting due to previous error
failed to compile `foo v0.1.0 (file://[..])`, intermediate artifacts can be \
- found at `[..]target-install`
+ found at `[..]target`
Caused by:
Could not compile `foo`.
assert_that(cargo_process("install"), execs().with_status(0));
assert_that(cargo_home(), has_installed_exe("foo"));
});
+
+test!(do_not_rebuilds_on_local_install {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.1.0"
+ authors = []
+ "#)
+ .file("src/main.rs", "fn main() {}");
+
+ assert_that(p.cargo_process("build").arg("--release"),
+ execs().with_status(0));
+ assert_that(cargo_process("install").arg("--path").arg(p.root()),
+ execs().with_status(0).with_stdout("\
+ Installing [..]
+").with_stderr("\
+be sure to add `[..]` to your PATH to be able to run the installed binaries
+"));
+
+ assert!(p.build_dir().c_exists());
+ assert!(p.release_bin("foo").c_exists());
+ assert_that(cargo_home(), has_installed_exe("foo"));
+});