Attempt to fix #365
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by David Peter · committed by David Peter · parent 2d398dc · Browse files · 2 files·+21 added−12 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+21 added−12 removed
- tests:+19 added−11 removed
- other:+2 added−1 removed
Provenance
- Commit
aeff525- Tree
8c49b2f- Author
David Peter <mail@david-peter.de>- Committer
David Peter <sharkdp@users.noreply.github.com>- Parent
2d398dc
2 files changed+21 added−12 removed
modified:src/main.rs+2 added-1 removed
19 unmodified lines20 use atty::Stream;21 use globset::GlobBuilder;22 use lscolors::LsColors;23 use regex::bytes::{RegexBuilder, RegexSetBuilder};24+use normpath::PathExt;25 26 use crate::error::print_error;27 use crate::exec::CommandTemplate;28 use crate::exit_codes::ExitCode;91 unmodified lines120 search_paths = search_paths121 .iter()122 .map(|path_buffer| {123 path_buffer123- .canonicalize()124+ .normalize()125 .and_then(|pb| filesystem::absolute_path(pb.as_path()))126 .unwrap()127 })128 .collect();363 unmodified linesmodified:tests/tests.rs+19 added-11 removed
3 unmodified lines4 use std::io::Write;5 use std::path::Path;6 use std::time::{Duration, SystemTime};7 8+use normpath::PathExt;9 use regex::escape;10 11 use crate::testenv::TestEnv;12 13 unmodified lines26 27 fn get_absolute_root_path(env: &TestEnv) -> String {28 let path = env29 .test_root()29- .canonicalize()30+ .normalize()31 .expect("absolute path")32+ .as_path()33 .to_str()34 .expect("string")35 .to_string();36 1054 unmodified lines1091 #[test]1092 fn test_symlink_and_absolute_path() {1093 let (te, abs_path) = get_test_env_with_abs_path(DEFAULT_DIRS, DEFAULT_FILES);1094 1095+ let expected_path = if cfg!(windows) { "symlink" } else { "one/two" };1096+1097 te.assert_output_subdirectory(1098 "symlink",1099 &["--absolute-path"],1100 &format!(1097- "{abs_path}/one/two/c.foo1098- {abs_path}/one/two/C.Foo21099- {abs_path}/one/two/three1100- {abs_path}/one/two/three/d.foo1101- {abs_path}/one/two/three/directory_foo",1102- abs_path = &abs_path1101+ "{abs_path}/{expected_path}/c.foo1102+ {abs_path}/{expected_path}/C.Foo21103+ {abs_path}/{expected_path}/three1104+ {abs_path}/{expected_path}/three/d.foo1105+ {abs_path}/{expected_path}/three/directory_foo",1106+ abs_path = &abs_path,1107+ expected_path = expected_path1108 ),1109 );1110 }1111 19 unmodified lines1131 let (te, abs_path) = get_test_env_with_abs_path(DEFAULT_DIRS, DEFAULT_FILES);1132 let root = te.system_root();1133 let prefix = escape(&root.to_string_lossy());1134 1135+ let expected_path = if cfg!(windows) { "symlink" } else { "one/two" };1136+1137 te.assert_output_subdirectory(1138 "symlink",1139 &[1140 "--absolute-path",1141 "--full-path",1142 &format!("^{prefix}.*three", prefix = prefix),1143 ],1144 &format!(1138- "{abs_path}/one/two/three1139- {abs_path}/one/two/three/d.foo1140- {abs_path}/one/two/three/directory_foo",1141- abs_path = &abs_path1145+ "{abs_path}/{expected_path}/three1146+ {abs_path}/{expected_path}/three/d.foo1147+ {abs_path}/{expected_path}/three/directory_foo",1148+ abs_path = &abs_path,1149+ expected_path = expected_path1150 ),1151 );1152 }1153 650 unmodified lines