1
- use crate :: { dir_structure, fixture_path, Result } ;
1
+ use crate :: { dir_structure, fixture_path} ;
2
2
use git_object:: bstr:: ByteSlice ;
3
3
use git_odb:: FindExt ;
4
4
use git_worktree:: { copy_index, Options } ;
@@ -8,7 +8,7 @@ use std::fs;
8
8
use std:: os:: unix:: prelude:: MetadataExt ;
9
9
10
10
#[ test]
11
- fn test_copy_index ( ) -> Result < ( ) > {
11
+ fn test_copy_index ( ) -> crate :: Result < ( ) > {
12
12
let path = fixture_path ( "make_repo" ) ;
13
13
let path_git = path. join ( ".git" ) ;
14
14
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<()> {
28
28
29
29
let srepo_files: Vec < _ > = repo_files. iter ( ) . flat_map ( |p| p. strip_prefix ( & path) ) . collect ( ) ;
30
30
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
+ ) ;
32
38
33
39
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
+ ) ;
35
47
#[ cfg( unix) ]
36
48
assert_eq ! (
37
49
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( ) ,
39
54
) ;
40
55
}
41
56
42
57
Ok ( ( ) )
43
58
}
44
59
45
60
#[ test]
46
- fn test_copy_index_without_symlinks ( ) -> Result < ( ) > {
61
+ fn test_copy_index_without_symlinks ( ) -> crate :: Result < ( ) > {
47
62
let path = fixture_path ( "make_repo" ) ;
48
63
let path_git = path. join ( ".git" ) ;
49
64
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<()> {
63
78
64
79
let srepo_files: Vec < _ > = repo_files. iter ( ) . flat_map ( |p| p. strip_prefix ( & path) ) . collect ( ) ;
65
80
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
+ ) ;
67
88
68
89
for ( file1, file2) in repo_files. iter ( ) . zip ( copy_files. iter ( ) ) {
69
90
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
+ ) ;
72
99
} 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
+ ) ;
74
107
#[ cfg( unix) ]
75
108
assert_eq ! (
76
109
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( ) ,
78
114
) ;
79
115
}
80
116
}
0 commit comments