use std::process::Command;
fn run_example(name: &str) {
let output = Command::new(env!("CARGO"))
.args(["run", "--example", name])
.output()
.unwrap_or_else(|e| panic!("Failed to launch `cargo run --example {name}`: {e}"));
let stdout = String::from_utf8_lossy(&output.stdout);
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(
output.status.success(),
"Example `{name}` failed (exit code: {:?}).\n--- stdout ---\n{stdout}\n--- stderr ---\n{stderr}",
output.status.code()
);
}
#[test]
fn example_01_road_geometry() {
run_example("01_road_geometry");
}
#[test]
fn example_02_backend_custom_command() {
run_example("02_backend_custom_command");
}
#[test]
fn example_03_maliput_malidrive_resources() {
run_example("03_maliput_malidrive_resources");
}
#[test]
fn example_04_math() {
run_example("04_math");
}
#[test]
fn example_05_multi_road_geometry() {
run_example("05_multi_road_geometry");
}
#[test]
fn example_06_road_rulebook() {
run_example("06_road_rulebook");
}
#[test]
fn example_07_error_handling() {
run_example("07_error_handling");
}
#[test]
fn example_08_direction_usage_rule() {
run_example("08_direction_usage_rule");
}
#[test]
fn example_09_phase_ring() {
run_example("09_phase_ring");
}
#[test]
fn example_10_lane_boundary() {
run_example("10_lane_boundary");
}
#[test]
fn example_11_lane_boundary_complex_marking() {
run_example("11_lane_boundary_complex_marking");
}
#[cfg(feature = "maliput_geopackage")]
#[test]
fn example_12_geopackage_road_geometry() {
run_example("12_geopackage_road_geometry");
}