diff options
| author | Chris Denton <chris@chrisdenton.dev> | 2024-06-23 13:42:52 +0000 |
|---|---|---|
| committer | Chris Denton <chris@chrisdenton.dev> | 2024-06-23 13:42:52 +0000 |
| commit | b8a003035887586eb180b2618cc9891f8f913678 (patch) | |
| tree | 45b0da1b486cd09b2be910e4e32b584ff6e1ee54 /src/tools/compiletest | |
| parent | 25c9f2ca06d6d8d5f314362ffd17e71a8df55546 (diff) | |
| download | rust-b8a003035887586eb180b2618cc9891f8f913678.tar.gz rust-b8a003035887586eb180b2618cc9891f8f913678.zip | |
Add need-symlink directive to compiletest
Diffstat (limited to 'src/tools/compiletest')
| -rw-r--r-- | src/tools/compiletest/src/header.rs | 1 | ||||
| -rw-r--r-- | src/tools/compiletest/src/header/needs.rs | 26 |
2 files changed, 27 insertions, 0 deletions
diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 5469b9f1a0a..0a618ef990e 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -875,6 +875,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[ "needs-sanitizer-shadow-call-stack", "needs-sanitizer-support", "needs-sanitizer-thread", + "needs-symlink", "needs-threads", "needs-unwind", "needs-wasmtime", diff --git a/src/tools/compiletest/src/header/needs.rs b/src/tools/compiletest/src/header/needs.rs index b96832db67b..5b2665f7d0b 100644 --- a/src/tools/compiletest/src/header/needs.rs +++ b/src/tools/compiletest/src/header/needs.rs @@ -144,6 +144,11 @@ pub(super) fn handle_needs( condition: config.runner.as_ref().is_some_and(|r| r.contains("wasmtime")), ignore_reason: "ignored when wasmtime runner is not available", }, + Need { + name: "needs-symlink", + condition: cache.symlinks, + ignore_reason: "ignored if symlinks are unavailable", + }, ]; let (name, comment) = match ln.split_once([':', ' ']) { @@ -209,6 +214,7 @@ pub(super) struct CachedNeedsConditions { xray: bool, rust_lld: bool, dlltool: bool, + symlinks: bool, } impl CachedNeedsConditions { @@ -253,6 +259,7 @@ impl CachedNeedsConditions { .exists(), dlltool: find_dlltool(&config), + symlinks: has_symlinks(), } } } @@ -279,3 +286,22 @@ fn find_dlltool(config: &Config) -> bool { }; dlltool_found } + +#[cfg(windows)] +fn has_symlinks() -> bool { + if std::env::var_os("CI").is_some() { + return true; + } + let link = std::env::temp_dir().join("RUST_COMPILETEST_SYMLINK_CHECK"); + if std::os::windows::fs::symlink_file("DOES NOT EXIST", &link).is_ok() { + std::fs::remove_file(&link).unwrap(); + true + } else { + false + } +} + +#[cfg(not(windows))] +fn has_symlinks() -> bool { + true +} |
