Skip to content

Commit a499369

Browse files
committed
fix: skip fallback header_contents tests on clang 9
clang 9's clang_Cursor_Evaluate returns CXEval_UnExposed instead of CXEval_Int for macro-expanded expressions loaded through a PCH, so clang_macro_fallback produces no constants on that version. The existing header-based fallback tests already handle this with clang-9-specific empty expectation files; apply the same pattern to the new inline tests by skipping when libclang 9 is detected.
1 parent cf7c69e commit a499369

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

bindgen-tests/tests/tests.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,8 +617,18 @@ fn test_macro_fallback_non_system_dir() {
617617
}
618618
}
619619

620+
/// clang 9's `clang_Cursor_Evaluate` returns `CXEval_UnExposed` instead
621+
/// of `CXEval_Int` for macro-expanded expressions through PCH, so
622+
/// `clang_macro_fallback` produces no constants on that version.
623+
fn clang_fallback_works() -> bool {
624+
!matches!(clang_version().parsed, Some((9, _)))
625+
}
626+
620627
#[test]
621628
fn test_macro_fallback_header_contents() {
629+
if !clang_fallback_works() {
630+
return;
631+
}
622632
let tmpdir = tempfile::tempdir().unwrap();
623633
let actual = builder()
624634
.disable_header_comment()
@@ -647,6 +657,9 @@ fn test_macro_fallback_header_contents() {
647657

648658
#[test]
649659
fn test_macro_fallback_multiple_header_contents() {
660+
if !clang_fallback_works() {
661+
return;
662+
}
650663
let tmpdir = tempfile::tempdir().unwrap();
651664
let actual = builder()
652665
.disable_header_comment()
@@ -675,6 +688,9 @@ fn test_macro_fallback_multiple_header_contents() {
675688

676689
#[test]
677690
fn test_macro_fallback_mixed_header_and_header_contents() {
691+
if !clang_fallback_works() {
692+
return;
693+
}
678694
let tmpdir = tempfile::tempdir().unwrap();
679695
let actual = builder()
680696
.disable_header_comment()
@@ -709,6 +725,9 @@ fn test_macro_fallback_mixed_header_and_header_contents() {
709725

710726
#[test]
711727
fn test_macro_fallback_header_contents_duplicate_basename() {
728+
if !clang_fallback_works() {
729+
return;
730+
}
712731
let tmpdir = tempfile::tempdir().unwrap();
713732
let actual = builder()
714733
.disable_header_comment()
@@ -743,6 +762,9 @@ fn test_macro_fallback_header_contents_duplicate_basename() {
743762

744763
#[test]
745764
fn test_macro_fallback_header_contents_absolute_name() {
765+
if !clang_fallback_works() {
766+
return;
767+
}
746768
// Absolute names must not escape the build dir — they should be
747769
// materialized safely under it, and the original file must not be
748770
// clobbered or deleted.
@@ -788,6 +810,9 @@ fn test_macro_fallback_header_contents_absolute_name() {
788810

789811
#[test]
790812
fn test_macro_fallback_header_contents_parent_dir_escape() {
813+
if !clang_fallback_works() {
814+
return;
815+
}
791816
// Names with ".." must not escape the build dir or delete files
792817
// outside it during FallbackTranslationUnit cleanup.
793818
let tmpdir = tempfile::tempdir().unwrap();
@@ -826,6 +851,9 @@ fn test_macro_fallback_header_contents_parent_dir_escape() {
826851

827852
#[test]
828853
fn test_macro_fallback_cross_target() {
854+
if !clang_fallback_works() {
855+
return;
856+
}
829857
// Subprocess-style test: setting TARGET as an env var in a parallel
830858
// test is not robust, so we re-invoke the test binary as a child
831859
// process with TARGET set to a non-host triple. The child runs the

0 commit comments

Comments
 (0)