Fix test failure in changing_bin_features_caches_targets for Linux.
authorEric Huss <eric@huss.org>
Tue, 22 May 2018 11:45:46 +0000 (04:45 -0700)
committerEric Huss <eric@huss.org>
Tue, 22 May 2018 11:45:46 +0000 (04:45 -0700)
Fixes rust-lang/rust#50962.

My theory is that while copying the binary, another thread forked with the fd
open.  The copy finishes and attempts to exec before the other child execs (and
closes the writeable fd).

I was able to easily repro this on linux.  I ran some stress tests of this fix
locally on linux and on appveyor, and was unable to trigger it again.

tests/testsuite/freshness.rs

index 7df638cfb03c0372c1f117b331f7773c5b45fa77..edf9c74dd628c9b11c2c9f0c865fd08f77450aa5 100644 (file)
@@ -522,7 +522,7 @@ fn changing_bin_features_caches_targets() {
     let foo_proc = |name: &str| {
         let src = p.bin("foo");
         let dst = p.bin(name);
-        fs::copy(&src, &dst).expect("Failed to copy foo");
+        fs::hard_link(&src, &dst).expect("Failed to link foo");
         p.process(dst)
     };