From 242b24c1849165bedb73fb14c8012d1d63ffd344 Mon Sep 17 00:00:00 2001 From: Jan Svoboda Date: Mon, 7 Mar 2022 10:21:30 +0100 Subject: [PATCH] [clang][modules] NFC: Simplify and clarify test This patch simplifies a test that checks only used module map files are reported as input files in PCM files. Instead of using opaque `diff`, this patch uses `clang -module-file-info` and `FileCheck` to verify this. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D120463 --- .../AddRemoveIrrelevantModuleMap/a.modulemap | 1 - .../AddRemoveIrrelevantModuleMap/b.modulemap | 1 - .../Modules/add-remove-irrelevant-module-map.m | 36 +++++++++++++++------- 3 files changed, 25 insertions(+), 13 deletions(-) delete mode 100644 clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/a.modulemap delete mode 100644 clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/b.modulemap diff --git a/clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/a.modulemap b/clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/a.modulemap deleted file mode 100644 index bf7200f..0000000 --- a/clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/a.modulemap +++ /dev/null @@ -1 +0,0 @@ -module a { } diff --git a/clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/b.modulemap b/clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/b.modulemap deleted file mode 100644 index f22b754..0000000 --- a/clang/test/Modules/Inputs/AddRemoveIrrelevantModuleMap/b.modulemap +++ /dev/null @@ -1 +0,0 @@ -module b { } diff --git a/clang/test/Modules/add-remove-irrelevant-module-map.m b/clang/test/Modules/add-remove-irrelevant-module-map.m index 3341d89..c7ee077 100644 --- a/clang/test/Modules/add-remove-irrelevant-module-map.m +++ b/clang/test/Modules/add-remove-irrelevant-module-map.m @@ -1,16 +1,30 @@ -// RUN: rm -rf %t -// RUN: rm -rf %t.mcp -// RUN: mkdir -p %t +// RUN: rm -rf %t && mkdir %t +// RUN: split-file %s %t -// Build without b.modulemap -// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t.mcp -fdisable-module-hash -fmodule-map-file=%S/Inputs/AddRemoveIrrelevantModuleMap/a.modulemap %s -verify -// RUN: cp %t.mcp/a.pcm %t/a.pcm +//--- a.modulemap +module a {} -// Build with b.modulemap -// RUN: rm -rf %t.mcp -// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t.mcp -fdisable-module-hash -fmodule-map-file=%S/Inputs/AddRemoveIrrelevantModuleMap/a.modulemap -fmodule-map-file=%S/Inputs/AddRemoveIrrelevantModuleMap/b.modulemap %s -verify -// RUN: not diff %t.mcp/a.pcm %t/a.pcm +//--- b.modulemap +module b {} +//--- test-simple.m // expected-no-diagnostics - @import a; + +// Build without b.modulemap: +// +// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache -fdisable-module-hash \ +// RUN: -fmodule-map-file=%t/a.modulemap %t/test-simple.m -verify +// RUN: mv %t/cache %t/cache-without-b + +// Build with b.modulemap: +// +// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache -fdisable-module-hash \ +// RUN: -fmodule-map-file=%t/a.modulemap -fmodule-map-file=%t/b.modulemap %t/test-simple.m -verify +// RUN: mv %t/cache %t/cache-with-b + +// Neither PCM file considers 'b.modulemap' an input: +// +// RUN: %clang_cc1 -module-file-info %t/cache-without-b/a.pcm | FileCheck %s +// RUN: %clang_cc1 -module-file-info %t/cache-with-b/a.pcm | FileCheck %s +// CHECK-NOT: Input file: {{.*}}/b.modulemap -- 2.7.4