Skip to content

Commit

Permalink
Fix tests for mac
Browse files Browse the repository at this point in the history
  • Loading branch information
matklad committed Apr 3, 2018
1 parent b7976d1 commit c919118
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
8 changes: 6 additions & 2 deletions src/cargo/ops/cargo_rustc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -645,8 +645,12 @@ fn hardlink_or_copy(src: &Path, dst: &Path) -> CargoResult<()> {
use std::os::windows::fs::symlink_dir as symlink;

let dst_dir = dst.parent().unwrap();
assert!(src.starts_with(dst_dir));
symlink(src.strip_prefix(dst_dir).unwrap(), dst)
let src = if src.starts_with(dst_dir) {
src.strip_prefix(dst_dir).unwrap()
} else {
src
};
symlink(src, dst)
} else {
fs::hard_link(src, dst)
};
Expand Down
15 changes: 6 additions & 9 deletions tests/testsuite/out_dir.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use std::path::Path;
use std::fs::{self, File};
use std::env;
use std::io::Write;

use hamcrest::assert_that;

use cargotest::{process, ChannelChanger};
use cargotest::{process, sleep_ms, ChannelChanger};
use cargotest::support::{execs, project};

#[test]
Expand All @@ -31,7 +30,7 @@ fn binary_with_debug() {
check_dir_contents(
&p.root().join("out"),
&["foo"],
&["foo"],
&["foo", "foo.dSYM"],
&["foo.exe", "foo.pdb"],
);
}
Expand Down Expand Up @@ -105,7 +104,7 @@ fn dynamic_library_with_debug() {
check_dir_contents(
&p.root().join("out"),
&["libfoo.so"],
&["libfoo.so"],
&["libfoo.dylib"],
&["foo.dll", "foo.dll.lib"],
);
}
Expand Down Expand Up @@ -194,7 +193,7 @@ fn include_only_the_binary_from_the_current_package() {
check_dir_contents(
&p.root().join("out"),
&["foo"],
&["foo"],
&["foo", "foo.dSYM"],
&["foo.exe", "foo.pdb"],
);
}
Expand Down Expand Up @@ -250,10 +249,8 @@ fn replaces_artifacts() {
execs().with_stdout("foo"),
);

fs::File::create(p.root().join("src/main.rs"))
.unwrap()
.write_all(br#"fn main() { println!("bar") }"#)
.unwrap();
sleep_ms(1000);
p.change_file("src/main.rs", r#"fn main() { println!("bar") }"#);

assert_that(
p.cargo("build -Z out-dir --out-dir out")
Expand Down

0 comments on commit c919118

Please sign in to comment.