@@ -6,7 +6,7 @@ use cargo::util::interning::InternedString;
6
6
use cargo:: util:: toml:: { self , VecStringOrBool as VSOB } ;
7
7
use cargo:: CargoResult ;
8
8
use cargo_test_support:: compare;
9
- use cargo_test_support:: { panic_error, paths, project, t} ;
9
+ use cargo_test_support:: { panic_error, paths, project, symlink_supported , t} ;
10
10
use serde:: Deserialize ;
11
11
use std:: borrow:: Borrow ;
12
12
use std:: collections:: { BTreeMap , HashMap } ;
@@ -152,28 +152,6 @@ fn write_config_toml(config: &str) {
152
152
write_config_at ( paths:: root ( ) . join ( ".cargo/config.toml" ) , config) ;
153
153
}
154
154
155
- // Several test fail on windows if the user does not have permission to
156
- // create symlinks (the `SeCreateSymbolicLinkPrivilege`). Instead of
157
- // disabling these test on Windows, use this function to test whether we
158
- // have permission, and return otherwise. This way, we still don't run these
159
- // tests most of the time, but at least we do if the user has the right
160
- // permissions.
161
- // This function is derived from libstd fs tests.
162
- pub fn got_symlink_permission ( ) -> bool {
163
- if cfg ! ( unix) {
164
- return true ;
165
- }
166
- let link = paths:: root ( ) . join ( "some_hopefully_unique_link_name" ) ;
167
- let target = paths:: root ( ) . join ( "nonexisting_target" ) ;
168
-
169
- match symlink_file ( & target, & link) {
170
- Ok ( _) => true ,
171
- // ERROR_PRIVILEGE_NOT_HELD = 1314
172
- Err ( ref err) if err. raw_os_error ( ) == Some ( 1314 ) => false ,
173
- Err ( _) => true ,
174
- }
175
- }
176
-
177
155
#[ cfg( unix) ]
178
156
fn symlink_file ( target : & Path , link : & Path ) -> io:: Result < ( ) > {
179
157
os:: unix:: fs:: symlink ( target, link)
@@ -255,7 +233,7 @@ f1 = 1
255
233
fn config_ambiguous_filename_symlink_doesnt_warn ( ) {
256
234
// Windows requires special permissions to create symlinks.
257
235
// If we don't have permission, just skip this test.
258
- if !got_symlink_permission ( ) {
236
+ if !symlink_supported ( ) {
259
237
return ;
260
238
} ;
261
239
0 commit comments