diff --git a/Cargo.lock b/Cargo.lock index a4e95df42..bc93fb960 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -654,6 +654,7 @@ version = "0.1.0" dependencies = [ "cheap-ruler", "chksum-md5", + "clap", "cucumber", "futures", "geo-types", diff --git a/Cargo.toml b/Cargo.toml index b97098f4f..35c3b076f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,7 @@ edition = "2021" [dependencies] cheap-ruler = "0.4.0" chksum-md5 = "0.0.0" +clap = "4.5.4" cucumber = "0.21.0" futures = "0.3.30" geo-types = "0.7.13" diff --git a/tests/cucumber.rs b/tests/cucumber.rs index b01c6478f..d62f8c7b2 100644 --- a/tests/cucumber.rs +++ b/tests/cucumber.rs @@ -1,13 +1,18 @@ +extern crate clap; + mod osm; use core::panic; use std::collections::{HashMap, HashSet, VecDeque}; +use std::error::Error; use std::fs::{create_dir_all, DirEntry, File}; use std::io::{self, Read, Write}; use std::path::PathBuf; -use std::{env, fs}; +use std::str::FromStr; +use std::{env, fmt, fs}; use cheap_ruler::CheapRuler; +use clap::{Arg, Parser}; use cucumber::{self, gherkin::Step, given, when, World}; use futures::{future, FutureExt}; use geo_types::{point, Point}; @@ -280,7 +285,56 @@ impl Iterator for LexicographicFileWalker { } } +#[derive( clap::ValueEnum, Clone, Default, Debug)] +enum LoadMethod { + Mmap, + #[default] + Datastore, + Directly, +} +impl ToString for LoadMethod { + fn to_string(&self) -> String { + match self { + LoadMethod::Mmap => "mmap".into(), + LoadMethod::Datastore => "datastore".into(), + LoadMethod::Directly => "directly".into(), + } + } +} + +#[derive(clap::ValueEnum, Clone, Default, Debug)] +enum RoutingAlgorithm { + #[default] + CH, + MLD, +} + +impl ToString for RoutingAlgorithm { + fn to_string(&self) -> String { + match self { + RoutingAlgorithm::CH => "ch".into(), + RoutingAlgorithm::MLD => "mld".into(), + } + } +} +// TODO: move to external file +#[derive(Parser, Debug)] +#[command(version, about, long_about = None)] +struct Args { + // underlying memory storage + #[arg(short, default_value_t = LoadMethod::Datastore)] + memory: LoadMethod, + + // Number of times to greet + #[arg(short, default_value_t = RoutingAlgorithm::CH)] + p: RoutingAlgorithm, +} + + fn main() { + let args = Args::parse(); + println!("name: {:?}", args); + // create OSRM digest before any tests are executed since cucumber-rs doesn't have @beforeAll let exe_path = env::current_exe().expect("failed to get current exe path"); let path = exe_path