mirror of
https://github.com/sharkdp/fd.git
synced 2024-11-17 09:28:25 +01:00
Attempt to fix #365
This commit is contained in:
parent
2d398dc4a7
commit
aeff525c30
2 changed files with 21 additions and 12 deletions
|
@ -21,6 +21,7 @@ use atty::Stream;
|
||||||
use globset::GlobBuilder;
|
use globset::GlobBuilder;
|
||||||
use lscolors::LsColors;
|
use lscolors::LsColors;
|
||||||
use regex::bytes::{RegexBuilder, RegexSetBuilder};
|
use regex::bytes::{RegexBuilder, RegexSetBuilder};
|
||||||
|
use normpath::PathExt;
|
||||||
|
|
||||||
use crate::error::print_error;
|
use crate::error::print_error;
|
||||||
use crate::exec::CommandTemplate;
|
use crate::exec::CommandTemplate;
|
||||||
|
@ -120,7 +121,7 @@ fn run() -> Result<ExitCode> {
|
||||||
.iter()
|
.iter()
|
||||||
.map(|path_buffer| {
|
.map(|path_buffer| {
|
||||||
path_buffer
|
path_buffer
|
||||||
.canonicalize()
|
.normalize()
|
||||||
.and_then(|pb| filesystem::absolute_path(pb.as_path()))
|
.and_then(|pb| filesystem::absolute_path(pb.as_path()))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
})
|
})
|
||||||
|
|
|
@ -5,6 +5,7 @@ use std::io::Write;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::time::{Duration, SystemTime};
|
use std::time::{Duration, SystemTime};
|
||||||
|
|
||||||
|
use normpath::PathExt;
|
||||||
use regex::escape;
|
use regex::escape;
|
||||||
|
|
||||||
use crate::testenv::TestEnv;
|
use crate::testenv::TestEnv;
|
||||||
|
@ -26,8 +27,9 @@ static DEFAULT_FILES: &[&str] = &[
|
||||||
fn get_absolute_root_path(env: &TestEnv) -> String {
|
fn get_absolute_root_path(env: &TestEnv) -> String {
|
||||||
let path = env
|
let path = env
|
||||||
.test_root()
|
.test_root()
|
||||||
.canonicalize()
|
.normalize()
|
||||||
.expect("absolute path")
|
.expect("absolute path")
|
||||||
|
.as_path()
|
||||||
.to_str()
|
.to_str()
|
||||||
.expect("string")
|
.expect("string")
|
||||||
.to_string();
|
.to_string();
|
||||||
|
@ -1090,16 +1092,19 @@ fn test_symlink_as_root() {
|
||||||
fn test_symlink_and_absolute_path() {
|
fn test_symlink_and_absolute_path() {
|
||||||
let (te, abs_path) = get_test_env_with_abs_path(DEFAULT_DIRS, DEFAULT_FILES);
|
let (te, abs_path) = get_test_env_with_abs_path(DEFAULT_DIRS, DEFAULT_FILES);
|
||||||
|
|
||||||
|
let expected_path = if cfg!(windows) { "symlink" } else { "one/two" };
|
||||||
|
|
||||||
te.assert_output_subdirectory(
|
te.assert_output_subdirectory(
|
||||||
"symlink",
|
"symlink",
|
||||||
&["--absolute-path"],
|
&["--absolute-path"],
|
||||||
&format!(
|
&format!(
|
||||||
"{abs_path}/one/two/c.foo
|
"{abs_path}/{expected_path}/c.foo
|
||||||
{abs_path}/one/two/C.Foo2
|
{abs_path}/{expected_path}/C.Foo2
|
||||||
{abs_path}/one/two/three
|
{abs_path}/{expected_path}/three
|
||||||
{abs_path}/one/two/three/d.foo
|
{abs_path}/{expected_path}/three/d.foo
|
||||||
{abs_path}/one/two/three/directory_foo",
|
{abs_path}/{expected_path}/three/directory_foo",
|
||||||
abs_path = &abs_path
|
abs_path = &abs_path,
|
||||||
|
expected_path = expected_path
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1127,6 +1132,8 @@ fn test_symlink_and_full_path() {
|
||||||
let root = te.system_root();
|
let root = te.system_root();
|
||||||
let prefix = escape(&root.to_string_lossy());
|
let prefix = escape(&root.to_string_lossy());
|
||||||
|
|
||||||
|
let expected_path = if cfg!(windows) { "symlink" } else { "one/two" };
|
||||||
|
|
||||||
te.assert_output_subdirectory(
|
te.assert_output_subdirectory(
|
||||||
"symlink",
|
"symlink",
|
||||||
&[
|
&[
|
||||||
|
@ -1135,10 +1142,11 @@ fn test_symlink_and_full_path() {
|
||||||
&format!("^{prefix}.*three", prefix = prefix),
|
&format!("^{prefix}.*three", prefix = prefix),
|
||||||
],
|
],
|
||||||
&format!(
|
&format!(
|
||||||
"{abs_path}/one/two/three
|
"{abs_path}/{expected_path}/three
|
||||||
{abs_path}/one/two/three/d.foo
|
{abs_path}/{expected_path}/three/d.foo
|
||||||
{abs_path}/one/two/three/directory_foo",
|
{abs_path}/{expected_path}/three/directory_foo",
|
||||||
abs_path = &abs_path
|
abs_path = &abs_path,
|
||||||
|
expected_path = expected_path
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue