diff --git a/.github/workflows/general.yml b/.github/workflows/general.yml index bfb681f..4eb9f97 100644 --- a/.github/workflows/general.yml +++ b/.github/workflows/general.yml @@ -64,6 +64,7 @@ jobs: override: true - name: Run cargo-tarpaulin - uses: actions-rs/tarpaulin@v0.1 + uses: actions-rs/tarpaulin@v0.1.3 with: + version: '0.15.0' args: '--ignore-tests' diff --git a/example/subtags.yml b/example/subtags.yml new file mode 100644 index 0000000..64685aa --- /dev/null +++ b/example/subtags.yml @@ -0,0 +1,9 @@ +# Example of a included file + +--- +- name: Fetch comments + request: + url: /api/comments.json + tags: + - tag_user + diff --git a/example/tags.yml b/example/tags.yml new file mode 100644 index 0000000..ca5b714 --- /dev/null +++ b/example/tags.yml @@ -0,0 +1,14 @@ +--- +base: 'http://localhost:9000' +iterations: 1 +concurrency: 1 + +plan: + - name: Include comments + include: subtags.yml + + - name: Tagged user request + request: + url: /api/users/70 + tags: + - tag_user diff --git a/src/actions/request.rs b/src/actions/request.rs index 108f19b..e81f427 100644 --- a/src/actions/request.rs +++ b/src/actions/request.rs @@ -122,7 +122,7 @@ impl Request { match context.get("base") { Some(value) => { if let Some(vs) = value.as_str() { - format!("{}{}", vs, interpolated_url) + format!("{vs}{interpolated_url}") } else { panic!("{} Wrong type 'base' variable!", "WARNING!".yellow().bold()); } @@ -173,7 +173,7 @@ impl Request { if let Some(cookies) = context.get("cookies") { let cookies: Map = serde_json::from_value(cookies.clone()).unwrap(); - let cookie = cookies.iter().map(|(key, value)| format!("{}={}", key, value)).collect::>().join(";"); + let cookie = cookies.iter().map(|(key, value)| format!("{key}={value}")).collect::>().join(";"); headers.insert(header::COOKIE, HeaderValue::from_str(&cookie).unwrap()); } @@ -334,7 +334,7 @@ fn log_request(request: &reqwest::Request) { write!(message, " {} {},", "URL:".bold(), request.url()).unwrap(); write!(message, " {} {},", "METHOD:".bold(), request.method()).unwrap(); write!(message, " {} {:?}", "HEADERS:".bold(), request.headers()).unwrap(); - println!("{}", message); + println!("{message}"); } fn log_message_response(response: &Option, duration_ms: f64) -> String { @@ -359,5 +359,5 @@ fn log_response(log_message_response: String, body: &Option) { if let Some(body) = body.as_ref() { write!(message, " {} {:?}", "BODY:".bold(), body).unwrap() } - println!("{}", message); + println!("{message}"); } diff --git a/src/config.rs b/src/config.rs index edfd2f2..baebd61 100644 --- a/src/config.rs +++ b/src/config.rs @@ -65,7 +65,7 @@ fn read_str_configuration(config_doc: &Yaml, interpolator: &interpolator::Interp } None => { if config_doc[name].as_str().is_some() { - println!("Invalid {} value!", name); + println!("Invalid {name} value!"); } default.to_owned() @@ -85,7 +85,7 @@ fn read_i64_configuration(config_doc: &Yaml, interpolator: &interpolator::Interp match value { Some(value) => { if value < 0 { - println!("Invalid negative {} value!", name); + println!("Invalid negative {name} value!"); default } else { @@ -94,7 +94,7 @@ fn read_i64_configuration(config_doc: &Yaml, interpolator: &interpolator::Interp } None => { if config_doc[name].as_str().is_some() { - println!("Invalid {} value!", name); + println!("Invalid {name} value!"); } default diff --git a/src/expandable/include.rs b/src/expandable/include.rs index 78fbee1..e288283 100644 --- a/src/expandable/include.rs +++ b/src/expandable/include.rs @@ -32,6 +32,12 @@ pub fn expand_from_filepath(parent_path: &str, benchmark: &mut Benchmark, access let items = reader::read_yaml_doc_accessor(&docs[0], accessor); for item in items { + if include::is_that_you(item) { + include::expand(parent_path, item, benchmark, tags); + + continue; + } + if tags.should_skip_item(item) { continue; } @@ -44,8 +50,6 @@ pub fn expand_from_filepath(parent_path: &str, benchmark: &mut Benchmark, access multi_csv_request::expand(parent_path, item, benchmark); } else if multi_file_request::is_that_you(item) { multi_file_request::expand(parent_path, item, benchmark); - } else if include::is_that_you(item) { - include::expand(parent_path, item, benchmark, tags); } else if actions::Delay::is_that_you(item) { benchmark.push(Box::new(actions::Delay::new(item, None))); } else if actions::Exec::is_that_you(item) { diff --git a/src/main.rs b/src/main.rs index b43101d..a02f88b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -168,11 +168,11 @@ fn show_stats(list_reports: &[Vec], stats_option: bool, nanosec: bool, d let requests_per_second = global_stats.total_requests as f64 / duration; println!(); - println!("{:width2$} {} {}", "Time taken for tests".yellow(), format!("{:.1}", duration).purple(), "seconds".purple(), width2 = 25); + println!("{:width2$} {} {}", "Time taken for tests".yellow(), format!("{duration:.1}").purple(), "seconds".purple(), width2 = 25); println!("{:width2$} {}", "Total requests".yellow(), global_stats.total_requests.to_string().purple(), width2 = 25); println!("{:width2$} {}", "Successful requests".yellow(), global_stats.successful_requests.to_string().purple(), width2 = 25); println!("{:width2$} {}", "Failed requests".yellow(), global_stats.failed_requests.to_string().purple(), width2 = 25); - println!("{:width2$} {} {}", "Requests per second".yellow(), format!("{:.2}", requests_per_second).purple(), "[#/sec]".purple(), width2 = 25); + println!("{:width2$} {} {}", "Requests per second".yellow(), format!("{requests_per_second:.2}").purple(), "[#/sec]".purple(), width2 = 25); println!("{:width2$} {}", "Median time per request".yellow(), format_time(global_stats.median_duration(), nanosec).purple(), width2 = 25); println!("{:width2$} {}", "Average time per request".yellow(), format_time(global_stats.mean_duration(), nanosec).purple(), width2 = 25); println!("{:width2$} {}", "Sample standard deviation".yellow(), format_time(global_stats.stdev_duration(), nanosec).purple(), width2 = 25); diff --git a/src/reader.rs b/src/reader.rs index c568854..38d335e 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -32,7 +32,7 @@ pub fn read_yaml_doc_accessor<'a>(doc: &'a yaml_rust::Yaml, accessor: Option<&st match doc[accessor_id].as_vec() { Some(items) => items, None => { - println!("Node missing on config: {}", accessor_id); + println!("Node missing on config: {accessor_id}"); println!("Exiting."); std::process::exit(1) } @@ -58,7 +58,7 @@ pub fn read_file_as_yml_array(filepath: &str) -> yaml_rust::yaml::Array { Ok(text) => { items.push(yaml_rust::Yaml::String(text)); } - Err(e) => println!("error parsing line: {:?}", e), + Err(e) => println!("error parsing line: {e:?}"), } } @@ -100,7 +100,7 @@ pub fn read_csv_file_as_yml(filepath: &str, quote: u8) -> yaml_rust::yaml::Array items.push(yaml_rust::Yaml::Hash(linked_hash_map)); } - Err(e) => println!("error parsing header: {:?}", e), + Err(e) => println!("error parsing header: {e:?}"), } } diff --git a/src/tags.rs b/src/tags.rs index 22825a1..5f6028e 100644 --- a/src/tags.rs +++ b/src/tags.rs @@ -84,7 +84,7 @@ pub fn list_benchmark_file_tasks(benchmark_file: &str, tags: &Tags) { let mut out_str = String::new(); let mut emitter = YamlEmitter::new(&mut out_str); emitter.dump(item).unwrap(); - println!("{}", out_str); + println!("{out_str}"); } }