From f1736f7a2a660944c24aac45e24cdf1ea6c6effa Mon Sep 17 00:00:00 2001 From: Paula Toth Date: Wed, 11 Mar 2020 12:12:35 -0700 Subject: [PATCH] [clang-tidy] Mock system headers for portability-restrict-system-includes tests. Summary: Didn't realize that headers such as stddef.h may not exist on all systems. This patch mocks the headers so that the check's tests work on all systems. (: Reviewers: RKSimon, aaron.ballman Reviewed By: aaron.ballman Subscribers: xazax.hun, cfe-commits Tags: #clang-tools-extra, #clang Differential Revision: https://reviews.llvm.org/D76015 --- .../portability-restrict-system-includes/{a.h => system/float.h} | 0 .../checkers/Inputs/portability-restrict-system-includes/system/j.h | 0 .../system/{cstdarg.h => stddef.h} | 0 .../system/{cstdlib.h => stdint.h} | 0 .../clang-tidy/checkers/portability-restrict-system-includes-allow.cpp | 3 ++- .../checkers/portability-restrict-system-includes-disallow.cpp | 3 ++- .../clang-tidy/checkers/portability-restrict-system-includes-glob.cpp | 3 ++- 7 files changed, 6 insertions(+), 3 deletions(-) rename clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/{a.h => system/float.h} (100%) delete mode 100644 clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/j.h rename clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/{cstdarg.h => stddef.h} (100%) rename clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/{cstdlib.h => stdint.h} (100%) diff --git a/clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/a.h b/clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/float.h similarity index 100% rename from clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/a.h rename to clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/float.h diff --git a/clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/j.h b/clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/j.h deleted file mode 100644 index e69de29..0000000 diff --git a/clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/cstdarg.h b/clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/stddef.h similarity index 100% rename from clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/cstdarg.h rename to clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/stddef.h diff --git a/clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/cstdlib.h b/clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/stdint.h similarity index 100% rename from clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/cstdlib.h rename to clang-tools-extra/test/clang-tidy/checkers/Inputs/portability-restrict-system-includes/system/stdint.h diff --git a/clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-allow.cpp b/clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-allow.cpp index e3a9376..a74b94b 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-allow.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-allow.cpp @@ -1,5 +1,6 @@ // RUN: %check_clang_tidy %s portability-restrict-system-includes %t \ -// RUN: -- -config="{CheckOptions: [{key: portability-restrict-system-includes.Includes, value: '*,-stddef.h'}]}" +// RUN: -- -config="{CheckOptions: [{key: portability-restrict-system-includes.Includes, value: '*,-stddef.h'}]}" \ +// RUN: -- -isystem %S/Inputs/portability-restrict-system-includes/system // Test block-list functionality: allow all but stddef.h. diff --git a/clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-disallow.cpp b/clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-disallow.cpp index f73cbbf..1d1e8a4 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-disallow.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-disallow.cpp @@ -1,5 +1,6 @@ // RUN: %check_clang_tidy %s portability-restrict-system-includes %t \ -// RUN: -- -config="{CheckOptions: [{key: portability-restrict-system-includes.Includes, value: '-*,stddef.h'}]}" +// RUN: -- -config="{CheckOptions: [{key: portability-restrict-system-includes.Includes, value: '-*,stddef.h'}]}" \ +// RUN: -- -isystem %S/Inputs/portability-restrict-system-includes/system // Test allow-list functionality: disallow all but stddef.h. diff --git a/clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-glob.cpp b/clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-glob.cpp index bee7ec7..e1cd588 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-glob.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-glob.cpp @@ -1,5 +1,6 @@ // RUN: %check_clang_tidy %s portability-restrict-system-includes %t \ -// RUN: -- -config="{CheckOptions: [{key: portability-restrict-system-includes.Includes, value: '-*,std*.h'}]}" +// RUN: -- -config="{CheckOptions: [{key: portability-restrict-system-includes.Includes, value: '-*,std*.h'}]}" \ +// RUN: -- -isystem %S/Inputs/portability-restrict-system-includes/system // Test glob functionality: disallow all headers except those that match // pattern "std*.h". -- 1.8.3.1