From d835b7c009f95221f94e1c6af11116ca2048bd85 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Tue, 18 Nov 2025 13:28:19 +1100 Subject: [PATCH] Add some tests for `//@ ignore-elf` and `//@ only-elf` --- src/tools/compiletest/src/directives/tests.rs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/tools/compiletest/src/directives/tests.rs b/src/tools/compiletest/src/directives/tests.rs index 649dc8570341..bb8002de391e 100644 --- a/src/tools/compiletest/src/directives/tests.rs +++ b/src/tools/compiletest/src/directives/tests.rs @@ -766,6 +766,29 @@ fn ignore_coverage() { assert!(check_ignore(&config, "//@ ignore-coverage-run")); } +#[test] +fn only_ignore_elf() { + let cases = &[ + ("aarch64-apple-darwin", false), + ("aarch64-unknown-linux-gnu", true), + ("powerpc64-ibm-aix", false), + ("wasm32-unknown-unknown", false), + ("wasm32-wasip1", false), + ("x86_64-apple-darwin", false), + ("x86_64-pc-windows-msvc", false), + ("x86_64-unknown-freebsd", true), + ("x86_64-unknown-illumos", true), + ("x86_64-unknown-linux-gnu", true), + ("x86_64-unknown-none", true), + ("x86_64-unknown-uefi", false), + ]; + for &(target, is_elf) in cases { + let config = &cfg().target(target).build(); + assert_eq!(is_elf, check_ignore(config, "//@ ignore-elf"), "`//@ ignore-elf` for {target}"); + assert_eq!(is_elf, !check_ignore(config, "//@ only-elf"), "`//@ only-elf` for {target}"); + } +} + #[test] fn threads_support() { let threads = [