diff --git a/abstutil/src/time.rs b/abstutil/src/time.rs index 407355a0eb..00ecbff8f1 100644 --- a/abstutil/src/time.rs +++ b/abstutil/src/time.rs @@ -409,12 +409,16 @@ fn process_used_memory_mb() -> usize { #[cfg(unix)] pub(crate) fn clear_current_line() { - let (terminal_width, _) = termion::terminal_size().unwrap(); - print!( - "{}{}", - termion::clear::CurrentLine, - termion::cursor::Left(terminal_width) - ); + // Fails in the test runner. + if let Ok((terminal_width, _)) = termion::terminal_size() { + print!( + "{}{}", + termion::clear::CurrentLine, + termion::cursor::Left(terminal_width) + ); + } else { + print!("\r"); + } } #[cfg(windows)] diff --git a/sim/src/events.rs b/sim/src/events.rs index 2ed4adbe38..4d8b1f8651 100644 --- a/sim/src/events.rs +++ b/sim/src/events.rs @@ -2,8 +2,7 @@ use crate::{AgentID, CarID, ParkingSpot, PedestrianID}; use map_model::{BuildingID, BusStopID, IntersectionID, LaneID, Traversable}; use serde_derive::{Deserialize, Serialize}; -// TODO rm Clone -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Event { CarReachedParkingSpot(CarID, ParkingSpot), CarOrBikeReachedBorder(CarID, IntersectionID), diff --git a/sim/src/sim.rs b/sim/src/sim.rs index 95bb9ca5c5..d8e71556fe 100644 --- a/sim/src/sim.rs +++ b/sim/src/sim.rs @@ -268,7 +268,7 @@ impl Sim { // Running impl Sim { - pub fn step(&mut self, map: &Map) -> Vec { + pub fn step(&mut self, map: &Map) { if !self.spawner.is_done() { panic!("Forgot to call spawn_all_trips"); } @@ -351,12 +351,11 @@ impl Sim { } } - let mut events = self.trips.collect_events(); - events.extend(self.transit.collect_events()); self.events_since_last_step.clear(); - self.events_since_last_step.extend(events.clone()); - // TODO Stop returning these here - events + self.events_since_last_step + .extend(self.trips.collect_events()); + self.events_since_last_step + .extend(self.transit.collect_events()); } pub fn dump_before_abort(&self) { @@ -419,8 +418,9 @@ impl Sim { if expectations.is_empty() { return; } - for ev in self.step(&map).into_iter() { - if ev == *expectations.front().unwrap() { + self.step(&map); + for ev in self.get_events_since_last_step() { + if ev == expectations.front().unwrap() { println!("At {}, met expectation {:?}", self.time, ev); expectations.pop_front(); if expectations.is_empty() {