Apply clippy fixes
This commit is contained in:
parent
bc56a1f8e6
commit
51c7421ebc
4
build.rs
4
build.rs
@ -71,7 +71,7 @@ fn main() {
|
|||||||
let url = format!("https://github.com/google/flatbuffers/releases/download/v{version}/{platform}.flatc.binary{compiler}.zip");
|
let url = format!("https://github.com/google/flatbuffers/releases/download/v{version}/{platform}.flatc.binary{compiler}.zip");
|
||||||
|
|
||||||
if !Path::new(executable_path).exists() {
|
if !Path::new(executable_path).exists() {
|
||||||
build_println!("downloading flatc executable from {url}");
|
build_println!("Downloading flatc executable from {url}");
|
||||||
let response = match reqwest::blocking::get(url) {
|
let response = match reqwest::blocking::get(url) {
|
||||||
Ok(response) => response,
|
Ok(response) => response,
|
||||||
Err(e) => panic!("network error during build: {e}"),
|
Err(e) => panic!("network error during build: {e}"),
|
||||||
@ -97,7 +97,7 @@ fn main() {
|
|||||||
assert!(flatc.check().is_ok());
|
assert!(flatc.check().is_ok());
|
||||||
let version = &flatc.version().unwrap();
|
let version = &flatc.version().unwrap();
|
||||||
build_println!(
|
build_println!(
|
||||||
"using {location} flatc v{} to compile schema files ({executable_path})",
|
"Using {location} flatc v{} to compile schema files ({executable_path})",
|
||||||
version.version()
|
version.version()
|
||||||
);
|
);
|
||||||
flatc
|
flatc
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
|
|
||||||
use std::default;
|
|
||||||
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@ use clap::Parser;
|
|||||||
use common::{
|
use common::{
|
||||||
cli_arguments::Args,
|
cli_arguments::Args,
|
||||||
comparison::Offset,
|
comparison::Offset,
|
||||||
dot_writer::DotWriter,
|
|
||||||
f64_utils::{approx_equal, approximate_within_range},
|
f64_utils::{approx_equal, approximate_within_range},
|
||||||
hash_util::md5_of_osrm_executables,
|
hash_util::md5_of_osrm_executables,
|
||||||
location::Location,
|
location::Location,
|
||||||
@ -18,14 +17,14 @@ use cucumber::{
|
|||||||
codegen::ParametersProvider,
|
codegen::ParametersProvider,
|
||||||
gherkin::{Step, Table},
|
gherkin::{Step, Table},
|
||||||
given, then, when,
|
given, then, when,
|
||||||
writer::summarize,
|
World,
|
||||||
World, WriterExt,
|
|
||||||
};
|
};
|
||||||
use futures::{future, FutureExt};
|
use futures::{future, FutureExt};
|
||||||
use geo_types::Point;
|
use geo_types::Point;
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use std::{
|
use std::{
|
||||||
collections::{HashMap, HashSet}, fmt::format, iter::zip, process::ExitCode, result
|
collections::{HashMap, HashSet},
|
||||||
|
iter::zip,
|
||||||
};
|
};
|
||||||
|
|
||||||
fn offset_origin_by(dx: f64, dy: f64, origin: Location, grid_size: f64) -> Location {
|
fn offset_origin_by(dx: f64, dy: f64, origin: Location, grid_size: f64) -> Location {
|
||||||
@ -53,7 +52,7 @@ fn set_profile(world: &mut OSRMWorld, profile: String) {
|
|||||||
#[given(expr = "the query options")]
|
#[given(expr = "the query options")]
|
||||||
fn set_query_options(world: &mut OSRMWorld, step: &Step) {
|
fn set_query_options(world: &mut OSRMWorld, step: &Step) {
|
||||||
let table = parse_option_table(&step.table.as_ref());
|
let table = parse_option_table(&step.table.as_ref());
|
||||||
world.query_options.extend(table.into_iter());
|
world.query_options.extend(table);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[given(expr = "the node locations")]
|
#[given(expr = "the node locations")]
|
||||||
@ -404,8 +403,8 @@ fn routability(world: &mut OSRMWorld, step: &Step) {
|
|||||||
.iter()
|
.iter()
|
||||||
.filter(|(title, _)| tested_headers.contains(title.as_str()))
|
.filter(|(title, _)| tested_headers.contains(title.as_str()))
|
||||||
.for_each(|(title, expectation)| {
|
.for_each(|(title, expectation)| {
|
||||||
let route_results = vec![world.route(&vec![source, target])
|
let route_results = vec![world.route(&[source, target])
|
||||||
,world.route(&vec![target, source])];
|
,world.route(&[target, source])];
|
||||||
let forward = title.starts_with("forw");
|
let forward = title.starts_with("forw");
|
||||||
let route_result = match forward {
|
let route_result = match forward {
|
||||||
true => &route_results[0],
|
true => &route_results[0],
|
||||||
@ -582,7 +581,7 @@ fn extract_number_and_offset(unit: &str, expectation: &str) -> (f64, Offset) {
|
|||||||
let expectation = expectation.replace(unit, "");
|
let expectation = expectation.replace(unit, "");
|
||||||
let delimiter = if expectation.contains("+-") {
|
let delimiter = if expectation.contains("+-") {
|
||||||
"+-"
|
"+-"
|
||||||
} else if expectation.contains("~") {
|
} else if expectation.contains('~') {
|
||||||
"~"
|
"~"
|
||||||
} else {
|
} else {
|
||||||
"unknown"
|
"unknown"
|
||||||
@ -595,26 +594,26 @@ fn extract_number_and_offset(unit: &str, expectation: &str) -> (f64, Offset) {
|
|||||||
// println!("{tokens:?}");
|
// println!("{tokens:?}");
|
||||||
let number = tokens[0]
|
let number = tokens[0]
|
||||||
.parse::<f64>()
|
.parse::<f64>()
|
||||||
.expect(&format!("'{}' needs to denote a parseablespeed", tokens[0]));
|
.unwrap_or_else(|_| panic!("'{}' needs to denote a parseablespeed", tokens[0]));
|
||||||
let offset = match tokens.len() {
|
let offset = match tokens.len() {
|
||||||
1 => 5., // TODO: the JS fuzzy matcher has a default margin of 5% for absolute comparsions. This is imprecise
|
1 => 5., // TODO: the JS fuzzy matcher has a default margin of 5% for absolute comparsions. This is imprecise
|
||||||
2 => tokens[1]
|
2 => tokens[1]
|
||||||
.replace("~", "")
|
.replace('~', "")
|
||||||
.replace("+-", "")
|
.replace("+-", "")
|
||||||
.replace("%", "")
|
.replace('%', "")
|
||||||
.trim()
|
.trim()
|
||||||
.parse()
|
.parse()
|
||||||
.expect(&format!("{} needs to specify a number", tokens[1])),
|
.unwrap_or_else(|_| panic!("{} needs to specify a number", tokens[1])),
|
||||||
_ => unreachable!("expectations can't be parsed"),
|
_ => unreachable!("expectations can't be parsed"),
|
||||||
};
|
};
|
||||||
if expectation.ends_with("%") {
|
if expectation.ends_with('%') {
|
||||||
return (number, Offset::Percentage(offset));
|
return (number, Offset::Percentage(offset));
|
||||||
}
|
}
|
||||||
(number, Offset::Absolute(offset))
|
(number, Offset::Absolute(offset))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn extract_number_vector_and_offset(unit: &str, expectation: &str) -> (Vec<f64>, Offset) {
|
fn extract_number_vector_and_offset(unit: &str, expectation: &str) -> (Vec<f64>, Offset) {
|
||||||
let expectation = expectation.replace(",", "");
|
let expectation = expectation.replace(',', "");
|
||||||
let tokens: Vec<_> = expectation
|
let tokens: Vec<_> = expectation
|
||||||
.split(unit)
|
.split(unit)
|
||||||
.map(|token| token.trim())
|
.map(|token| token.trim())
|
||||||
@ -639,10 +638,10 @@ fn extract_number_vector_and_offset(unit: &str, expectation: &str) -> (Vec<f64>,
|
|||||||
.replace("+-", "")
|
.replace("+-", "")
|
||||||
.trim()
|
.trim()
|
||||||
.parse()
|
.parse()
|
||||||
.expect(&format!("{} needs to specify a number", tokens[1])),
|
.unwrap_or_else(|_| panic!("{} needs to specify a number", tokens[1])),
|
||||||
// _ => unreachable!("expectations can't be parsed"),
|
// _ => unreachable!("expectations can't be parsed"),
|
||||||
};
|
};
|
||||||
if expectation.ends_with("%") {
|
if expectation.ends_with('%') {
|
||||||
return (numbers, Offset::Percentage(offset.into()));
|
return (numbers, Offset::Percentage(offset.into()));
|
||||||
}
|
}
|
||||||
(numbers, Offset::Absolute(offset.into()))
|
(numbers, Offset::Absolute(offset.into()))
|
||||||
@ -705,13 +704,12 @@ fn request_route(world: &mut OSRMWorld, step: &Step, state: String) {
|
|||||||
|
|
||||||
let (_, test_cases) = parse_table_from_steps(&step.table.as_ref());
|
let (_, test_cases) = parse_table_from_steps(&step.table.as_ref());
|
||||||
for test_case in &test_cases {
|
for test_case in &test_cases {
|
||||||
let waypoints = match get_location_specification(&test_case) {
|
let waypoints = match get_location_specification(test_case) {
|
||||||
WaypointsOrLocation::Waypoints => {
|
WaypointsOrLocation::Waypoints => {
|
||||||
let locations: Vec<Location> = test_case
|
let locations: Vec<Location> = test_case
|
||||||
.get("waypoints")
|
.get("waypoints")
|
||||||
.expect("locations specified as waypoints")
|
.expect("locations specified as waypoints")
|
||||||
.split(",")
|
.split(',')
|
||||||
.into_iter()
|
|
||||||
.map(|name| {
|
.map(|name| {
|
||||||
assert!(name.len() == 1, "node names need to be of length one");
|
assert!(name.len() == 1, "node names need to be of length one");
|
||||||
world.get_location(name.chars().next().unwrap())
|
world.get_location(name.chars().next().unwrap())
|
||||||
@ -749,7 +747,7 @@ fn request_route(world: &mut OSRMWorld, step: &Step, state: String) {
|
|||||||
// TODO: change test cases to provide proper query options
|
// TODO: change test cases to provide proper query options
|
||||||
world
|
world
|
||||||
.query_options
|
.query_options
|
||||||
.insert("bearings".into(), bearings.replace(" ", ";"));
|
.insert("bearings".into(), bearings.replace(' ', ";"));
|
||||||
}
|
}
|
||||||
|
|
||||||
let route_result = world.route(&waypoints);
|
let route_result = world.route(&waypoints);
|
||||||
@ -927,9 +925,9 @@ fn request_route(world: &mut OSRMWorld, step: &Step, state: String) {
|
|||||||
"times" => {
|
"times" => {
|
||||||
// TODO: go over steps
|
// TODO: go over steps
|
||||||
let (_, response) = route_result.as_ref().expect("osrm-routed returned an unexpected error");
|
let (_, response) = route_result.as_ref().expect("osrm-routed returned an unexpected error");
|
||||||
let actual_times : Vec<f64>= response.routes.first().expect("no route returned").legs.iter().map(|leg| {
|
let actual_times : Vec<f64>= response.routes.first().expect("no route returned").legs.iter().flat_map(|leg| {
|
||||||
leg.steps.iter().filter(|step| step.duration > 0.).map(|step| step.duration).collect::<Vec<f64>>()
|
leg.steps.iter().filter(|step| step.duration > 0.).map(|step| step.duration).collect::<Vec<f64>>()
|
||||||
}).flatten().collect();
|
}).collect();
|
||||||
let (expected_times, offset) = extract_number_vector_and_offset("s", expectation);
|
let (expected_times, offset) = extract_number_vector_and_offset("s", expectation);
|
||||||
assert_eq!(actual_times.len(), expected_times.len(), "times mismatch: {actual_times:?} != {expected_times:?} +- {offset:?}");
|
assert_eq!(actual_times.len(), expected_times.len(), "times mismatch: {actual_times:?} != {expected_times:?} +- {offset:?}");
|
||||||
|
|
||||||
@ -940,10 +938,10 @@ fn request_route(world: &mut OSRMWorld, step: &Step, state: String) {
|
|||||||
},
|
},
|
||||||
"distances" => {
|
"distances" => {
|
||||||
let (_, response) = route_result.as_ref().expect("osrm-routed returned an unexpected error");
|
let (_, response) = route_result.as_ref().expect("osrm-routed returned an unexpected error");
|
||||||
let actual_distances = response.routes.first().expect("no route returned").legs.iter().map(|leg| {
|
let actual_distances = response.routes.first().expect("no route returned").legs.iter().flat_map(|leg| {
|
||||||
leg.steps.iter().filter(|step| step.distance > 0.).map(|step| step.distance).collect::<Vec<f64>>()
|
leg.steps.iter().filter(|step| step.distance > 0.).map(|step| step.distance).collect::<Vec<f64>>()
|
||||||
}).flatten().collect::<Vec<f64>>();
|
}).collect::<Vec<f64>>();
|
||||||
let (expected_distances, offset) = extract_number_vector_and_offset("m", expectation);
|
let (expected_distances, offset) = extract_number_vector_and_offset("m", expectation);
|
||||||
assert_eq!(expected_distances.len(), actual_distances.len(), "distances mismatch {expected_distances:?} != {actual_distances:?} +- {offset:?}");
|
assert_eq!(expected_distances.len(), actual_distances.len(), "distances mismatch {expected_distances:?} != {actual_distances:?} +- {offset:?}");
|
||||||
|
|
||||||
zip(actual_distances, expected_distances).for_each(|(actual_distance, expected_distance)| {
|
zip(actual_distances, expected_distances).for_each(|(actual_distance, expected_distance)| {
|
||||||
@ -1146,16 +1144,19 @@ fn main() {
|
|||||||
.before(move |feature, _rule, scenario, world| {
|
.before(move |feature, _rule, scenario, world| {
|
||||||
world.scenario_id = common::scenario_id::scenario_id(scenario);
|
world.scenario_id = common::scenario_id::scenario_id(scenario);
|
||||||
world.set_scenario_specific_paths_and_digests(feature.path.clone());
|
world.set_scenario_specific_paths_and_digests(feature.path.clone());
|
||||||
world.osrm_digest = digest.clone();
|
world.osrm_digest.clone_from(&digest);
|
||||||
|
|
||||||
// TODO: clean up cache if needed? Or do in scenarios?
|
// TODO: clean up cache if needed? Or do in scenarios?
|
||||||
|
|
||||||
future::ready(()).boxed()
|
future::ready(()).boxed()
|
||||||
})
|
})
|
||||||
// .with_writer(DotWriter::default().normalized())
|
// .with_writer(DotWriter::default().normalized())
|
||||||
// .filter_run("features/", |fe, _, sc| {
|
.filter_run("features/", |fe, r, sc| {
|
||||||
.filter_run("features/guidance/anticipate-lanes.feature", |fe, _, sc| {
|
// .filter_run("features/bicycle/classes.feature", |fe, r, sc| {
|
||||||
!sc.tags.iter().any(|t| t == "todo") && !fe.tags.iter().any(|t| t == "todo")
|
let tag = "todo".to_string();
|
||||||
|
!sc.tags.contains(&tag)
|
||||||
|
&& !fe.tags.contains(&tag)
|
||||||
|
&& !r.is_some_and(|rule| rule.tags.contains(&tag))
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user