mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-25 23:43:25 +03:00
grouping tests with suite name
This commit is contained in:
parent
5de255b55b
commit
ff0e921c15
@ -13,8 +13,8 @@ mod runner;
|
|||||||
fn main() {
|
fn main() {
|
||||||
let mut t = runner::TestRunner::new();
|
let mut t = runner::TestRunner::new();
|
||||||
|
|
||||||
map_conversion::run(&mut t);
|
map_conversion::run(t.suite("map_conversion"));
|
||||||
physics::run(&mut t);
|
physics::run(t.suite("physics"));
|
||||||
|
|
||||||
t.done();
|
t.done();
|
||||||
}
|
}
|
||||||
|
@ -3,26 +3,29 @@ use convert_osm;
|
|||||||
use runner::TestRunner;
|
use runner::TestRunner;
|
||||||
|
|
||||||
pub fn run(t: &mut TestRunner) {
|
pub fn run(t: &mut TestRunner) {
|
||||||
t.run("convert_twice", Box::new(|_| {
|
t.run(
|
||||||
let flags = convert_osm::Flags {
|
"convert_twice",
|
||||||
osm: "../data/input/montlake.osm".to_string(),
|
Box::new(|_| {
|
||||||
elevation: "../data/input/N47W122.hgt".to_string(),
|
let flags = convert_osm::Flags {
|
||||||
traffic_signals: "../data/input/TrafficSignals.shp".to_string(),
|
osm: "../data/input/montlake.osm".to_string(),
|
||||||
parcels: "../data/seattle_parcels.abst".to_string(),
|
elevation: "../data/input/N47W122.hgt".to_string(),
|
||||||
parking_shapes: "../data/shapes/blockface".to_string(),
|
traffic_signals: "../data/input/TrafficSignals.shp".to_string(),
|
||||||
gtfs: "../data/input/google_transit_2018_18_08".to_string(),
|
parcels: "../data/seattle_parcels.abst".to_string(),
|
||||||
neighborhoods: "../data/input/neighborhoods.geojson".to_string(),
|
parking_shapes: "../data/shapes/blockface".to_string(),
|
||||||
output: "".to_string(),
|
gtfs: "../data/input/google_transit_2018_18_08".to_string(),
|
||||||
};
|
neighborhoods: "../data/input/neighborhoods.geojson".to_string(),
|
||||||
|
output: "".to_string(),
|
||||||
|
};
|
||||||
|
|
||||||
let map1 = convert_osm::convert(&flags, &mut abstutil::Timer::new("convert map"));
|
let map1 = convert_osm::convert(&flags, &mut abstutil::Timer::new("convert map"));
|
||||||
let map2 = convert_osm::convert(&flags, &mut abstutil::Timer::new("convert map"));
|
let map2 = convert_osm::convert(&flags, &mut abstutil::Timer::new("convert map"));
|
||||||
|
|
||||||
if map1 != map2 {
|
if map1 != map2 {
|
||||||
// TODO tmp files
|
// TODO tmp files
|
||||||
abstutil::write_json("map1.json", &map1).unwrap();
|
abstutil::write_json("map1.json", &map1).unwrap();
|
||||||
abstutil::write_json("map2.json", &map2).unwrap();
|
abstutil::write_json("map2.json", &map2).unwrap();
|
||||||
panic!("map1.json and map2.json differ");
|
panic!("map1.json and map2.json differ");
|
||||||
}
|
}
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,11 @@
|
|||||||
use abstutil;
|
use abstutil;
|
||||||
use gag::Redirect;
|
use gag::Redirect;
|
||||||
use std;
|
use std;
|
||||||
use yansi::Paint;
|
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
use yansi::Paint;
|
||||||
|
|
||||||
pub struct TestRunner {
|
pub struct TestRunner {
|
||||||
|
current_suite: Option<String>,
|
||||||
results: Vec<TestResult>,
|
results: Vec<TestResult>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -20,11 +21,25 @@ struct TestResult {
|
|||||||
impl TestRunner {
|
impl TestRunner {
|
||||||
pub fn new() -> TestRunner {
|
pub fn new() -> TestRunner {
|
||||||
TestRunner {
|
TestRunner {
|
||||||
|
current_suite: None,
|
||||||
results: Vec::new(),
|
results: Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run(&mut self, test_name: &str, test: Box<Fn(&mut TestHelper)>) {
|
pub fn suite(&mut self, name: &str) -> &mut TestRunner {
|
||||||
|
self.current_suite = Some(name.to_string());
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn run(&mut self, specific_test_name: &str, test: Box<Fn(&mut TestHelper)>) {
|
||||||
|
let test_name = format!(
|
||||||
|
"{}/{}",
|
||||||
|
self.current_suite
|
||||||
|
.as_ref()
|
||||||
|
.expect("Can't run() a test without suite()"),
|
||||||
|
specific_test_name
|
||||||
|
);
|
||||||
|
|
||||||
print!("Running {}...", test_name);
|
print!("Running {}...", test_name);
|
||||||
std::io::stdout().flush().unwrap();
|
std::io::stdout().flush().unwrap();
|
||||||
|
|
||||||
@ -72,10 +87,20 @@ impl TestRunner {
|
|||||||
for result in self.results.into_iter() {
|
for result in self.results.into_iter() {
|
||||||
if result.pass {
|
if result.pass {
|
||||||
passed += 1;
|
passed += 1;
|
||||||
println!("- {} ({}): {}", result.test_name, result.duration, Paint::green("PASS"));
|
println!(
|
||||||
|
"- {} ({}): {}",
|
||||||
|
result.test_name,
|
||||||
|
result.duration,
|
||||||
|
Paint::green("PASS")
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
failed += 1;
|
failed += 1;
|
||||||
println!("- {} ({}): {}", result.test_name, result.duration, Paint::red("FAIL"));
|
println!(
|
||||||
|
"- {} ({}): {}",
|
||||||
|
result.test_name,
|
||||||
|
result.duration,
|
||||||
|
Paint::red("FAIL")
|
||||||
|
);
|
||||||
println!(" {}", Paint::cyan(result.output_path));
|
println!(" {}", Paint::cyan(result.output_path));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user