moving convert_osm test to new runner

This commit is contained in:
Dustin Carlino 2018-11-23 15:02:41 -08:00
parent 9f0b2ea756
commit e8dc01fd98
5 changed files with 37 additions and 26 deletions

View File

@ -1,26 +0,0 @@
extern crate abstutil;
extern crate convert_osm;
#[test]
fn convert_twice() {
let flags = convert_osm::Flags {
osm: "../data/input/montlake.osm".to_string(),
elevation: "../data/input/N47W122.hgt".to_string(),
traffic_signals: "../data/input/TrafficSignals.shp".to_string(),
parcels: "../data/seattle_parcels.abst".to_string(),
parking_shapes: "../data/shapes/blockface".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 map2 = convert_osm::convert(&flags, &mut abstutil::Timer::new("convert map"));
if map1 != map2 {
// TODO tmp files
abstutil::write_json("map1.json", &map1).unwrap();
abstutil::write_json("map2.json", &map2).unwrap();
panic!("map1.json and map2.json differ");
}
}

View File

@ -4,6 +4,8 @@ version = "0.1.0"
authors = ["Dustin Carlino <dabreegster@gmail.com>"]
[dependencies]
abstutil = { path = "../abstutil" }
convert_osm = { path = "../convert_osm" }
dimensioned = { git = "https://github.com/paholg/dimensioned", rev = "0e1076ebfa5128d1ee544bdc9754c948987b6fe3", features = ["serde"] }
gag = "0.1.10"
geom = { path = "../geom" }

View File

@ -1,15 +1,19 @@
extern crate abstutil;
extern crate convert_osm;
extern crate dimensioned;
extern crate gag;
extern crate geom;
extern crate sim;
extern crate yansi;
mod map_conversion;
mod physics;
mod runner;
fn main() {
let mut t = runner::TestRunner::new();
map_conversion::run(&mut t);
physics::run(&mut t);
t.done();

View File

@ -0,0 +1,28 @@
use abstutil;
use convert_osm;
use runner::TestRunner;
pub fn run(t: &mut TestRunner) {
t.run("convert twice", Box::new(|_| {
let flags = convert_osm::Flags {
osm: "../data/input/montlake.osm".to_string(),
elevation: "../data/input/N47W122.hgt".to_string(),
traffic_signals: "../data/input/TrafficSignals.shp".to_string(),
parcels: "../data/seattle_parcels.abst".to_string(),
parking_shapes: "../data/shapes/blockface".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 map2 = convert_osm::convert(&flags, &mut abstutil::Timer::new("convert map"));
if map1 != map2 {
// TODO tmp files
abstutil::write_json("map1.json", &map1).unwrap();
abstutil::write_json("map2.json", &map2).unwrap();
panic!("map1.json and map2.json differ");
}
}));
}

View File

@ -22,6 +22,8 @@ impl TestRunner {
}
pub fn run(&mut self, test_name: &str, test: Box<Fn(&mut TestHelper)>) {
println!("Running {}...", test_name);
// TODO Make a temporary directory inside /tmp, remove successful files
let output_path = format!("/tmp/{}.log", test_name);
std::fs::create_dir_all(std::path::Path::new(&output_path).parent().unwrap())
@ -54,6 +56,7 @@ impl TestRunner {
}
pub fn done(self) {
println!("");
let mut passed = 0;
let mut failed = 0;
for result in self.results.into_iter() {