Rollup merge of #60805 - euclio:filetime-dep, r=Mark-Simulacrum

remove compiletest's dependency on `filetime`
This commit is contained in:
Mazdak Farrokhzad 2019-05-17 02:54:14 +02:00 committed by GitHub
commit 23d91e272b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 15 deletions

View File

@ -475,7 +475,6 @@ version = "0.0.0"
dependencies = [
"diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)",
"filetime 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@ -7,7 +7,6 @@ edition = "2018"
[dependencies]
diff = "0.1.10"
env_logger = { version = "0.5", default-features = false }
filetime = "0.2"
getopts = "0.2"
log = "0.4"
regex = "1.0"

View File

@ -9,7 +9,6 @@ use crate::common::CompareMode;
use crate::common::{expected_output_path, output_base_dir, output_relative_path, UI_EXTENSIONS};
use crate::common::{Config, TestPaths};
use crate::common::{DebugInfoBoth, DebugInfoGdb, DebugInfoLldb, Mode, Pretty};
use filetime::FileTime;
use getopts::Options;
use std::env;
use std::ffi::OsString;
@ -17,6 +16,7 @@ use std::fs;
use std::io::{self, ErrorKind};
use std::path::{Path, PathBuf};
use std::process::Command;
use std::time::SystemTime;
use test::ColorConfig;
use crate::util::logv;
use walkdir::WalkDir;
@ -752,31 +752,36 @@ fn up_to_date(
#[derive(Debug, PartialEq, PartialOrd, Ord, Eq)]
struct Stamp {
time: FileTime,
time: SystemTime,
file: PathBuf,
}
impl Stamp {
fn from_path(p: &Path) -> Self {
let time = fs::metadata(p)
.and_then(|metadata| metadata.modified())
.unwrap_or(SystemTime::UNIX_EPOCH);
Stamp {
time: mtime(&p),
time,
file: p.into(),
}
}
fn from_dir(path: &Path) -> impl Iterator<Item=Stamp> {
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()))
}
}
.map(|entry| {
let time = (|| -> io::Result<_> { entry.metadata()?.modified() })();
fn mtime(path: &Path) -> FileTime {
fs::metadata(path)
.map(|f| FileTime::from_last_modification_time(&f))
.unwrap_or_else(|_| FileTime::zero())
Stamp {
time: time.unwrap_or(SystemTime::UNIX_EPOCH),
file: entry.path().into(),
}
})
}
}
fn make_test_name(

View File

@ -9,7 +9,6 @@ use crate::common::{Config, TestPaths};
use crate::common::{Incremental, MirOpt, RunMake, Ui, JsDocTest, Assembly};
use diff;
use crate::errors::{self, Error, ErrorKind};
use filetime::FileTime;
use crate::header::TestProps;
use crate::json;
use regex::{Captures, Regex};
@ -3029,7 +3028,7 @@ impl<'test> TestCx<'test> {
}
fn check_mir_test_timestamp(&self, test_name: &str, output_file: &Path) {
let t = |file| FileTime::from_last_modification_time(&fs::metadata(file).unwrap());
let t = |file| fs::metadata(file).unwrap().modified().unwrap();
let source_file = &self.testpaths.file;
let output_time = t(output_file);
let source_time = t(source_file);