Commit adc0ee8 1 parent c7c9e0a commit adc0ee8 Copy full SHA for adc0ee8
File tree 2 files changed +47
-36
lines changed
2 files changed +47
-36
lines changed Original file line number Diff line number Diff line change @@ -102,45 +102,9 @@ pub fn strict_hash_verification(enabled: bool) {
102
102
#[ cfg( test) ]
103
103
mod test {
104
104
use super :: * ;
105
- use std:: env:: join_paths;
106
105
107
106
#[ test]
108
107
fn smoke ( ) {
109
108
strict_hash_verification ( false ) ;
110
109
}
111
-
112
- #[ test]
113
- fn search_path ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
114
- let path = "fake_path" ;
115
- let original = unsafe { get_search_path ( ConfigLevel :: Global ) } ;
116
- assert_ne ! ( original, Ok ( path. into_c_string( ) ?) ) ;
117
-
118
- // Set
119
- unsafe {
120
- set_search_path ( ConfigLevel :: Global , & path) ?;
121
- }
122
- assert_eq ! (
123
- unsafe { get_search_path( ConfigLevel :: Global ) } ,
124
- Ok ( path. into_c_string( ) ?)
125
- ) ;
126
-
127
- // Append
128
- let paths = join_paths ( [ "$PATH" , path] . iter ( ) ) ?;
129
- let expected_paths = join_paths ( [ path, path] . iter ( ) ) ?. into_c_string ( ) ?;
130
- unsafe {
131
- set_search_path ( ConfigLevel :: Global , paths) ?;
132
- }
133
- assert_eq ! (
134
- unsafe { get_search_path( ConfigLevel :: Global ) } ,
135
- Ok ( expected_paths)
136
- ) ;
137
-
138
- // Reset
139
- unsafe {
140
- reset_search_path ( ConfigLevel :: Global ) ?;
141
- }
142
- assert_eq ! ( unsafe { get_search_path( ConfigLevel :: Global ) } , original) ;
143
-
144
- Ok ( ( ) )
145
- }
146
110
}
Original file line number Diff line number Diff line change
1
+ //! Test for some global state set up by libgit2's `git_libgit2_init` function
2
+ //! that need to be synchronized within a single process.
3
+
4
+ use git2:: opts;
5
+ use git2:: { ConfigLevel , IntoCString } ;
6
+
7
+ // Test for mutating configuration file search path which is set during
8
+ // initialization in libgit2's `git_sysdir_global_init` function.
9
+ #[ test]
10
+ fn search_path ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
11
+ use std:: env:: join_paths;
12
+
13
+ let path = "fake_path" ;
14
+ let original = unsafe { opts:: get_search_path ( ConfigLevel :: Global ) } ;
15
+ assert_ne ! ( original, Ok ( path. into_c_string( ) ?) ) ;
16
+
17
+ // Set
18
+ unsafe {
19
+ opts:: set_search_path ( ConfigLevel :: Global , & path) ?;
20
+ }
21
+ assert_eq ! (
22
+ unsafe { opts:: get_search_path( ConfigLevel :: Global ) } ,
23
+ Ok ( path. into_c_string( ) ?)
24
+ ) ;
25
+
26
+ // Append
27
+ let paths = join_paths ( [ "$PATH" , path] . iter ( ) ) ?;
28
+ let expected_paths = join_paths ( [ path, path] . iter ( ) ) ?. into_c_string ( ) ?;
29
+ unsafe {
30
+ opts:: set_search_path ( ConfigLevel :: Global , paths) ?;
31
+ }
32
+ assert_eq ! (
33
+ unsafe { opts:: get_search_path( ConfigLevel :: Global ) } ,
34
+ Ok ( expected_paths)
35
+ ) ;
36
+
37
+ // Reset
38
+ unsafe {
39
+ opts:: reset_search_path ( ConfigLevel :: Global ) ?;
40
+ }
41
+ assert_eq ! (
42
+ unsafe { opts:: get_search_path( ConfigLevel :: Global ) } ,
43
+ original
44
+ ) ;
45
+
46
+ Ok ( ( ) )
47
+ }
You can’t perform that action at this time.
0 commit comments