From b66d1d371709205525128fcd80ca302630f8ac9e Mon Sep 17 00:00:00 2001 From: Thomas Otto Date: Mon, 7 Feb 2022 23:11:36 +0100 Subject: [PATCH] Fix unused imports and functions warnings on windows Otherwise these warnings clutter the github diff display. --- src/features/hyperlinks.rs | 91 +++++++++++++++++++------------------ src/handlers/hunk_header.rs | 5 +- 2 files changed, 48 insertions(+), 48 deletions(-) diff --git a/src/features/hyperlinks.rs b/src/features/hyperlinks.rs index 587faf9b1..2fad166fd 100644 --- a/src/features/hyperlinks.rs +++ b/src/features/hyperlinks.rs @@ -111,54 +111,55 @@ fn format_github_commit_url(commit: &str, github_repo: &str) -> String { #[cfg(test)] pub mod tests { - use std::path::PathBuf; + #[cfg(not(target_os = "windows"))] + pub mod unix { + use std::path::PathBuf; - use super::*; - use crate::tests::integration_test_utils; + use super::super::*; + use crate::tests::integration_test_utils; - fn assert_file_hyperlink_matches( - relative_path: &str, - expected_hyperlink_path: &str, - config: &Config, - ) { - let link_text = "link text"; - assert_eq!( - format_osc8_hyperlink( - &PathBuf::from(expected_hyperlink_path).to_string_lossy(), - link_text - ), - format_osc8_file_hyperlink(relative_path, None, link_text, config) - ) - } + fn assert_file_hyperlink_matches( + relative_path: &str, + expected_hyperlink_path: &str, + config: &Config, + ) { + let link_text = "link text"; + assert_eq!( + format_osc8_hyperlink( + &PathBuf::from(expected_hyperlink_path).to_string_lossy(), + link_text + ), + format_osc8_file_hyperlink(relative_path, None, link_text, config) + ) + } - #[test] - #[cfg(not(target_os = "windows"))] - fn test_relative_path_file_hyperlink_when_not_child_process_of_git() { - // The current process is not a child process of git. - // Delta receives a file path 'a'. - // The hyperlink should be $cwd/a. - let mut config = integration_test_utils::make_config_from_args(&[ - "--hyperlinks", - "--hyperlinks-file-link-format", - "{path}", - ]); - config.cwd_of_user_shell_process = Some(PathBuf::from("/some/cwd")); - assert_file_hyperlink_matches("a", "/some/cwd/a", &config) - } + #[test] + fn test_relative_path_file_hyperlink_when_not_child_process_of_git() { + // The current process is not a child process of git. + // Delta receives a file path 'a'. + // The hyperlink should be $cwd/a. + let mut config = integration_test_utils::make_config_from_args(&[ + "--hyperlinks", + "--hyperlinks-file-link-format", + "{path}", + ]); + config.cwd_of_user_shell_process = Some(PathBuf::from("/some/cwd")); + assert_file_hyperlink_matches("a", "/some/cwd/a", &config) + } - #[test] - #[cfg(not(target_os = "windows"))] - fn test_relative_path_file_hyperlink_when_child_process_of_git() { - // The current process is a child process of git. - // Delta receives a file path 'a'. - // We are in directory b/ relative to the repo root. - // The hyperlink should be $repo_root/b/a. - let mut config = integration_test_utils::make_config_from_args(&[ - "--hyperlinks", - "--hyperlinks-file-link-format", - "{path}", - ]); - config.cwd_of_user_shell_process = Some(PathBuf::from("/some/repo-root/b")); - assert_file_hyperlink_matches("a", "/some/repo-root/b/a", &config) + #[test] + fn test_relative_path_file_hyperlink_when_child_process_of_git() { + // The current process is a child process of git. + // Delta receives a file path 'a'. + // We are in directory b/ relative to the repo root. + // The hyperlink should be $repo_root/b/a. + let mut config = integration_test_utils::make_config_from_args(&[ + "--hyperlinks", + "--hyperlinks-file-link-format", + "{path}", + ]); + config.cwd_of_user_shell_process = Some(PathBuf::from("/some/repo-root/b")); + assert_file_hyperlink_matches("a", "/some/repo-root/b/a", &config) + } } } diff --git a/src/handlers/hunk_header.rs b/src/handlers/hunk_header.rs index 53cfbacb7..b52ba5b42 100644 --- a/src/handlers/hunk_header.rs +++ b/src/handlers/hunk_header.rs @@ -314,8 +314,6 @@ fn write_to_output_buffer( #[cfg(test)] pub mod tests { - use std::path::PathBuf; - use super::*; use crate::ansi::strip_ansi_codes; use crate::tests::integration_test_utils; @@ -412,7 +410,8 @@ pub mod tests { let mut config = integration_test_utils::make_config_from_args(&["--features", "hyperlinks"]); - config.cwd_of_user_shell_process = Some(PathBuf::from("/some/current/directory")); + config.cwd_of_user_shell_process = + Some(std::path::PathBuf::from("/some/current/directory")); let result = paint_file_path_with_line_number(Some(3), "some-file", &config);