@@ -155,8 +155,10 @@ mod local_filesystem {
155155 let urls = paths
156156 . into_iter ( )
157157 . map ( |p| {
158- let path_clone = p. clone ( ) ;
159- Url :: from_file_path ( p)
158+ let path_clone = p
159+ . canonicalize ( )
160+ . map_err ( |_| vortex_err ! ( "Cannot canonicalize file path: {:?}" , p) ) ?;
161+ Url :: from_file_path ( & path_clone)
160162 . map_err ( |_| vortex_err ! ( "Invalid file path: {:?}" , path_clone) )
161163 } )
162164 . collect :: < Result < Vec < _ > , _ > > ( ) ?;
@@ -167,12 +169,34 @@ mod local_filesystem {
167169
168170#[ cfg( test) ]
169171mod tests {
172+ use std:: env;
170173 use std:: fs:: { self , File } ;
174+ use std:: path:: PathBuf ;
171175
172176 use tempfile:: TempDir ;
173177
174178 use super :: * ;
175179
180+ #[ test]
181+ fn test_expand_local_disk_glob_relative_path ( ) {
182+ let temp_dir = TempDir :: new ( ) . unwrap ( ) ;
183+ let file_path = "test.txt" ;
184+
185+ let original_dir = env:: current_dir ( ) . unwrap ( ) ;
186+ env:: set_current_dir ( temp_dir. path ( ) ) . unwrap ( ) ;
187+
188+ File :: create ( file_path) . unwrap ( ) ;
189+ let result = local_filesystem:: expand_glob ( file_path) . unwrap ( ) ;
190+
191+ assert_eq ! ( result. 0 . len( ) , 1 ) ;
192+ assert_eq ! (
193+ result. 0 [ 0 ] . to_file_path( ) . unwrap( ) ,
194+ PathBuf :: from( file_path) . canonicalize( ) . unwrap( )
195+ ) ;
196+
197+ env:: set_current_dir ( & original_dir) . unwrap ( ) ;
198+ }
199+
176200 #[ test]
177201 fn test_expand_local_disk_glob_single_file ( ) {
178202 let temp_dir = TempDir :: new ( ) . unwrap ( ) ;
@@ -183,7 +207,10 @@ mod tests {
183207 let result = local_filesystem:: expand_glob ( & glob_pattern) . unwrap ( ) ;
184208
185209 assert_eq ! ( result. 0 . len( ) , 1 ) ;
186- assert_eq ! ( result. 0 [ 0 ] . to_file_path( ) . unwrap( ) , file_path) ;
210+ assert_eq ! (
211+ result. 0 [ 0 ] . to_file_path( ) . unwrap( ) ,
212+ file_path. canonicalize( ) . unwrap( )
213+ ) ;
187214 }
188215
189216 #[ test]
0 commit comments