Skip to content
Myr

Snapshot reference comparison output

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 463a889 · Browse files · 1 file+23 added−23 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+23 added−23 removed

  • tests:+23 added−23 removed

1 file+23 added−23 removed

modified:tests/integration_tests.rs+23 added-23 removed
705 unmodified lines
706}707708#[test]709fn command_sorted_comparison_and_markup_identify_reference() {710 let _settings = snapshot_settings().bind_to_scope();711 let directory = tempfile::tempdir().unwrap();712 let export_path = directory.path().join("results.md");713 let output = hyperfine_debug()714 .args([
12 unmodified lines
727 .unwrap();728 assert!(output.status.success(), "{:?}", output);729 let stdout = String::from_utf8(output.stdout).unwrap();730 let comparison = stdout.split_once("Relative speed comparison\n").unwrap().1;730 for (name, factor) in [731 ("baseline (reference)", "1.00"),732 ("sleep 1 (faster)", "2.00"),733 ("sleep 2 (same speed)", "1.00"),734 ("sleep 3 (slower)", "1.50"),735 ] {736 let row = comparison.lines().find(|line| line.contains(name)).unwrap();737 assert!(row.trim_start().starts_with(factor), "{}", row);738 }731 insta::assert_snapshot!(comparison, @r"732 1.00 baseline (reference)733 2.00 sleep 1 (faster)734 1.00 sleep 2 (same speed)735 1.50 sleep 3 (slower)736 ");737 let markdown = std::fs::read_to_string(export_path).unwrap();738 for (command, relative) in [739 ("baseline", "1.00 (reference)"),740 ("sleep 1", "2.00 (faster)"),
267 unmodified lines
1008}10091010#[test]1011fn markdown_export_uses_selected_parameterized_reference() {1014 let output = hyperfine_debug()1012 let _settings = snapshot_settings().bind_to_scope();1013 assert_cmd_snapshot!(hyperfine_debug()1014 .args([1015 "--style=none",1016 "--runs=1",1017 "--export-markdown=-",
5 unmodified lines
1023 "case-{x}",1024 "--reference",1025 "case-2",1026 "sleep {x}",1028 ])1029 .output()1030 .unwrap();1031 assert!(output.status.success(), "{:?}", output);1032 let stdout = String::from_utf8(output.stdout).unwrap();1033 for (command, relative) in [1034 ("case-1", "2.00 (faster)"),1035 ("case-2", "1.00 (reference)"),1036 ("case-3", "1.50 (slower)"),1037 ] {1038 let row = stdout.lines().find(|line| line.contains(command)).unwrap();1039 assert!(row.ends_with(&format!("| {relative} |")), "{}", row);1040 }1027 ]), @r"1028 success: true1029 exit_code: 01030 ----- stdout -----10311032 | Command | Mean [s] | Min [s] | Max [s] | Relative |1033 |:---|---:|---:|---:|---:|1034 | `case-1` | 1.000 | 1.000 | 1.000 | 2.00 (faster) |1035 | `case-2` | 2.000 | 2.000 | 2.000 | 1.00 (reference) |1036 | `case-3` | 3.000 | 3.000 | 3.000 | 1.50 (slower) |103710381039 ----- stderr -----1040 ");1041}10421043#[test]1044fn intermediate_results_are_not_exported_to_stdout() {
235 unmodified lines