Attempt to fix #365

This commit is contained in:
David Peter 2021-08-08 14:13:32 +02:00 committed by David Peter
parent 2d398dc4a7
commit aeff525c30
2 changed files with 21 additions and 12 deletions

View file

@ -21,6 +21,7 @@ use atty::Stream;
use globset::GlobBuilder;
use lscolors::LsColors;
use regex::bytes::{RegexBuilder, RegexSetBuilder};
use normpath::PathExt;
use crate::error::print_error;
use crate::exec::CommandTemplate;
@ -120,7 +121,7 @@ fn run() -> Result<ExitCode> {
.iter()
.map(|path_buffer| {
path_buffer
.canonicalize()
.normalize()
.and_then(|pb| filesystem::absolute_path(pb.as_path()))
.unwrap()
})

View file

@ -5,6 +5,7 @@ use std::io::Write;
use std::path::Path;
use std::time::{Duration, SystemTime};
use normpath::PathExt;
use regex::escape;
use crate::testenv::TestEnv;
@ -26,8 +27,9 @@ static DEFAULT_FILES: &[&str] = &[
fn get_absolute_root_path(env: &TestEnv) -> String {
let path = env
.test_root()
.canonicalize()
.normalize()
.expect("absolute path")
.as_path()
.to_str()
.expect("string")
.to_string();
@ -1090,16 +1092,19 @@ fn test_symlink_as_root() {
fn test_symlink_and_absolute_path() {
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(
"symlink",
&["--absolute-path"],
&format!(
"{abs_path}/one/two/c.foo
{abs_path}/one/two/C.Foo2
{abs_path}/one/two/three
{abs_path}/one/two/three/d.foo
{abs_path}/one/two/three/directory_foo",
abs_path = &abs_path
"{abs_path}/{expected_path}/c.foo
{abs_path}/{expected_path}/C.Foo2
{abs_path}/{expected_path}/three
{abs_path}/{expected_path}/three/d.foo
{abs_path}/{expected_path}/three/directory_foo",
abs_path = &abs_path,
expected_path = expected_path
),
);
}
@ -1127,6 +1132,8 @@ fn test_symlink_and_full_path() {
let root = te.system_root();
let prefix = escape(&root.to_string_lossy());
let expected_path = if cfg!(windows) { "symlink" } else { "one/two" };
te.assert_output_subdirectory(
"symlink",
&[
@ -1135,10 +1142,11 @@ fn test_symlink_and_full_path() {
&format!("^{prefix}.*three", prefix = prefix),
],
&format!(
"{abs_path}/one/two/three
{abs_path}/one/two/three/d.foo
{abs_path}/one/two/three/directory_foo",
abs_path = &abs_path
"{abs_path}/{expected_path}/three
{abs_path}/{expected_path}/three/d.foo
{abs_path}/{expected_path}/three/directory_foo",
abs_path = &abs_path,
expected_path = expected_path
),
);
}