osrm-backend/tests/common/dot_writer.rs

43 lines
1.5 KiB
Rust
Raw Normal View History

2024-06-05 08:58:41 -04:00
use std::io::{self, Write};
use cucumber::{cli, event, parser, Event};
2024-06-05 08:59:19 -04:00
// TODO: add colors
// TODO: print summary at the end
2024-06-05 08:59:19 -04:00
pub struct DotWriter;
2024-06-05 08:58:41 -04:00
2024-06-05 08:59:19 -04:00
impl<W: 'static> cucumber::Writer<W> for DotWriter {
2024-06-05 08:58:41 -04:00
type Cli = cli::Empty; // we provide no CLI options
async fn handle_event(&mut self, ev: parser::Result<Event<event::Cucumber<W>>>, _: &Self::Cli) {
match ev {
Ok(Event { value, .. }) => match value {
event::Cucumber::Feature(_feature, ev) => match ev {
event::Feature::Started => {
print!(".")
}
event::Feature::Scenario(_scenario, ev) => match ev.event {
event::Scenario::Started => {
print!(".")
}
event::Scenario::Step(_step, ev) => match ev {
event::Step::Started => {
print!(".")
}
event::Step::Passed(..) => print!("."),
event::Step::Skipped => print!("-"),
event::Step::Failed(_, _, _, _err) => {
print!("x")
}
},
_ => {}
},
_ => {}
},
_ => {}
},
Err(e) => println!("Error: {e}"),
}
let _ = io::stdout().flush();
}
}