From 123e883bcb6c9eed722e1e0e0e5625e5db10bce8 Mon Sep 17 00:00:00 2001 From: ulwlu Date: Mon, 23 Nov 2020 05:07:27 +0900 Subject: Fix diff interactivefilter when decoration option is enabled (#367) * Add test for diffInteractiveFilter for all options * Disable **-decoration-style when color-only * Edit color-only one-to-one test cases Co-authored-by: ryuta69 Co-authored-by: Dan Davison --- src/options/set.rs | 2 + src/tests/test_example_diffs.rs | 129 ++++++++++++++++++++++++++++++---------- 2 files changed, 99 insertions(+), 32 deletions(-) diff --git a/src/options/set.rs b/src/options/set.rs index e721c5ae..67a5e21d 100644 --- a/src/options/set.rs +++ b/src/options/set.rs @@ -192,6 +192,8 @@ pub fn set_options( // there (does not emit lines in 1-1 correspondence with raw git output). See #274. if opt.color_only { opt.side_by_side = false; + opt.file_decoration_style = "none".to_string(); + opt.commit_decoration_style = "none".to_string(); opt.file_style = "raw".to_string(); opt.commit_style = "raw".to_string(); opt.hunk_header_style = "raw".to_string(); diff --git a/src/tests/test_example_diffs.rs b/src/tests/test_example_diffs.rs index d42efb64..022748df 100644 --- a/src/tests/test_example_diffs.rs +++ b/src/tests/test_example_diffs.rs @@ -837,38 +837,100 @@ src/align.rs #[test] fn test_color_only_output_is_in_one_to_one_correspondence_with_input() { - _do_test_output_is_in_one_to_one_correspondence_with_input(&["--color-only", "true"]); - _do_test_output_is_in_one_to_one_correspondence_with_input(&[ - "--color-only", - "true", - "--hunk-header-style", - "normal", - "--line-numbers", - ]); - _do_test_output_is_in_one_to_one_correspondence_with_input(&[ - "--color-only", - "true", - "--file-style", - "blue", - "--commit-style", - "omit", - "--hunk-header-style", - "omit", - "--hunk-header-decoration-style", - "omit", - ]); - _do_test_output_is_in_one_to_one_correspondence_with_input(&[ - "--color-only", - "true", - "--file-style", - "blue", - "--commit-style", - "red", - "--hunk-header-style", - "syntax", - "--hunk-header-decoration-style", - "box", - ]); + let user_suppliable_configs: &[&[&str]] = &[ + &["--color-only", "--light"], + &["--color-only", "--dark"], + &["--color-only", "--line-numbers"], + &["--color-only", "--side-by-side"], + &["--color-only", "--diff-highlight"], + &["--color-only", "--diff-so-fancy"], + &["--color-only", "--navigate"], + &["--color-only", "--hyperlinks"], + &["--color-only", "--keep-plus-minus-markers"], + &["--color-only", "--raw"], + &["--color-only", "--syntax-theme", "Monokai Extended"], + &["--color-only", "--minus-style", "syntax bold auto"], + &["--color-only", "--zero-style", "red strike"], + &["--color-only", "--plus-style", "red blink"], + &["--color-only", "--minus-emph-style", "red dim"], + &["--color-only", "--minus-non-emph-style", "red hidden"], + &["--color-only", "--plus-emph-style", "red reverse"], + &["--color-only", "--plus-non-emph-style", "red bold ul"], + &["--color-only", "--commit-style", "red bold ul"], + &[ + "--color-only", + "--commit-decoration-style", + "bold yellow box ul", + ], + &["--color-only", "--file-style", "red bold ul"], + &[ + "--color-only", + "--file-decoration-style", + "bold yellow box ul", + ], + &["--color-only", "--hunk-header-style", "red bold ul"], + &[ + "--color-only", + "--hunk-header-decoration-style", + "bold yellow box ul", + ], + &[ + "--color-only", + "--line-numbers", + "--line-numbers-minus-style", + "#444444", + ], + &[ + "--color-only", + "--line-numbers", + "--line-numbers-zero-style", + "#444444", + ], + &[ + "--color-only", + "--line-numbers", + "--line-numbers-plus-style", + "#444444", + ], + &[ + "--color-only", + "--line-numbers", + "--line-numbers-left-format", + "{nm:>4}┊", + ], + &[ + "--color-only", + "--line-numbers", + "--line-numbers-right-format", + "{np:>4}│", + ], + &[ + "--color-only", + "--line-numbers", + "--line-numbers-left-style", + "blue", + ], + &[ + "--color-only", + "--line-numbers", + "--line-numbers-right-style", + "blue", + ], + &["--color-only", "--file-modified-label", "hogehoge"], + &["--color-only", "--file-removed-label", "hogehoge"], + &["--color-only", "--file-added-label", "hogehoge"], + &["--color-only", "--file-renamed-label", "hogehoge"], + &["--color-only", "--max-line-length", "1"], + &["--color-only", "--width", "1"], + &["--color-only", "--tabs", "10"], + &["--color-only", "--24-bit-color", "always"], + &["--color-only", "--inspect-raw-lines", "false"], + &["--color-only", "--whitespace-error-style", "22 reverse"], + ]; + + for config in user_suppliable_configs { + _do_test_output_is_in_one_to_one_correspondence_with_input(config); + } } fn _do_test_output_is_in_one_to_one_correspondence_with_input(args: &[&str]) { @@ -882,6 +944,9 @@ src/align.rs // Although git patch options only checks the line counts of input and output, // we should check if they are identical as well to avoid unexpected decoration. + if args.contains(&"--max-line-length") { + return; + } for n in 0..input_lines.len() { let input_line = input_lines[n]; // If config.line_numbers is enabled, -- cgit v1.2.3