Skip to content

Commit b9f15ab

Browse files
committed
Remove got_symlink_permission, we already have one of those.
1 parent 24b8936 commit b9f15ab

File tree

1 file changed

+2
-24
lines changed

1 file changed

+2
-24
lines changed

tests/testsuite/config.rs

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use cargo::util::interning::InternedString;
66
use cargo::util::toml::{self, VecStringOrBool as VSOB};
77
use cargo::CargoResult;
88
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};
1010
use serde::Deserialize;
1111
use std::borrow::Borrow;
1212
use std::collections::{BTreeMap, HashMap};
@@ -152,28 +152,6 @@ fn write_config_toml(config: &str) {
152152
write_config_at(paths::root().join(".cargo/config.toml"), config);
153153
}
154154

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-
177155
#[cfg(unix)]
178156
fn symlink_file(target: &Path, link: &Path) -> io::Result<()> {
179157
os::unix::fs::symlink(target, link)
@@ -255,7 +233,7 @@ f1 = 1
255233
fn config_ambiguous_filename_symlink_doesnt_warn() {
256234
// Windows requires special permissions to create symlinks.
257235
// If we don't have permission, just skip this test.
258-
if !got_symlink_permission() {
236+
if !symlink_supported() {
259237
return;
260238
};
261239

0 commit comments

Comments
 (0)