]> git.proxmox.com Git - cargo.git/commitdiff
Make a timing test a little less flaky
authorAlex Crichton <alex@alexcrichton.com>
Tue, 19 Aug 2014 05:51:14 +0000 (22:51 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Tue, 19 Aug 2014 06:47:57 +0000 (23:47 -0700)
src/bin/cargo.rs
src/cargo/sources/path.rs
tests/support/paths.rs
tests/test_cargo.rs
tests/test_cargo_compile_git_deps.rs

index 95f43e43952476461b2426c8f91773302da53ffa..b22a3a9edfe2a025c3d8a6a123093955cb22f52f 100644 (file)
@@ -29,9 +29,7 @@ Rust's package manager
 
 Usage:
     cargo <command> [<args>...]
-    cargo -h | --help
-    cargo -V | --version
-    cargo --list
+    cargo [options]
 
 Options:
     -h, --help       Display this message
index 0d65a19c725c363dad952c2a936c29384044fc9d..0ef3484f9ea6ecde6a1717168e76fd3a3757b75a 100644 (file)
@@ -82,14 +82,17 @@ impl PathSource {
         let root = pkg.get_manifest_path().dir_path();
         Ok(candidates.move_iter().filter(|candidate| {
             let candidate = candidate.path_relative_from(&root).unwrap();
-            !pats.iter().any(|p| p.matches_path(&candidate))
+            !pats.iter().any(|p| p.matches_path(&candidate)) &&
+                candidate.is_file()
         }).collect())
     }
 
     fn list_files_git(&self, pkg: &Package) -> CargoResult<Vec<Path>> {
         let cwd = pkg.get_manifest_path().dir_path();
         let mut cmd = process("git").cwd(cwd.clone());
-        cmd = cmd.arg("ls-files").arg("-z");
+        cmd = cmd.arg("ls-files").arg("-z")
+                 .arg("-x").arg("/target")
+                 .arg("-x").arg("/Cargo.lock");
 
         // Filter out all other packages with a filter directive
         for pkg in self.packages.iter().filter(|p| *p != pkg) {
@@ -190,6 +193,7 @@ impl Source for PathSource {
             // as 0.
             max = cmp::max(max, file.stat().map(|s| s.modified).unwrap_or(0));
         }
+        log!(5, "fingerprint {}: {}", self.path.display(), max);
         Ok(max.to_string())
     }
 }
index b8fd197c506da5efe5265eba5334dbcf8bd592c1..f14f1d03ab0db0f78eef1689bcc097fcab5ec7d1 100644 (file)
@@ -76,6 +76,14 @@ impl PathExt for Path {
 
             let hour = 1000 * 3600;
             let newtime = stat.modified - hour;
+
+            // Sadly change_file_times has the same failure mode as the above
+            // rmdir_recursive :(
+            match fs::change_file_times(path, newtime, newtime) {
+                Err(io::IoError { kind: io::PermissionDenied, .. }) => {}
+                e => return e,
+            }
+            try!(fs::chmod(path, stat.perm | io::UserWrite));
             fs::change_file_times(path, newtime, newtime)
         }
     }
index 3fc2034a166eeb05ef7e344a01f3f04a4f196ea2..d3bd640f86601347dd8a7a987e8bcc10f36d0357 100644 (file)
@@ -47,7 +47,7 @@ test!(list_commands_empty {
     let proj = project("list-runs");
     let pr = copied_executable_process(&proj, "cargo", &Path::new("bin"));
     let new_path = os::join_paths(new_path().as_slice()).unwrap();
-    assert_that(pr.arg("--list").env("PATH", Some(new_path.as_slice())),
+    assert_that(pr.arg("-v").arg("--list").env("PATH", Some(new_path.as_slice())),
                 execs().with_status(0)
                        .with_stdout("Installed Commands:\n"));
 })
@@ -67,7 +67,7 @@ test!(list_commands_non_overlapping {
     let mut path = new_path();
     path.push(proj.root().join("path-test"));
     let path = os::join_paths(path.as_slice()).unwrap();
-    assert_that(pr.arg("--list").env("PATH", Some(path.as_slice())),
+    assert_that(pr.arg("-v").arg("--list").env("PATH", Some(path.as_slice())),
                 execs().with_status(0)
                        .with_stdout("Installed Commands:\n   1\n   2\n   3\n"));
 })
index 5219e4f79bed245f71ed00c21b20b7ff7ebed9a2..5d0d8a6c52183c6e4ea5fa9bf4ea92cddaa913f2 100644 (file)
@@ -1030,11 +1030,12 @@ test!(git_build_cmd_freshness {
         .file("src/lib.rs", "pub fn bar() -> int { 1 }")
         .file(".gitignore", "
             src/bar.rs
-            Cargo.lock
         ")
     }).assert();
     foo.root().move_into_the_past().assert();
 
+    timer::sleep(Duration::milliseconds(1000));
+
     assert_that(foo.process(cargo_dir().join("cargo-build")),
                 execs().with_status(0)
                        .with_stdout(format!("\