From 98a71766b8b6ece6fabb8429e5fe53805ba28b78 Mon Sep 17 00:00:00 2001 From: Kirill Podoprigora Date: Wed, 13 Nov 2024 15:05:31 +0200 Subject: [PATCH 1/2] Add ``exact-llvm-major-version`` directive --- src/tools/compiletest/src/directive-list.rs | 1 + src/tools/compiletest/src/header.rs | 13 +++++++++++++ src/tools/compiletest/src/header/tests.rs | 9 +++++++++ tests/codegen/try_question_mark_nop.rs | 3 +-- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/tools/compiletest/src/directive-list.rs b/src/tools/compiletest/src/directive-list.rs index 4a102f0c2cbed..038de9036bf98 100644 --- a/src/tools/compiletest/src/directive-list.rs +++ b/src/tools/compiletest/src/directive-list.rs @@ -25,6 +25,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[ "dont-check-failure-status", "edition", "error-pattern", + "exact-llvm-major-version", "exec-env", "failure-status", "filecheck-flags", diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 300a03e5f3377..5b198c3e60b24 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -1585,6 +1585,19 @@ fn ignore_llvm(config: &Config, line: &str) -> IgnoreDecision { }; } } + } else if let Some(version_string) = + config.parse_name_value_directive(line, "exact-llvm-major-version") + { + // Syntax is "only-llvm-major-version: " + let version = extract_llvm_version(&version_string); + if actual_version.major > version.major || actual_version.major < version.major { + return IgnoreDecision::Ignore { + reason: format!( + "ignored when the LLVM major version is {}, but it should be {}", + actual_version.major, version.major + ), + }; + } } } IgnoreDecision::Continue diff --git a/src/tools/compiletest/src/header/tests.rs b/src/tools/compiletest/src/header/tests.rs index c3fb8d4ab8019..1eca48c1c3a83 100644 --- a/src/tools/compiletest/src/header/tests.rs +++ b/src/tools/compiletest/src/header/tests.rs @@ -284,6 +284,15 @@ fn llvm_version() { let config: Config = cfg().llvm_version("10.0.0").build(); assert!(!check_ignore(&config, "//@ min-llvm-version: 9.0")); + + let config: Config = cfg().llvm_version("10.0.0").build(); + assert!(check_ignore(&config, "//@ exact-llvm-major-version: 9.0")); + + let config: Config = cfg().llvm_version("9.0.0").build(); + assert!(check_ignore(&config, "//@ exact-llvm-major-version: 10.0")); + + let config: Config = cfg().llvm_version("10.0.0").build(); + assert!(!check_ignore(&config, "//@ exact-llvm-major-version: 10.0")); } #[test] diff --git a/tests/codegen/try_question_mark_nop.rs b/tests/codegen/try_question_mark_nop.rs index b68ecce869e42..36a0d9066c895 100644 --- a/tests/codegen/try_question_mark_nop.rs +++ b/tests/codegen/try_question_mark_nop.rs @@ -2,8 +2,7 @@ //@ only-x86_64 // FIXME: Remove the `min-llvm-version`. //@ revisions: NINETEEN TWENTY -//@[NINETEEN] min-llvm-version: 19 -//@[NINETEEN] ignore-llvm-version: 20-99 +//@[NINETEEN] exact-llvm-major-version: 19 //@[TWENTY] min-llvm-version: 20 //@ min-llvm-version: 19 From 81f61058519a408ca8d55e87435f092cc967de8b Mon Sep 17 00:00:00 2001 From: Kirill Podoprigora Date: Wed, 13 Nov 2024 15:31:07 +0200 Subject: [PATCH 2/2] Address review --- src/tools/compiletest/src/header.rs | 6 +++--- src/tools/compiletest/src/header/tests.rs | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 5b198c3e60b24..0e81f675474aa 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -1588,12 +1588,12 @@ fn ignore_llvm(config: &Config, line: &str) -> IgnoreDecision { } else if let Some(version_string) = config.parse_name_value_directive(line, "exact-llvm-major-version") { - // Syntax is "only-llvm-major-version: " + // Syntax is "exact-llvm-major-version: " let version = extract_llvm_version(&version_string); - if actual_version.major > version.major || actual_version.major < version.major { + if actual_version.major != version.major { return IgnoreDecision::Ignore { reason: format!( - "ignored when the LLVM major version is {}, but it should be {}", + "ignored when the actual LLVM major version is {}, but the test only targets major version {}", actual_version.major, version.major ), }; diff --git a/src/tools/compiletest/src/header/tests.rs b/src/tools/compiletest/src/header/tests.rs index 1eca48c1c3a83..6c52a1b950782 100644 --- a/src/tools/compiletest/src/header/tests.rs +++ b/src/tools/compiletest/src/header/tests.rs @@ -293,6 +293,12 @@ fn llvm_version() { let config: Config = cfg().llvm_version("10.0.0").build(); assert!(!check_ignore(&config, "//@ exact-llvm-major-version: 10.0")); + + let config: Config = cfg().llvm_version("10.0.0").build(); + assert!(!check_ignore(&config, "//@ exact-llvm-major-version: 10")); + + let config: Config = cfg().llvm_version("10.6.2").build(); + assert!(!check_ignore(&config, "//@ exact-llvm-major-version: 10")); } #[test]