@@ -196,7 +196,7 @@ impl Read for GitRFile<'_> {
196196#[ cfg( test) ]
197197mod tests {
198198 use std:: io:: Read ;
199- use std:: path:: Path ;
199+ use std:: path:: PathBuf ;
200200 use std:: pin:: Pin ;
201201
202202 use dir_structure:: prelude:: Vfs ;
@@ -209,6 +209,10 @@ mod tests {
209209 git2:: Repository :: open_from_env ( ) . expect ( "Failed to open git repository" )
210210 }
211211
212+ fn get_dir_structure_path ( ) -> PathBuf {
213+ PathBuf :: from ( std:: env:: var_os ( "DIR_STRUCTURE_REPO_IN_ROOT_REPO" ) . unwrap_or_default ( ) )
214+ }
215+
212216 #[ test]
213217 fn test_read ( ) {
214218 let repo = open_repo ( ) ;
@@ -220,8 +224,10 @@ mod tests {
220224 let vfs = GitVfs { repo : & repo, tree } ;
221225 let vfs = Pin :: new ( & vfs) ;
222226
227+ let ds_path = get_dir_structure_path ( ) ;
228+
223229 let content = vfs
224- . read_string ( Path :: new ( "README.md" ) )
230+ . read_string ( & ds_path . join ( "README.md" ) )
225231 . expect ( "Failed to read README.md" ) ;
226232 assert_eq ! ( content, include_str!( "../../README.md" ) ) ;
227233 }
@@ -237,12 +243,14 @@ mod tests {
237243 let vfs = GitVfs { repo : & repo, tree } ;
238244 let vfs = Pin :: new ( & vfs) ;
239245
246+ let ds_path = get_dir_structure_path ( ) ;
247+
240248 assert ! (
241- vfs. exists( Path :: new ( "README.md" ) )
249+ vfs. exists( & ds_path . join ( "README.md" ) )
242250 . expect( "Failed to check existence" )
243251 ) ;
244252 assert ! (
245- !vfs. exists( Path :: new ( "NON_EXISTENT_FILE" ) )
253+ !vfs. exists( & ds_path . join ( "NON_EXISTENT_FILE" ) )
246254 . expect( "Failed to check existence" )
247255 ) ;
248256 }
@@ -258,8 +266,10 @@ mod tests {
258266 let vfs = GitVfs { repo : & repo, tree } ;
259267 let vfs = Pin :: new ( & vfs) ;
260268
269+ let ds_path = get_dir_structure_path ( ) ;
270+
261271 let mut file = vfs
262- . open_read ( Path :: new ( "README.md" ) )
272+ . open_read ( & ds_path . join ( "README.md" ) )
263273 . expect ( "Failed to open README.md" ) ;
264274 let mut content = String :: new ( ) ;
265275 file. read_to_string ( & mut content)
@@ -277,8 +287,9 @@ mod tests {
277287 . expect ( "Failed to get tree" ) ;
278288 let vfs = GitVfs { repo : & repo, tree } ;
279289 let vfs = Pin :: new ( & vfs) ;
290+ let ds_path = get_dir_structure_path ( ) ;
280291 let mut walker = vfs
281- . walk_dir ( Path :: new ( "dir-structure-macros" ) )
292+ . walk_dir ( & ds_path . join ( "dir-structure-macros" ) )
282293 . expect ( "Failed to walk dir" ) ;
283294 let mut entries = Vec :: new ( ) ;
284295 while let Some ( entry) = walker. next ( ) {
@@ -293,23 +304,23 @@ mod tests {
293304 vfs:: DirEntryInfo {
294305 name: "Cargo.toml" . into( ) ,
295306 kind: vfs:: DirEntryKind :: File ,
296- path: Path :: new ( "dir-structure-macros/Cargo.toml" ) . into( ) ,
307+ path: ds_path . join ( "dir-structure-macros/Cargo.toml" ) . into( ) ,
297308 } ,
298309 vfs:: DirEntryInfo {
299310 name: "README.md" . into( ) ,
300311 kind: vfs:: DirEntryKind :: File ,
301- path: Path :: new ( "dir-structure-macros/README.md" ) . into( ) ,
312+ path: ds_path . join ( "dir-structure-macros/README.md" ) . into( ) ,
302313 } ,
303314 vfs:: DirEntryInfo {
304315 name: "src" . into( ) ,
305316 kind: vfs:: DirEntryKind :: Directory ,
306- path: Path :: new ( "dir-structure-macros/src" ) . into( ) ,
317+ path: ds_path . join ( "dir-structure-macros/src" ) . into( ) ,
307318 } ,
308319 ]
309320 ) ;
310321
311322 let mut walker = vfs
312- . walk_dir ( Path :: new ( "dir-structure" ) )
323+ . walk_dir ( & ds_path . join ( "dir-structure" ) )
313324 . expect ( "Failed to walk dir" ) ;
314325 let mut entries = Vec :: new ( ) ;
315326 while let Some ( entry) = walker. next ( ) {
@@ -324,27 +335,27 @@ mod tests {
324335 vfs:: DirEntryInfo {
325336 name: "Cargo.toml" . into( ) ,
326337 kind: vfs:: DirEntryKind :: File ,
327- path: Path :: new ( "dir-structure/Cargo.toml" ) . into( ) ,
338+ path: ds_path . join ( "dir-structure/Cargo.toml" ) . into( ) ,
328339 } ,
329340 vfs:: DirEntryInfo {
330341 name: "README.md" . into( ) ,
331342 kind: vfs:: DirEntryKind :: File ,
332- path: Path :: new ( "dir-structure/README.md" ) . into( ) ,
343+ path: ds_path . join ( "dir-structure/README.md" ) . into( ) ,
333344 } ,
334345 vfs:: DirEntryInfo {
335346 name: "examples" . into( ) ,
336347 kind: vfs:: DirEntryKind :: Directory ,
337- path: Path :: new ( "dir-structure/examples" ) . into( ) ,
348+ path: ds_path . join ( "dir-structure/examples" ) . into( ) ,
338349 } ,
339350 vfs:: DirEntryInfo {
340351 name: "src" . into( ) ,
341352 kind: vfs:: DirEntryKind :: Directory ,
342- path: Path :: new ( "dir-structure/src" ) . into( ) ,
353+ path: ds_path . join ( "dir-structure/src" ) . into( ) ,
343354 } ,
344355 vfs:: DirEntryInfo {
345356 name: "tests" . into( ) ,
346357 kind: vfs:: DirEntryKind :: Directory ,
347- path: Path :: new ( "dir-structure/tests" ) . into( ) ,
358+ path: ds_path . join ( "dir-structure/tests" ) . into( ) ,
348359 } ,
349360 ]
350361 ) ;
0 commit comments