about summary refs log tree commit diff
path: root/src/tools/compiletest
diff options
context:
space:
mode:
authorMark Rousskov <mark.simulacrum@gmail.com>2019-01-23 17:34:43 -0700
committerMark Rousskov <mark.simulacrum@gmail.com>2019-01-25 14:31:38 -0700
commit82fae2be049f37bc20d2bad6c6c482a7d957f687 (patch)
tree3cda509366d543b3c9fe0e1cc59e68ce085951b8 /src/tools/compiletest
parent6bba352cad2117f56353d400f71e96eafa2e6bd7 (diff)
downloadrust-82fae2be049f37bc20d2bad6c6c482a7d957f687.tar.gz
rust-82fae2be049f37bc20d2bad6c6c482a7d957f687.zip
Correctly set filetime for copied LLVM
This also makes compiletest no longer always retest everything.
Diffstat (limited to 'src/tools/compiletest')
-rw-r--r--src/tools/compiletest/src/main.rs54
-rw-r--r--src/tools/compiletest/src/runtest.rs3
2 files changed, 37 insertions, 20 deletions
diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs
index 2e5feca5415..94317f541c3 100644
--- a/src/tools/compiletest/src/main.rs
+++ b/src/tools/compiletest/src/main.rs
@@ -669,15 +669,6 @@ fn stamp(config: &Config, testpaths: &TestPaths, revision: Option<&str>) -> Path
     output_base_dir(config, testpaths, revision).join("stamp")
 }
 
-/// Return an iterator over timestamps of files in the directory at `path`.
-fn collect_timestamps(path: &PathBuf) -> impl Iterator<Item=FileTime> {
-    WalkDir::new(path)
-        .into_iter()
-        .map(|entry| entry.unwrap())
-        .filter(|entry| entry.file_type().is_file())
-        .map(|entry| mtime(entry.path()))
-}
-
 fn up_to_date(
     config: &Config,
     testpaths: &TestPaths,
@@ -700,13 +691,15 @@ fn up_to_date(
     let rust_src_dir = config
         .find_rust_src_root()
         .expect("Could not find Rust source root");
-    let stamp = mtime(&stamp_name);
-    let mut inputs = vec![mtime(&testpaths.file), mtime(&config.rustc_path)];
+    let stamp = Stamp::from_path(&stamp_name);
+    let mut inputs = vec![Stamp::from_path(&testpaths.file), Stamp::from_path(&config.rustc_path)];
     inputs.extend(
         props
             .aux
             .iter()
-            .map(|aux| mtime(&testpaths.file.parent().unwrap().join("auxiliary").join(aux))),
+            .map(|aux| {
+                Stamp::from_path(&testpaths.file.parent().unwrap().join("auxiliary").join(aux))
+            }),
     );
     // Relevant pretty printer files
     let pretty_printer_files = [
@@ -717,24 +710,47 @@ fn up_to_date(
         "src/etc/lldb_rust_formatters.py",
     ];
     inputs.extend(pretty_printer_files.iter().map(|pretty_printer_file| {
-        mtime(&rust_src_dir.join(pretty_printer_file))
+        Stamp::from_path(&rust_src_dir.join(pretty_printer_file))
     }));
-    inputs.extend(collect_timestamps(&config.run_lib_path));
+    inputs.extend(Stamp::from_dir(&config.run_lib_path));
     if let Some(ref rustdoc_path) = config.rustdoc_path {
-        inputs.push(mtime(&rustdoc_path));
-        inputs.push(mtime(&rust_src_dir.join("src/etc/htmldocck.py")));
+        inputs.push(Stamp::from_path(&rustdoc_path));
+        inputs.push(Stamp::from_path(&rust_src_dir.join("src/etc/htmldocck.py")));
     }
 
     // UI test files.
     inputs.extend(UI_EXTENSIONS.iter().map(|extension| {
         let path = &expected_output_path(testpaths, revision, &config.compare_mode, extension);
-        mtime(path)
+        Stamp::from_path(path)
     }));
 
     // Compiletest itself.
-    inputs.extend(collect_timestamps(&rust_src_dir.join("src/tools/compiletest/")));
+    inputs.extend(Stamp::from_dir(&rust_src_dir.join("src/tools/compiletest/")));
 
-    inputs.iter().any(|input| *input > stamp)
+    inputs.iter().any(|input| input > &stamp)
+}
+
+#[derive(Debug, PartialEq, PartialOrd, Ord, Eq)]
+struct Stamp {
+    time: FileTime,
+    file: PathBuf,
+}
+
+impl Stamp {
+    fn from_path(p: &Path) -> Self {
+        Stamp {
+            time: mtime(&p),
+            file: p.into(),
+        }
+    }
+
+    fn from_dir(path: &Path) -> impl Iterator<Item=Stamp> {
+        WalkDir::new(path)
+            .into_iter()
+            .map(|entry| entry.unwrap())
+            .filter(|entry| entry.file_type().is_file())
+            .map(|entry| Stamp::from_path(entry.path()))
+    }
 }
 
 fn mtime(path: &Path) -> FileTime {
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
index 400c205d44b..3c2ca9702dc 100644
--- a/src/tools/compiletest/src/runtest.rs
+++ b/src/tools/compiletest/src/runtest.rs
@@ -1998,7 +1998,8 @@ impl<'test> TestCx<'test> {
 
     fn fatal(&self, err: &str) -> ! {
         self.error(err);
-        panic!();
+        error!("fatal error, panic: {:?}", err);
+        panic!("fatal error");
     }
 
     fn fatal_proc_rec(&self, err: &str, proc_res: &ProcRes) -> ! {