1- use crate :: { dir_structure, fixture_path, Result } ;
1+ use crate :: { dir_structure, fixture_path} ;
22use git_object:: bstr:: ByteSlice ;
33use git_odb:: FindExt ;
44use git_worktree:: { copy_index, Options } ;
@@ -8,7 +8,7 @@ use std::fs;
88use std:: os:: unix:: prelude:: MetadataExt ;
99
1010#[ test]
11- fn test_copy_index ( ) -> Result < ( ) > {
11+ fn test_copy_index ( ) -> crate :: Result < ( ) > {
1212 let path = fixture_path ( "make_repo" ) ;
1313 let path_git = path. join ( ".git" ) ;
1414 let mut file = git_index:: File :: at ( path_git. join ( "index" ) , git_index:: decode:: Options :: default ( ) ) ?;
@@ -28,22 +28,37 @@ fn test_copy_index() -> Result<()> {
2828
2929 let srepo_files: Vec < _ > = repo_files. iter ( ) . flat_map ( |p| p. strip_prefix ( & path) ) . collect ( ) ;
3030 let scopy_files: Vec < _ > = copy_files. iter ( ) . flat_map ( |p| p. strip_prefix ( output) ) . collect ( ) ;
31- assert_eq ! ( srepo_files, scopy_files) ;
31+ assert_eq ! (
32+ srepo_files,
33+ scopy_files,
34+ "Testing if {} and {} have the same structure" ,
35+ path. display( ) ,
36+ output. display( )
37+ ) ;
3238
3339 for ( file1, file2) in repo_files. iter ( ) . zip ( copy_files. iter ( ) ) {
34- assert_eq ! ( fs:: read( file1) ?, fs:: read( file2) ?) ;
40+ assert_eq ! (
41+ fs:: read( file1) ?,
42+ fs:: read( file2) ?,
43+ "Testing if the contents of {} and {} are the same" ,
44+ file1. display( ) ,
45+ file2. display( ) ,
46+ ) ;
3547 #[ cfg( unix) ]
3648 assert_eq ! (
3749 fs:: symlink_metadata( file1) ?. mode( ) & 0b111 << 6 ,
38- fs:: symlink_metadata( file2) ?. mode( ) & 0b111 << 6
50+ fs:: symlink_metadata( file2) ?. mode( ) & 0b111 << 6 ,
51+ "Testing if the permissions of {} and {} are the same" ,
52+ file1. display( ) ,
53+ file2. display( ) ,
3954 ) ;
4055 }
4156
4257 Ok ( ( ) )
4358}
4459
4560#[ test]
46- fn test_copy_index_without_symlinks ( ) -> Result < ( ) > {
61+ fn test_copy_index_without_symlinks ( ) -> crate :: Result < ( ) > {
4762 let path = fixture_path ( "make_repo" ) ;
4863 let path_git = path. join ( ".git" ) ;
4964 let mut file = git_index:: File :: at ( path_git. join ( "index" ) , git_index:: decode:: Options :: default ( ) ) ?;
@@ -63,18 +78,39 @@ fn test_copy_index_without_symlinks() -> Result<()> {
6378
6479 let srepo_files: Vec < _ > = repo_files. iter ( ) . flat_map ( |p| p. strip_prefix ( & path) ) . collect ( ) ;
6580 let scopy_files: Vec < _ > = copy_files. iter ( ) . flat_map ( |p| p. strip_prefix ( output) ) . collect ( ) ;
66- assert_eq ! ( srepo_files, scopy_files) ;
81+ assert_eq ! (
82+ srepo_files,
83+ scopy_files,
84+ "Testing if {} and {} have the same structure" ,
85+ path. display( ) ,
86+ output. display( )
87+ ) ;
6788
6889 for ( file1, file2) in repo_files. iter ( ) . zip ( copy_files. iter ( ) ) {
6990 if file1. is_symlink ( ) {
70- assert ! ( !file2. is_symlink( ) ) ;
71- assert_eq ! ( fs:: read( file2) ?. to_path( ) ?, fs:: read_link( file1) ?) ;
91+ assert ! ( !file2. is_symlink( ) , "Testing if the new file is not a symlink" ) ;
92+ assert_eq ! (
93+ fs:: read( file2) ?. to_path( ) ?,
94+ fs:: read_link( file1) ?,
95+ "Testing if the {} contains the path the symlink {} is pointing to" ,
96+ file2. display( ) ,
97+ file1. display( ) ,
98+ ) ;
7299 } else {
73- assert_eq ! ( fs:: read( file1) ?, fs:: read( file2) ?) ;
100+ assert_eq ! (
101+ fs:: read( file1) ?,
102+ fs:: read( file2) ?,
103+ "Testing if the contents of {} and {} are the same" ,
104+ file1. display( ) ,
105+ file2. display( ) ,
106+ ) ;
74107 #[ cfg( unix) ]
75108 assert_eq ! (
76109 fs:: symlink_metadata( file1) ?. mode( ) & 0b111 << 6 ,
77- fs:: symlink_metadata( file2) ?. mode( ) & 0b111 << 6
110+ fs:: symlink_metadata( file2) ?. mode( ) & 0b111 << 6 ,
111+ "Testing if the permissions of {} and {} are the same" ,
112+ file1. display( ) ,
113+ file2. display( ) ,
78114 ) ;
79115 }
80116 }
0 commit comments