mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-24 01:15:12 +03:00
put test results in different directories and remove successful logs
This commit is contained in:
parent
03712f65d5
commit
d5e0a6fc49
@ -5,7 +5,6 @@ use abstutil::Error;
|
|||||||
use gag::Redirect;
|
use gag::Redirect;
|
||||||
use std;
|
use std;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::str::FromStr;
|
|
||||||
use yansi::Paint;
|
use yansi::Paint;
|
||||||
|
|
||||||
pub struct TestRunner {
|
pub struct TestRunner {
|
||||||
@ -13,6 +12,7 @@ pub struct TestRunner {
|
|||||||
results: Vec<TestResult>,
|
results: Vec<TestResult>,
|
||||||
filter: Filter,
|
filter: Filter,
|
||||||
test_name_filter: Option<String>,
|
test_name_filter: Option<String>,
|
||||||
|
output_dir: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TestResult {
|
struct TestResult {
|
||||||
@ -29,6 +29,13 @@ impl TestRunner {
|
|||||||
results: Vec::new(),
|
results: Vec::new(),
|
||||||
filter,
|
filter,
|
||||||
test_name_filter,
|
test_name_filter,
|
||||||
|
output_dir: format!(
|
||||||
|
"/tmp/abst_tests_{}",
|
||||||
|
std::time::SystemTime::now()
|
||||||
|
.duration_since(std::time::SystemTime::UNIX_EPOCH)
|
||||||
|
.unwrap()
|
||||||
|
.as_secs()
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,12 +62,10 @@ impl TestRunner {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (fast && self.filter == Filter::Slow) || (!fast && self.filter == Filter::Fast) {
|
if (fast && self.filter == Filter::Slow) || (!fast && self.filter == Filter::Fast) {
|
||||||
println!("Skipping {}", test_name);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if let Some(ref filter) = self.test_name_filter {
|
if let Some(ref filter) = self.test_name_filter {
|
||||||
if !test_name.contains(filter) {
|
if !test_name.contains(filter) {
|
||||||
println!("Skipping {}", test_name);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -68,10 +73,9 @@ impl TestRunner {
|
|||||||
print!("Running {}...", test_name);
|
print!("Running {}...", test_name);
|
||||||
std::io::stdout().flush().unwrap();
|
std::io::stdout().flush().unwrap();
|
||||||
|
|
||||||
// TODO Make a temporary directory inside /tmp, remove successful files
|
|
||||||
let start = std::time::Instant::now();
|
let start = std::time::Instant::now();
|
||||||
let mut helper = TestHelper {};
|
let mut helper = TestHelper {};
|
||||||
let output_path = format!("/tmp/{}.log", test_name);
|
let output_path = format!("{}/{}.log", self.output_dir, test_name);
|
||||||
std::fs::create_dir_all(std::path::Path::new(&output_path).parent().unwrap())
|
std::fs::create_dir_all(std::path::Path::new(&output_path).parent().unwrap())
|
||||||
.expect("Creating parent dir failed");
|
.expect("Creating parent dir failed");
|
||||||
|
|
||||||
@ -118,6 +122,10 @@ impl TestRunner {
|
|||||||
result.duration,
|
result.duration,
|
||||||
Paint::green("PASS")
|
Paint::green("PASS")
|
||||||
);
|
);
|
||||||
|
std::fs::remove_file(&result.output_path).expect(&format!(
|
||||||
|
"Couldn't delete successful test log {}",
|
||||||
|
result.output_path
|
||||||
|
));
|
||||||
} else {
|
} else {
|
||||||
failed += 1;
|
failed += 1;
|
||||||
println!(
|
println!(
|
||||||
@ -143,7 +151,7 @@ pub enum Filter {
|
|||||||
Fast,
|
Fast,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromStr for Filter {
|
impl std::str::FromStr for Filter {
|
||||||
type Err = Error;
|
type Err = Error;
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
|
Loading…
Reference in New Issue
Block a user