Skip to content

Commit c919118

Browse files
committed
Fix tests for mac
1 parent b7976d1 commit c919118

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/cargo/ops/cargo_rustc/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -645,8 +645,12 @@ fn hardlink_or_copy(src: &Path, dst: &Path) -> CargoResult<()> {
645645
use std::os::windows::fs::symlink_dir as symlink;
646646

647647
let dst_dir = dst.parent().unwrap();
648-
assert!(src.starts_with(dst_dir));
649-
symlink(src.strip_prefix(dst_dir).unwrap(), dst)
648+
let src = if src.starts_with(dst_dir) {
649+
src.strip_prefix(dst_dir).unwrap()
650+
} else {
651+
src
652+
};
653+
symlink(src, dst)
650654
} else {
651655
fs::hard_link(src, dst)
652656
};

tests/testsuite/out_dir.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
use std::path::Path;
22
use std::fs::{self, File};
33
use std::env;
4-
use std::io::Write;
54

65
use hamcrest::assert_that;
76

8-
use cargotest::{process, ChannelChanger};
7+
use cargotest::{process, sleep_ms, ChannelChanger};
98
use cargotest::support::{execs, project};
109

1110
#[test]
@@ -31,7 +30,7 @@ fn binary_with_debug() {
3130
check_dir_contents(
3231
&p.root().join("out"),
3332
&["foo"],
34-
&["foo"],
33+
&["foo", "foo.dSYM"],
3534
&["foo.exe", "foo.pdb"],
3635
);
3736
}
@@ -105,7 +104,7 @@ fn dynamic_library_with_debug() {
105104
check_dir_contents(
106105
&p.root().join("out"),
107106
&["libfoo.so"],
108-
&["libfoo.so"],
107+
&["libfoo.dylib"],
109108
&["foo.dll", "foo.dll.lib"],
110109
);
111110
}
@@ -194,7 +193,7 @@ fn include_only_the_binary_from_the_current_package() {
194193
check_dir_contents(
195194
&p.root().join("out"),
196195
&["foo"],
197-
&["foo"],
196+
&["foo", "foo.dSYM"],
198197
&["foo.exe", "foo.pdb"],
199198
);
200199
}
@@ -250,10 +249,8 @@ fn replaces_artifacts() {
250249
execs().with_stdout("foo"),
251250
);
252251

253-
fs::File::create(p.root().join("src/main.rs"))
254-
.unwrap()
255-
.write_all(br#"fn main() { println!("bar") }"#)
256-
.unwrap();
252+
sleep_ms(1000);
253+
p.change_file("src/main.rs", r#"fn main() { println!("bar") }"#);
257254

258255
assert_that(
259256
p.cargo("build -Z out-dir --out-dir out")

0 commit comments

Comments
 (0)