Move more tests to insta
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by David Peter · committed by David Peter · parent 7a9d04d · Browse files · 5 files·+154 added−539 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+154 added−539 removed
- other:+154 added−539 removed
Provenance
- Commit
da399ab- Tree
7270023- Author
David Peter <mail@david-peter.de>- Committer
David Peter <sharkdp@users.noreply.github.com>- Parent
7a9d04d
5 files changed+154 added−539 removed
modified:src/export/asciidoc.rs-174 removed
63 unmodified lines64 let expect = "[cols=\"<,>,>,>,>\"]\n|===";65 66 assert_eq!(expect, actual);67 }68-69-/// Test helper function to create unit-based header and horizontal line70-/// independently from the markup functionality for Asciidoc.71-#[cfg(test)]72-fn cfg_test_table_header(unit_short_name: &str) -> String {73- format!(74- "[cols=\"<,>,>,>,>\"]\n|===\n| Command \n| Mean [{unit_short_name}] \n| Min [{unit_short_name}] \n| Max [{unit_short_name}] \n| Relative \n"75- )76-}77-78-#[cfg(test)]79-use crate::options::SortOrder;80-81-#[cfg(test)]82-use crate::util::units::Unit;83-84-#[cfg(test)]85-use crate::export::BenchmarkResult;86-87-#[cfg(test)]88-use crate::export::Exporter;89-90-/// Integration test91-#[test]92-fn test_asciidoc_format_s() {93- use std::collections::BTreeMap;94- let exporter = AsciidocExporter::default();95-96- let results = vec![97- BenchmarkResult {98- command: String::from("FOO=1 BAR=2 command | 1"),99- command_with_unused_parameters: String::from("FOO=1 BAR=2 command | 1"),100- mean: 1.0,101- stddev: Some(2.0),102- median: 1.0,103- user: 3.0,104- system: 4.0,105- min: 5.0,106- max: 6.0,107- times: Some(vec![7.0, 8.0, 9.0]),108- memory_usage_byte: None,109- exit_codes: vec![Some(0), Some(0), Some(0)],110- parameters: {111- let mut params = BTreeMap::new();112- params.insert("foo".into(), "1".into());113- params.insert("bar".into(), "2".into());114- params115- },116- },117- BenchmarkResult {118- command: String::from("FOO=1 BAR=7 command | 2"),119- command_with_unused_parameters: String::from("FOO=1 BAR=7 command | 2"),120- mean: 11.0,121- stddev: Some(12.0),122- median: 11.0,123- user: 13.0,124- system: 14.0,125- min: 15.0,126- max: 16.0,127- times: Some(vec![17.0, 18.0, 19.0]),128- memory_usage_byte: None,129- exit_codes: vec![Some(0), Some(0), Some(0)],130- parameters: {131- let mut params = BTreeMap::new();132- params.insert("foo".into(), "1".into());133- params.insert("bar".into(), "7".into());134- params135- },136- },137- ];138-139- let actual = String::from_utf8(140- exporter141- .serialize(&results, Some(Unit::Second), SortOrder::Command)142- .unwrap(),143- )144- .unwrap();145- let expect = format!(146- "{}147-| `FOO=1 BAR=2 command \\| 1` 148-| 1.000 ± 2.000 149-| 5.000 150-| 6.000 151-| 1.00 152-153-| `FOO=1 BAR=7 command \\| 2` 154-| 11.000 ± 12.000 155-| 15.000 156-| 16.000 157-| 11.00 ± 25.06 158-|===159-",160- cfg_test_table_header("s")161- );162-163- assert_eq!(expect, actual);164-}165-166-/// This test demonstrates that the given unit (ms) is used to set167-/// the units for all entries.168-#[test]169-fn test_asciidoc_format_ms() {170- use std::collections::BTreeMap;171- let exporter = AsciidocExporter::default();172-173- let results = vec![174- BenchmarkResult {175- command: String::from("FOO=1 BAR=7 command | 2"),176- command_with_unused_parameters: String::from("FOO=1 BAR=7 command | 2"),177- mean: 0.011,178- stddev: Some(0.012),179- median: 0.011,180- user: 0.013,181- system: 0.014,182- min: 0.015,183- max: 0.016,184- times: Some(vec![0.017, 0.018, 0.019]),185- memory_usage_byte: None,186- exit_codes: vec![Some(0), Some(0), Some(0)],187- parameters: {188- let mut params = BTreeMap::new();189- params.insert("foo".into(), "1".into());190- params.insert("bar".into(), "7".into());191- params192- },193- },194- BenchmarkResult {195- command: String::from("FOO=1 BAR=2 command | 1"),196- command_with_unused_parameters: String::from("FOO=1 BAR=2 command | 1"),197- mean: 1.0,198- stddev: Some(2.0),199- median: 1.0,200- user: 3.0,201- system: 4.0,202- min: 5.0,203- max: 6.0,204- times: Some(vec![7.0, 8.0, 9.0]),205- memory_usage_byte: None,206- exit_codes: vec![Some(0), Some(0), Some(0)],207- parameters: {208- let mut params = BTreeMap::new();209- params.insert("foo".into(), "1".into());210- params.insert("bar".into(), "2".into());211- params212- },213- },214- ];215-216- let actual = String::from_utf8(217- exporter218- .serialize(&results, Some(Unit::MilliSecond), SortOrder::Command)219- .unwrap(),220- )221- .unwrap();222- let expect = format!(223- "{}224-| `FOO=1 BAR=7 command \\| 2` 225-| 11.0 ± 12.0 226-| 15.0 227-| 16.0 228-| 1.00 229-230-| `FOO=1 BAR=2 command \\| 1` 231-| 1000.0 ± 2000.0 232-| 5000.0 233-| 6000.0 234-| 90.91 ± 207.11 235-|===236-",237- cfg_test_table_header("ms")238- );239-240- assert_eq!(expect, actual);241-}modified:src/export/csv.rs+7 added-8 removed
105 unmodified lines106 params107 },108 },109 ];110- let exps: String = String::from(111- "command,mean,stddev,median,user,system,min,max,parameter_bar,parameter_foo\n\112- FOO=one BAR=two command | 1,1,2,1,3,4,5,6,two,one\n\113- FOO=one BAR=seven command | 2,11,12,11,13,14,15,16.5,seven,one\n\114- ",115- );116- let gens = String::from_utf8(110+111+ let actual = String::from_utf8(112 exporter113 .serialize(&results, Some(Unit::Second), SortOrder::Command)114 .unwrap(),115 )116 .unwrap();117 123- assert_eq!(exps, gens);118+ insta::assert_snapshot!(actual, @r#"119+ command,mean,stddev,median,user,system,min,max,parameter_bar,parameter_foo120+ FOO=one BAR=two command | 1,1,2,1,3,4,5,6,two,one121+ FOO=one BAR=seven command | 2,11,12,11,13,14,15,16.5,seven,one122+ "#);123 }modified:src/export/markup.rs-188 removed
117 unmodified lines118 let table = self.table_results(&entries, unit);119 Ok(table.as_bytes().to_vec())120 }121 }122-123-/// Check unit resolving for timing results and given unit 's'124-#[test]125-fn test_determine_unit_from_results_unit_given_s() {126- use std::collections::BTreeMap;127- let results = vec![128- BenchmarkResult {129- command: String::from("sleep 2"),130- command_with_unused_parameters: String::from("sleep 2"),131- mean: 2.0050,132- stddev: Some(0.0020),133- median: 2.0050,134- user: 0.0009,135- system: 0.0012,136- min: 2.0020,137- max: 2.0080,138- times: Some(vec![2.0, 2.0, 2.0]),139- memory_usage_byte: None,140- exit_codes: vec![Some(0), Some(0), Some(0)],141- parameters: BTreeMap::new(),142- },143- BenchmarkResult {144- command: String::from("sleep 0.1"),145- command_with_unused_parameters: String::from("sleep 0.1"),146- mean: 0.1057,147- stddev: Some(0.0016),148- median: 0.1057,149- user: 0.0009,150- system: 0.0011,151- min: 0.1023,152- max: 0.1080,153- times: Some(vec![0.1, 0.1, 0.1]),154- memory_usage_byte: None,155- exit_codes: vec![Some(0), Some(0), Some(0)],156- parameters: BTreeMap::new(),157- },158- ];159- let unit = Some(Unit::Second);160-161- let markup_actual = unit.unwrap_or_else(|| determine_unit_from_results(&results));162- let markup_expected = Unit::Second;163-164- assert_eq!(markup_expected, markup_actual);165-}166-167-/// Check unit resolving for timing results and given unit 'ms'168-#[test]169-fn test_determine_unit_from_results_unit_given_ms() {170- use std::collections::BTreeMap;171- let results = vec![172- BenchmarkResult {173- command: String::from("sleep 2"),174- command_with_unused_parameters: String::from("sleep 2"),175- mean: 2.0050,176- stddev: Some(0.0020),177- median: 2.0050,178- user: 0.0009,179- system: 0.0012,180- min: 2.0020,181- max: 2.0080,182- times: Some(vec![2.0, 2.0, 2.0]),183- memory_usage_byte: None,184- exit_codes: vec![Some(0), Some(0), Some(0)],185- parameters: BTreeMap::new(),186- },187- BenchmarkResult {188- command: String::from("sleep 0.1"),189- command_with_unused_parameters: String::from("sleep 0.1"),190- mean: 0.1057,191- stddev: Some(0.0016),192- median: 0.1057,193- user: 0.0009,194- system: 0.0011,195- min: 0.1023,196- max: 0.1080,197- times: Some(vec![0.1, 0.1, 0.1]),198- memory_usage_byte: None,199- exit_codes: vec![Some(0), Some(0), Some(0)],200- parameters: BTreeMap::new(),201- },202- ];203- let unit = Some(Unit::MilliSecond);204-205- let markup_actual = unit.unwrap_or_else(|| determine_unit_from_results(&results));206- let markup_expected = Unit::MilliSecond;207-208- assert_eq!(markup_expected, markup_actual);209-}210-211-/// Check unit resolving for timing results using the first result entry as 's'212-#[test]213-fn test_determine_unit_from_results_unit_first_s() {214- use std::collections::BTreeMap;215- let results = vec![216- BenchmarkResult {217- command: String::from("sleep 2"),218- command_with_unused_parameters: String::from("sleep 2"),219- mean: 2.0050,220- stddev: Some(0.0020),221- median: 2.0050,222- user: 0.0009,223- system: 0.0012,224- min: 2.0020,225- max: 2.0080,226- times: Some(vec![2.0, 2.0, 2.0]),227- memory_usage_byte: None,228- exit_codes: vec![Some(0), Some(0), Some(0)],229- parameters: BTreeMap::new(),230- },231- BenchmarkResult {232- command: String::from("sleep 0.1"),233- command_with_unused_parameters: String::from("sleep 0.1"),234- mean: 0.1057,235- stddev: Some(0.0016),236- median: 0.1057,237- user: 0.0009,238- system: 0.0011,239- min: 0.1023,240- max: 0.1080,241- times: Some(vec![0.1, 0.1, 0.1]),242- memory_usage_byte: None,243- exit_codes: vec![Some(0), Some(0), Some(0)],244- parameters: BTreeMap::new(),245- },246- ];247- let unit = None;248-249- let markup_actual = unit.unwrap_or_else(|| determine_unit_from_results(&results));250- let markup_expected = Unit::Second;251-252- assert_eq!(markup_expected, markup_actual);253-}254-255-/// Check unit resolving for timing results using the first result entry as 'ms'256-#[test]257-fn test_determine_unit_from_results_unit_first_ms() {258- use std::collections::BTreeMap;259- let results = vec![260- BenchmarkResult {261- command: String::from("sleep 0.1"),262- command_with_unused_parameters: String::from("sleep 0.1"),263- mean: 0.1057,264- stddev: Some(0.0016),265- median: 0.1057,266- user: 0.0009,267- system: 0.0011,268- min: 0.1023,269- max: 0.1080,270- times: Some(vec![0.1, 0.1, 0.1]),271- memory_usage_byte: None,272- exit_codes: vec![Some(0), Some(0), Some(0)],273- parameters: BTreeMap::new(),274- },275- BenchmarkResult {276- command: String::from("sleep 2"),277- command_with_unused_parameters: String::from("sleep 2"),278- mean: 2.0050,279- stddev: Some(0.0020),280- median: 2.0050,281- user: 0.0009,282- system: 0.0012,283- min: 2.0020,284- max: 2.0080,285- times: Some(vec![2.0, 2.0, 2.0]),286- memory_usage_byte: None,287- exit_codes: vec![Some(0), Some(0), Some(0)],288- parameters: BTreeMap::new(),289- },290- ];291- let unit = None;292-293- let markup_actual = unit.unwrap_or_else(|| determine_unit_from_results(&results));294- let markup_expected = Unit::MilliSecond;295-296- assert_eq!(markup_expected, markup_actual);297-}298-299-/// Check unit resolving for not timing results and no given unit defaulting to 's'300-#[test]301-fn test_determine_unit_from_results_unit_default_s() {302- let results: Vec<BenchmarkResult> = vec![];303- let unit = None;304-305- let markup_actual = unit.unwrap_or_else(|| determine_unit_from_results(&results));306- let markup_expected = Unit::Second;307-308- assert_eq!(markup_expected, markup_actual);309-}modified:src/export/orgmode.rs-137 removed
20 unmodified lines21 format!("={cmd}=")22 }23 }24 25-#[cfg(test)]26-use crate::options::SortOrder;27-25 /// Check Emacs org-mode data row formatting26 #[test]27 fn test_orgmode_formatter_table_data() {28 let exporter = OrgmodeExporter::default();19 unmodified lines48 let expect = "|--+--+--+--+--|\n";49 50 assert_eq!(expect, actual);51 }55-56-/// Test helper function to create unit-based header and horizontal line57-/// independently from the markup functionality for Emacs org-mode.58-#[cfg(test)]59-fn cfg_test_table_header(unit_short_name: String) -> String {60- format!(61- "| Command | Mean [{unit_short_name}] | Min [{unit_short_name}] | Max [{unit_short_name}] | Relative |\n|--+--+--+--+--|\n"62- )63-}64-65-/// Ensure the Emacs org-mode output includes the table header and the multiple66-/// benchmark results as a table. The list of actual times is not included67-/// in the output.68-///69-/// This also demonstrates that the first entry's units (ms) are used to set70-/// the units for all entries when the time unit is not given.71-#[test]72-fn test_orgmode_format_ms() {73- use super::Exporter;74- use crate::benchmark::benchmark_result::BenchmarkResult;75- use std::collections::BTreeMap;76-77- let exporter = OrgmodeExporter::default();78-79- let results = vec![80- BenchmarkResult {81- command: String::from("sleep 0.1"),82- command_with_unused_parameters: String::from("sleep 0.1"),83- mean: 0.1057,84- stddev: Some(0.0016),85- median: 0.1057,86- user: 0.0009,87- system: 0.0011,88- min: 0.1023,89- max: 0.1080,90- times: Some(vec![0.1, 0.1, 0.1]),91- memory_usage_byte: None,92- exit_codes: vec![Some(0), Some(0), Some(0)],93- parameters: BTreeMap::new(),94- },95- BenchmarkResult {96- command: String::from("sleep 2"),97- command_with_unused_parameters: String::from("sleep 2"),98- mean: 2.0050,99- stddev: Some(0.0020),100- median: 2.0050,101- user: 0.0009,102- system: 0.0012,103- min: 2.0020,104- max: 2.0080,105- times: Some(vec![2.0, 2.0, 2.0]),106- memory_usage_byte: None,107- exit_codes: vec![Some(0), Some(0), Some(0)],108- parameters: BTreeMap::new(),109- },110- ];111-112- let actual = String::from_utf8(113- exporter114- .serialize(&results, None, SortOrder::Command)115- .unwrap(),116- )117- .unwrap();118- let expect = format!(119- "{}\120-| =sleep 0.1= | 105.7 ± 1.6 | 102.3 | 108.0 | 1.00 |121-| =sleep 2= | 2005.0 ± 2.0 | 2002.0 | 2008.0 | 18.97 ± 0.29 |122-",123- cfg_test_table_header("ms".to_string())124- );125-126- assert_eq!(expect, actual);127-}128-129-/// This test demonstrates that the given unit (s) is used to set130-/// the units for all entries.131-#[test]132-fn test_orgmode_format_s() {133- use super::Exporter;134- use crate::benchmark::benchmark_result::BenchmarkResult;135- use crate::util::units::Unit;136- use std::collections::BTreeMap;137-138- let exporter = OrgmodeExporter::default();139-140- let results = vec![141- BenchmarkResult {142- command: String::from("sleep 2"),143- command_with_unused_parameters: String::from("sleep 2"),144- mean: 2.0050,145- stddev: Some(0.0020),146- median: 2.0050,147- user: 0.0009,148- system: 0.0012,149- min: 2.0020,150- max: 2.0080,151- times: Some(vec![2.0, 2.0, 2.0]),152- memory_usage_byte: None,153- exit_codes: vec![Some(0), Some(0), Some(0)],154- parameters: BTreeMap::new(),155- },156- BenchmarkResult {157- command: String::from("sleep 0.1"),158- command_with_unused_parameters: String::from("sleep 0.1"),159- mean: 0.1057,160- stddev: Some(0.0016),161- median: 0.1057,162- user: 0.0009,163- system: 0.0011,164- min: 0.1023,165- max: 0.1080,166- times: Some(vec![0.1, 0.1, 0.1]),167- memory_usage_byte: None,168- exit_codes: vec![Some(0), Some(0), Some(0)],169- parameters: BTreeMap::new(),170- },171- ];172-173- let actual = String::from_utf8(174- exporter175- .serialize(&results, Some(Unit::Second), SortOrder::Command)176- .unwrap(),177- )178- .unwrap();179- let expect = format!(180- "{}\181-| =sleep 2= | 2.005 ± 0.002 | 2.002 | 2.008 | 18.97 ± 0.29 |182-| =sleep 0.1= | 0.106 ± 0.002 | 0.102 | 0.108 | 1.00 |183-",184- cfg_test_table_header("s".to_string())185- );186-187- assert_eq!(expect, actual);188-}modified:src/export/tests.rs+147 added-32 removed
1 use super::Exporter;2 use crate::benchmark::benchmark_result::BenchmarkResult;3+use crate::export::asciidoc::AsciidocExporter;4+use crate::export::orgmode::OrgmodeExporter;5 use crate::util::units::Unit;6 use crate::{export::markdown::MarkdownExporter, options::SortOrder};7 use std::collections::BTreeMap;8 7-fn get_markdown_output(9+fn get_output<E: Exporter + Default>(10 results: &[BenchmarkResult],11 unit: Option<Unit>,12 sort_order: SortOrder,13 ) -> String {12- let exporter = MarkdownExporter::default();14+ let exporter = E::default();15 String::from_utf8(exporter.serialize(results, unit, sort_order).unwrap()).unwrap()16 }17 16-/// Ensure the markdown output includes the table header and the multiple18+/// Ensure the makrup output includes the table header and the multiple19 /// benchmark results as a table. The list of actual times is not included20 /// in the output.21 ///22 /// This also demonstrates that the first entry's units (ms) are used to set21-/// the units for all entries when the time unit is not given.23+/// the units for all entries when the time unit is not specified.24 #[test]23-fn test_markdown_format_ms() {25+fn test_markup_export_auto_ms() {26 let results = [27 BenchmarkResult {28 command: String::from("sleep 0.1"),29 command_with_unused_parameters: String::from("sleep 0.1"),25 unmodified lines55 parameters: BTreeMap::new(),56 },57 ];58 57- insta::assert_snapshot!(get_markdown_output(&results, None, SortOrder::Command), @r#"59+ insta::assert_snapshot!(get_output::<MarkdownExporter>(&results, None, SortOrder::Command), @r#"60 | Command | Mean [ms] | Min [ms] | Max [ms] | Relative |61 |:---|---:|---:|---:|---:|62 | `sleep 0.1` | 105.7 ± 1.6 | 102.3 | 108.0 | 1.00 |63 | `sleep 2` | 2005.0 ± 2.0 | 2002.0 | 2008.0 | 18.97 ± 0.29 |64 "#);65+66+ insta::assert_snapshot!(get_output::<AsciidocExporter>(&results, None, SortOrder::Command), @r#"67+ [cols="<,>,>,>,>"]68+ |===69+ | Command 70+ | Mean [ms] 71+ | Min [ms] 72+ | Max [ms] 73+ | Relative 74+75+ | `sleep 0.1` 76+ | 105.7 ± 1.6 77+ | 102.3 78+ | 108.0 79+ | 1.00 80+81+ | `sleep 2` 82+ | 2005.0 ± 2.0 83+ | 2002.0 84+ | 2008.0 85+ | 18.97 ± 0.29 86+ |===87+ "#);88+89+ insta::assert_snapshot!(get_output::<OrgmodeExporter>(&results, None, SortOrder::Command), @r#"90+ | Command | Mean [ms] | Min [ms] | Max [ms] | Relative |91+ |--+--+--+--+--|92+ | =sleep 0.1= | 105.7 ± 1.6 | 102.3 | 108.0 | 1.00 |93+ | =sleep 2= | 2005.0 ± 2.0 | 2002.0 | 2008.0 | 18.97 ± 0.29 |94+ "#);95 }96 97 /// This (again) demonstrates that the first entry's units (s) are used to set98 /// the units for all entries when the time unit is not given.99 #[test]68-fn test_markdown_format_s() {100+fn test_markup_export_auto_s() {101 let results = [102 BenchmarkResult {103 command: String::from("sleep 2"),104 command_with_unused_parameters: String::from("sleep 2"),25 unmodified lines130 parameters: BTreeMap::new(),131 },132 ];133 102- insta::assert_snapshot!(get_markdown_output(&results, None, SortOrder::Command), @r#"134+ insta::assert_snapshot!(get_output::<MarkdownExporter>(&results, None, SortOrder::Command), @r#"135 | Command | Mean [s] | Min [s] | Max [s] | Relative |136 |:---|---:|---:|---:|---:|137 | `sleep 2` | 2.005 ± 0.002 | 2.002 | 2.008 | 18.97 ± 0.29 |138 | `sleep 0.1` | 0.106 ± 0.002 | 0.102 | 0.108 | 1.00 |139 "#);140+141+ insta::assert_snapshot!(get_output::<AsciidocExporter>(&results, None, SortOrder::Command), @r#"142+ [cols="<,>,>,>,>"]143+ |===144+ | Command 145+ | Mean [s] 146+ | Min [s] 147+ | Max [s] 148+ | Relative 149+150+ | `sleep 2` 151+ | 2.005 ± 0.002 152+ | 2.002 153+ | 2.008 154+ | 18.97 ± 0.29 155+156+ | `sleep 0.1` 157+ | 0.106 ± 0.002 158+ | 0.102 159+ | 0.108 160+ | 1.00 161+ |===162+ "#);163+164+ insta::assert_snapshot!(get_output::<OrgmodeExporter>(&results, None, SortOrder::Command), @r#"165+ | Command | Mean [s] | Min [s] | Max [s] | Relative |166+ |--+--+--+--+--|167+ | =sleep 2= | 2.005 ± 0.002 | 2.002 | 2.008 | 18.97 ± 0.29 |168+ | =sleep 0.1= | 0.106 ± 0.002 | 0.102 | 0.108 | 1.00 |169+ "#);170 }171 110-/// The given time unit (s) is used to set the units for all entries.172+/// This (again) demonstrates that the given time unit (ms) is used to set173+/// the units for all entries.174 #[test]112-fn test_markdown_format_time_unit_s() {113- let results = [175+fn test_markup_export_manual_ms() {176+ let timing_results = [177 BenchmarkResult {178 command: String::from("sleep 2"),179 command_with_unused_parameters: String::from("sleep 2"),180 mean: 2.0050,24 unmodified lines205 parameters: BTreeMap::new(),206 },207 ];208 146- insta::assert_snapshot!(get_markdown_output(&results, Some(Unit::Second), SortOrder::Command), @r#"147- | Command | Mean [s] | Min [s] | Max [s] | Relative |148- |:---|---:|---:|---:|---:|149- | `sleep 2` | 2.005 ± 0.002 | 2.002 | 2.008 | 18.97 ± 0.29 |150- | `sleep 0.1` | 0.106 ± 0.002 | 0.102 | 0.108 | 1.00 |151- "#);209+ insta::assert_snapshot!(get_output::<MarkdownExporter>(&timing_results, Some(Unit::MilliSecond), SortOrder::Command), @r#"210+ | Command | Mean [ms] | Min [ms] | Max [ms] | Relative |211+ |:---|---:|---:|---:|---:|212+ | `sleep 2` | 2005.0 ± 2.0 | 2002.0 | 2008.0 | 18.97 ± 0.29 |213+ | `sleep 0.1` | 105.7 ± 1.6 | 102.3 | 108.0 | 1.00 |214+ "#);215 153- insta::assert_snapshot!(get_markdown_output(&results, Some(Unit::Second), SortOrder::MeanTime), @r#"154- | Command | Mean [s] | Min [s] | Max [s] | Relative |155- |:---|---:|---:|---:|---:|156- | `sleep 0.1` | 0.106 ± 0.002 | 0.102 | 0.108 | 1.00 |157- | `sleep 2` | 2.005 ± 0.002 | 2.002 | 2.008 | 18.97 ± 0.29 |158- "#);216+ insta::assert_snapshot!(get_output::<AsciidocExporter>(&timing_results, Some(Unit::MilliSecond), SortOrder::Command), @r#"217+ [cols="<,>,>,>,>"]218+ |===219+ | Command 220+ | Mean [ms] 221+ | Min [ms] 222+ | Max [ms] 223+ | Relative 224+225+ | `sleep 2` 226+ | 2005.0 ± 2.0 227+ | 2002.0 228+ | 2008.0 229+ | 18.97 ± 0.29 230+231+ | `sleep 0.1` 232+ | 105.7 ± 1.6 233+ | 102.3 234+ | 108.0 235+ | 1.00 236+ |===237+ "#);238+239+ insta::assert_snapshot!(get_output::<OrgmodeExporter>(&timing_results, Some(Unit::MilliSecond), SortOrder::Command), @r#"240+ | Command | Mean [ms] | Min [ms] | Max [ms] | Relative |241+ |--+--+--+--+--|242+ | =sleep 2= | 2005.0 ± 2.0 | 2002.0 | 2008.0 | 18.97 ± 0.29 |243+ | =sleep 0.1= | 105.7 ± 1.6 | 102.3 | 108.0 | 1.00 |244+ "#);245 }246 161-/// This (again) demonstrates that the given time unit (ms) is used to set162-/// the units for all entries.247+/// The given time unit (s) is used to set the units for all entries.248 #[test]164-fn test_markdown_format_time_unit_ms() {165- let timing_results = [249+fn test_markup_export_manual_s() {250+ let results = [251 BenchmarkResult {252 command: String::from("sleep 2"),253 command_with_unused_parameters: String::from("sleep 2"),254 mean: 2.0050,24 unmodified lines279 parameters: BTreeMap::new(),280 },281 ];282 198- insta::assert_snapshot!(get_markdown_output(&timing_results, Some(Unit::MilliSecond), SortOrder::Command), @r#"199- | Command | Mean [ms] | Min [ms] | Max [ms] | Relative |200- |:---|---:|---:|---:|---:|201- | `sleep 2` | 2005.0 ± 2.0 | 2002.0 | 2008.0 | 18.97 ± 0.29 |202- | `sleep 0.1` | 105.7 ± 1.6 | 102.3 | 108.0 | 1.00 |283+ insta::assert_snapshot!(get_output::<MarkdownExporter>(&results, Some(Unit::Second), SortOrder::Command), @r#"284+ | Command | Mean [s] | Min [s] | Max [s] | Relative |285+ |:---|---:|---:|---:|---:|286+ | `sleep 2` | 2.005 ± 0.002 | 2.002 | 2.008 | 18.97 ± 0.29 |287+ | `sleep 0.1` | 0.106 ± 0.002 | 0.102 | 0.108 | 1.00 |288+ "#);289+290+ insta::assert_snapshot!(get_output::<MarkdownExporter>(&results, Some(Unit::Second), SortOrder::MeanTime), @r#"291+ | Command | Mean [s] | Min [s] | Max [s] | Relative |292+ |:---|---:|---:|---:|---:|293+ | `sleep 0.1` | 0.106 ± 0.002 | 0.102 | 0.108 | 1.00 |294+ | `sleep 2` | 2.005 ± 0.002 | 2.002 | 2.008 | 18.97 ± 0.29 |295+ "#);296+297+ insta::assert_snapshot!(get_output::<AsciidocExporter>(&results, Some(Unit::Second), SortOrder::Command), @r#"298+ [cols="<,>,>,>,>"]299+ |===300+ | Command 301+ | Mean [s] 302+ | Min [s] 303+ | Max [s] 304+ | Relative 305+306+ | `sleep 2` 307+ | 2.005 ± 0.002 308+ | 2.002 309+ | 2.008 310+ | 18.97 ± 0.29 311+312+ | `sleep 0.1` 313+ | 0.106 ± 0.002 314+ | 0.102 315+ | 0.108 316+ | 1.00 317+ |===318 "#);319 }