From fff5de375a3f0ddc7e0d8cb98a75c890af7c7299 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 18 Aug 2014 22:51:14 -0700 Subject: [PATCH] Make a timing test a little less flaky --- src/bin/cargo.rs | 4 +--- src/cargo/sources/path.rs | 8 ++++++-- tests/support/paths.rs | 8 ++++++++ tests/test_cargo.rs | 4 ++-- tests/test_cargo_compile_git_deps.rs | 3 ++- 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/bin/cargo.rs b/src/bin/cargo.rs index 95f43e439..b22a3a9ed 100644 --- a/src/bin/cargo.rs +++ b/src/bin/cargo.rs @@ -29,9 +29,7 @@ Rust's package manager Usage: cargo [...] - cargo -h | --help - cargo -V | --version - cargo --list + cargo [options] Options: -h, --help Display this message diff --git a/src/cargo/sources/path.rs b/src/cargo/sources/path.rs index 0d65a19c7..0ef3484f9 100644 --- a/src/cargo/sources/path.rs +++ b/src/cargo/sources/path.rs @@ -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> { 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()) } } diff --git a/tests/support/paths.rs b/tests/support/paths.rs index b8fd197c5..f14f1d03a 100644 --- a/tests/support/paths.rs +++ b/tests/support/paths.rs @@ -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) } } diff --git a/tests/test_cargo.rs b/tests/test_cargo.rs index 3fc2034a1..d3bd640f8 100644 --- a/tests/test_cargo.rs +++ b/tests/test_cargo.rs @@ -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")); }) diff --git a/tests/test_cargo_compile_git_deps.rs b/tests/test_cargo_compile_git_deps.rs index 5219e4f79..5d0d8a6c5 100644 --- a/tests/test_cargo_compile_git_deps.rs +++ b/tests/test_cargo_compile_git_deps.rs @@ -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!("\ -- 2.39.5