fixing up tests

This commit is contained in:
Dustin Carlino 2018-09-07 13:22:37 -07:00
parent 58b01fce9e
commit 99fe9f170c
7 changed files with 46 additions and 31 deletions

View File

@ -8,6 +8,7 @@ fn convert_twice() {
elevation: "../data/input/N47W122.hgt".to_string(),
traffic_signals: "../data/input/TrafficSignals.shp".to_string(),
parcels: "../data/seattle_parcels.abst".to_string(),
gtfs: "../data/input/google_transit_2018_18_08".to_string(),
output: "".to_string(),
};

View File

@ -18,3 +18,9 @@
- with interactive mode?
- try destructive approach for snake idea
- with interactive mode?
## Generally useful rust stuff
- better test runner
- summary of pass/fail at the end, with timings
- log output from failures to tmp files

View File

@ -861,3 +861,7 @@ ah no, it's because we use max_lookahead_dist in accel_to_follow, and the speed
- gfx (pre-II or not?) + winit
- https://suhr.github.io/gsgt/
- glium (unmaintained)
https://www.reddit.com/r/rust_gamedev/comments/7f7w60/auditioning_a_replacement_for_bearlibterminal/
https://github.com/ggez/ggez/blob/master/examples/drawing.rs

View File

@ -367,4 +367,8 @@ impl Map {
pub fn get_all_bus_routes(&self) -> &Vec<BusRoute> {
&self.bus_routes
}
pub fn get_bus_route(&self, name: &str) -> Option<&BusRoute> {
self.bus_routes.iter().find(|r| r.name == name)
}
}

View File

@ -12,7 +12,14 @@ pub fn capture_backtrace(event: &str) {
let mut found_this_fxn = false;
let mut calls: Vec<String> = vec![event.to_string()];
for f in bt.frames() {
let raw_name = format!("{}", f.symbols()[0].name().unwrap());
// TODO compiler flag so capture_backtrace is usually a no-op. actually, looks like this
// doesn't work in --release mode, so use that.
let symbol_name = f.symbols()[0].name();
if !symbol_name.is_some() {
return;
}
let raw_name = format!("{}", symbol_name.unwrap());
let mut raw_name_parts: Vec<&str> = raw_name.split("::").collect();
raw_name_parts.pop();
let name = raw_name_parts.join("::");
@ -37,6 +44,4 @@ pub fn save_backtraces(path: &str) {
}
// TODO call from all interesting methods in a few different types; maybe use macros to help
// TODO compiler flag so capture_backtrace is usually a no-op. actually, looks like this doesn't
// work in --release mode, so use that.
// TODO script to organize and visualize results

View File

@ -112,6 +112,7 @@ fn make_test_map() -> map_model::Map {
},
],
parcels: Vec::new(),
bus_routes: Vec::new(),
coordinates_in_world_space: true,
},
&map_model::Edits::new(),

View File

@ -12,24 +12,19 @@ fn bus_reaches_stops() {
Some(sim::Tick::from_seconds(30)),
);
let stop1 = map.get_l(map_model::LaneID(309)).bus_stops[0].id;
let stop2 = map.get_l(map_model::LaneID(325)).bus_stops[0].id;
let stop3 = map.get_l(map_model::LaneID(840)).bus_stops[0].id;
let buses = sim.seed_bus_route(vec![stop1, stop2, stop3], &map);
let (bus1, _, _) = (buses[0], buses[1], buses[2]);
let route = map.get_bus_route("48").unwrap();
let bus = sim.seed_bus_route(route, &map)[0];
let mut expectations: Vec<sim::Event> = Vec::new();
// TODO assert stuff about other buses as well, although the timing is a little unclear
for stop in route.stops.iter().skip(1) {
expectations.push(sim::Event::BusArrivedAtStop(bus, *stop));
expectations.push(sim::Event::BusDepartedFromStop(bus, *stop));
}
sim.run_until_expectations_met(
&map,
&control_map,
// TODO assert stuff about other buses as well, although the timing is a little unclear
vec![
sim::Event::BusArrivedAtStop(bus1, stop2),
sim::Event::BusDepartedFromStop(bus1, stop2),
sim::Event::BusArrivedAtStop(bus1, stop3),
sim::Event::BusDepartedFromStop(bus1, stop3),
sim::Event::BusArrivedAtStop(bus1, stop1),
sim::Event::BusDepartedFromStop(bus1, stop1),
],
expectations,
sim::Tick::from_minutes(10),
);
sim.run_until_done(&map, &control_map, Box::new(|_sim| {}));
@ -45,31 +40,30 @@ fn ped_uses_bus() {
Some(sim::Tick::from_seconds(30)),
);
let stop1 = map.get_l(map_model::LaneID(309)).bus_stops[0].id;
let stop2 = map.get_l(map_model::LaneID(325)).bus_stops[0].id;
let stop3 = map.get_l(map_model::LaneID(840)).bus_stops[0].id;
let buses = sim.seed_bus_route(vec![stop1, stop2, stop3], &map);
let (bus, _, _) = (buses[0], buses[1], buses[2]);
let route = map.get_bus_route("48").unwrap();
let bus = sim.seed_bus_route(route, &map)[0];
let ped_stop1 = route.stops[1];
let ped_stop2 = route.stops[2];
let ped = sim.make_ped_using_bus(
&map,
map_model::LaneID(550),
map_model::LaneID(727),
map_model::LaneID(283),
map_model::LaneID(553),
sim::RouteID(0),
map.get_l(map_model::LaneID(325)).bus_stops[0].id,
map.get_l(map_model::LaneID(840)).bus_stops[0].id,
ped_stop1,
ped_stop2,
);
sim.run_until_expectations_met(
&map,
&control_map,
vec![
sim::Event::BusArrivedAtStop(bus, stop2),
sim::Event::BusArrivedAtStop(bus, ped_stop1),
sim::Event::PedEntersBus(ped, bus),
sim::Event::BusDepartedFromStop(bus, stop2),
sim::Event::BusArrivedAtStop(bus, stop3),
sim::Event::BusDepartedFromStop(bus, ped_stop1),
sim::Event::BusArrivedAtStop(bus, ped_stop2),
sim::Event::PedLeavesBus(ped, bus),
sim::Event::BusDepartedFromStop(bus, stop3),
sim::Event::BusArrivedAtStop(bus, stop1),
sim::Event::BusDepartedFromStop(bus, ped_stop2),
sim::Event::BusArrivedAtStop(bus, route.stops[3]),
// TODO PedReachedBuilding, once the seeding specifies a building instead of picking
],
sim::Tick::from_minutes(10),