Skip to content
Myr

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

2 files+21 added−12 removed

modified:src/main.rs+2 added-1 removed
19 unmodified lines
20use atty::Stream;21use globset::GlobBuilder;22use lscolors::LsColors;23use regex::bytes::{RegexBuilder, RegexSetBuilder};24use normpath::PathExt;2526use crate::error::print_error;27use crate::exec::CommandTemplate;28use crate::exit_codes::ExitCode;
91 unmodified lines
120 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 lines
modified:tests/tests.rs+19 added-11 removed
3 unmodified lines
4use std::io::Write;5use std::path::Path;6use std::time::{Duration, SystemTime};78use normpath::PathExt;9use regex::escape;1011use crate::testenv::TestEnv;12
13 unmodified lines
2627fn 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 lines
1091#[test]1092fn test_symlink_and_absolute_path() {1093 let (te, abs_path) = get_test_env_with_abs_path(DEFAULT_DIRS, DEFAULT_FILES);10941095 let expected_path = if cfg!(windows) { "symlink" } else { "one/two" };10961097 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 lines
1131 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());11341135 let expected_path = if cfg!(windows) { "symlink" } else { "one/two" };11361137 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