Revive the -T aka --time-passes argument to report run times on the CLI;
This commit is contained in:
committed by
Dan Gohman
parent
58229e10bf
commit
af0a239539
@@ -35,6 +35,7 @@ extern crate num_cpus;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
use cranelift_codegen::timing;
|
||||
use cranelift_reader::TestCommand;
|
||||
use runner::TestRunner;
|
||||
use std::path::Path;
|
||||
@@ -73,8 +74,8 @@ type TestResult = Result<time::Duration, String>;
|
||||
/// Directories are scanned recursively for test cases ending in `.clif`. These test cases are
|
||||
/// executed on background threads.
|
||||
///
|
||||
pub fn run(verbose: bool, files: &[String]) -> TestResult {
|
||||
let mut runner = TestRunner::new(verbose);
|
||||
pub fn run(verbose: bool, report_times: bool, files: &[String]) -> TestResult {
|
||||
let mut runner = TestRunner::new(verbose, report_times);
|
||||
|
||||
for path in files.iter().map(Path::new) {
|
||||
if path.is_file() {
|
||||
@@ -93,8 +94,14 @@ pub fn run(verbose: bool, files: &[String]) -> TestResult {
|
||||
///
|
||||
/// Directories are scanned recursively for test cases ending in `.clif`.
|
||||
///
|
||||
pub fn run_passes(verbose: bool, passes: &[String], target: &str, file: &str) -> TestResult {
|
||||
let mut runner = TestRunner::new(verbose);
|
||||
pub fn run_passes(
|
||||
verbose: bool,
|
||||
report_times: bool,
|
||||
passes: &[String],
|
||||
target: &str,
|
||||
file: &str,
|
||||
) -> TestResult {
|
||||
let mut runner = TestRunner::new(verbose, /* report_times */ false);
|
||||
|
||||
let path = Path::new(file);
|
||||
if path == Path::new("-") || path.is_file() {
|
||||
@@ -103,7 +110,11 @@ pub fn run_passes(verbose: bool, passes: &[String], target: &str, file: &str) ->
|
||||
runner.push_dir(path);
|
||||
}
|
||||
|
||||
runner.run_passes(passes, target)
|
||||
let result = runner.run_passes(passes, target);
|
||||
if report_times {
|
||||
println!("{}", timing::take_current());
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
/// Create a new subcommand trait object to match `parsed.command`.
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
//! scanning directories for tests.
|
||||
|
||||
use concurrent::{ConcurrentRunner, Reply};
|
||||
use cranelift_codegen::timing;
|
||||
use std::error::Error;
|
||||
use std::ffi::OsStr;
|
||||
use std::fmt::{self, Display};
|
||||
@@ -62,6 +63,9 @@ impl Display for QueueEntry {
|
||||
pub struct TestRunner {
|
||||
verbose: bool,
|
||||
|
||||
// Should we print the timings out?
|
||||
report_times: bool,
|
||||
|
||||
// Directories that have not yet been scanned.
|
||||
dir_stack: Vec<PathBuf>,
|
||||
|
||||
@@ -85,9 +89,10 @@ pub struct TestRunner {
|
||||
|
||||
impl TestRunner {
|
||||
/// Create a new blank TrstRunner.
|
||||
pub fn new(verbose: bool) -> Self {
|
||||
pub fn new(verbose: bool, report_times: bool) -> Self {
|
||||
Self {
|
||||
verbose,
|
||||
report_times,
|
||||
dir_stack: Vec::new(),
|
||||
tests: Vec::new(),
|
||||
new_tests: 0,
|
||||
@@ -300,6 +305,9 @@ impl TestRunner {
|
||||
}
|
||||
}
|
||||
conc.join();
|
||||
if self.report_times {
|
||||
println!("{}", timing::take_current());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user