Skip to content

run-make: add a //@ needs-symlink directive over //@ ignore-windows #127797

Closed
@jieyouxu

Description

@jieyouxu

symlinks are a priviledged operation on Windows, but we should not straight up //@ ignore-windows as the CI runners have symlinks enabled, and so might the contributor on their local Windows machines. Instead, we should try to do what stdlib does here:

// Several test fail on windows if the user does not have permission to
// create symlinks (the `SeCreateSymbolicLinkPrivilege`). Instead of
// disabling these test on Windows, use this function to test whether we
// have permission, and return otherwise. This way, we still don't run these
// tests most of the time, but at least we do if the user has the right
// permissions.
pub fn got_symlink_permission(tmpdir: &TempDir) -> bool {
if cfg!(not(windows)) || env::var_os("CI").is_some() {
return true;
}
let link = tmpdir.join("some_hopefully_unique_link_name");
match symlink_file(r"nonexisting_target", link) {
// ERROR_PRIVILEGE_NOT_HELD = 1314
Err(ref err) if err.raw_os_error() == Some(1314) => false,
Ok(_) | Err(_) => true,
}
}

Thanks to @ChrisDenton for pointing this out to me!

Metadata

Metadata

Assignees

Labels

A-compiletestArea: The compiletest test runnerA-run-makeArea: port run-make Makefiles to rmake.rsA-testsuiteArea: The testsuite used to check the correctness of rustcC-cleanupCategory: PRs that clean code up or issues documenting cleanup.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions