compiletest: Add caching of test results · rust-lang/rust@c8e0d04 (original) (raw)
`@@ -25,13 +25,15 @@ extern crate rustc_serialize;
`
25
25
`#[macro_use]
`
26
26
`extern crate log;
`
27
27
`extern crate env_logger;
`
``
28
`+
extern crate filetime;
`
28
29
``
29
30
`use std::env;
`
30
31
`use std::ffi::OsString;
`
31
32
`use std::fs;
`
32
33
`use std::io;
`
33
34
`use std::path::{Path, PathBuf};
`
34
35
`use std::process::Command;
`
``
36
`+
use filetime::FileTime;
`
35
37
`use getopts::{optopt, optflag, reqopt};
`
36
38
`use common::Config;
`
37
39
`use common::{Pretty, DebugInfoGdb, DebugInfoLldb, Mode};
`
`@@ -457,7 +459,7 @@ pub fn make_test(config: &Config, testpaths: &TestPaths) -> test::TestDescAndFn
`
457
459
`};
`
458
460
``
459
461
`// Debugging emscripten code doesn't make sense today
`
460
``
`-
let mut ignore = early_props.ignore;
`
``
462
`+
let mut ignore = early_props.ignore || !up_to_date(config, testpaths, &early_props);
`
461
463
`if (config.mode == DebugInfoGdb || config.mode == DebugInfoLldb) &&
`
462
464
` config.target.contains("emscripten") {
`
463
465
` ignore = true;
`
`@@ -473,6 +475,42 @@ pub fn make_test(config: &Config, testpaths: &TestPaths) -> test::TestDescAndFn
`
473
475
`}
`
474
476
`}
`
475
477
``
``
478
`+
fn stamp(config: &Config, testpaths: &TestPaths) -> PathBuf {
`
``
479
`+
let stamp_name = format!("{}-H-{}-T-{}-S-{}.stamp",
`
``
480
`+
testpaths.file.file_name().unwrap()
`
``
481
`+
.to_str().unwrap(),
`
``
482
`+
config.host,
`
``
483
`+
config.target,
`
``
484
`+
config.stage_id);
`
``
485
`+
config.build_base.canonicalize()
`
``
486
`+
.unwrap_or(config.build_base.clone())
`
``
487
`+
.join(stamp_name)
`
``
488
`+
}
`
``
489
+
``
490
`+
fn up_to_date(config: &Config, testpaths: &TestPaths, props: &EarlyProps) -> bool {
`
``
491
`+
let stamp = mtime(&stamp(config, testpaths));
`
``
492
`+
let mut inputs = vec![
`
``
493
`+
mtime(&testpaths.file),
`
``
494
`+
mtime(&config.rustc_path),
`
``
495
`+
];
`
``
496
`+
for aux in props.aux.iter() {
`
``
497
`+
inputs.push(mtime(&testpaths.file.parent().unwrap()
`
``
498
`+
.join("auxiliary")
`
``
499
`+
.join(aux)));
`
``
500
`+
}
`
``
501
`+
for lib in config.run_lib_path.read_dir().unwrap() {
`
``
502
`+
let lib = lib.unwrap();
`
``
503
`+
inputs.push(mtime(&lib.path()));
`
``
504
`+
}
`
``
505
`+
inputs.iter().any(|input| *input > stamp)
`
``
506
`+
}
`
``
507
+
``
508
`+
fn mtime(path: &Path) -> FileTime {
`
``
509
`+
fs::metadata(path).map(|f| {
`
``
510
`+
FileTime::from_last_modification_time(&f)
`
``
511
`+
}).unwrap_or(FileTime::zero())
`
``
512
`+
}
`
``
513
+
476
514
`pub fn make_test_name(config: &Config, testpaths: &TestPaths) -> test::TestName {
`
477
515
`// Convert a complete path to something like
`
478
516
`//
`