Skip to content

Commit

Permalink
Fix unused imports and functions warnings on windows
Browse files Browse the repository at this point in the history
Otherwise these warnings clutter the github diff display.
  • Loading branch information
th1000s authored and dandavison committed Feb 8, 2022
1 parent 37dd339 commit b66d1d3
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 48 deletions.
91 changes: 46 additions & 45 deletions src/features/hyperlinks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
5 changes: 2 additions & 3 deletions src/handlers/hunk_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit b66d1d3

Please sign in to comment.