xref: /llvm-project/clang/test/ClangScanDeps/modules.cpp (revision b58a420ff4f92b085fd718600fda162059171a58)
19ab6d823SMichael Spencer // RUN: rm -rf %t.dir
29ab6d823SMichael Spencer // RUN: rm -rf %t.cdb
36bb836afSGulfem Savrun Yeniceri // RUN: rm -rf %t_clangcl.cdb
49ab6d823SMichael Spencer // RUN: rm -rf %t.module-cache
56bb836afSGulfem Savrun Yeniceri // RUN: rm -rf %t.module-cache_clangcl
69ab6d823SMichael Spencer // RUN: mkdir -p %t.dir
79ab6d823SMichael Spencer // RUN: cp %s %t.dir/modules_cdb_input.cpp
89ab6d823SMichael Spencer // RUN: cp %s %t.dir/modules_cdb_input2.cpp
99ab6d823SMichael Spencer // RUN: mkdir %t.dir/Inputs
109ab6d823SMichael Spencer // RUN: cp %S/Inputs/header.h %t.dir/Inputs/header.h
119ab6d823SMichael Spencer // RUN: cp %S/Inputs/header2.h %t.dir/Inputs/header2.h
129ab6d823SMichael Spencer // RUN: cp %S/Inputs/module.modulemap %t.dir/Inputs/module.modulemap
139ab6d823SMichael Spencer // RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/modules_cdb.json > %t.cdb
146bb836afSGulfem Savrun Yeniceri // RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/modules_cdb_clangcl.json > %t_clangcl.cdb
159ab6d823SMichael Spencer //
16*b58a420fSArgyrios Kyrtzidis // RUN: clang-scan-deps -compilation-database %t.cdb -j 1 -mode preprocess-dependency-directives | \
179ab6d823SMichael Spencer // RUN:   FileCheck --check-prefixes=CHECK1,CHECK2,CHECK2NO %s
18*b58a420fSArgyrios Kyrtzidis // RUN: clang-scan-deps -compilation-database %t_clangcl.cdb -j 1 -mode preprocess-dependency-directives | \
196bb836afSGulfem Savrun Yeniceri // RUN:   FileCheck --check-prefixes=CHECK1,CHECK2,CHECK2NO %s
209ab6d823SMichael Spencer //
219ab6d823SMichael Spencer // The output order is non-deterministic when using more than one thread,
229ab6d823SMichael Spencer // so check the output using two runs. Note that the 'NOT' check is not used
239ab6d823SMichael Spencer // as it might fail if the results for `modules_cdb_input.cpp` are reported before
249ab6d823SMichael Spencer // `modules_cdb_input2.cpp`.
259ab6d823SMichael Spencer //
26*b58a420fSArgyrios Kyrtzidis // RUN: clang-scan-deps -compilation-database %t.cdb -j 2 -mode preprocess-dependency-directives | \
279ab6d823SMichael Spencer // RUN:   FileCheck --check-prefix=CHECK1 %s
28*b58a420fSArgyrios Kyrtzidis // RUN: clang-scan-deps -compilation-database %t_clangcl.cdb -j 2 -mode preprocess-dependency-directives | \
296bb836afSGulfem Savrun Yeniceri // RUN:   FileCheck --check-prefix=CHECK1 %s
309ab6d823SMichael Spencer // RUN: clang-scan-deps -compilation-database %t.cdb -j 2 -mode preprocess | \
319ab6d823SMichael Spencer // RUN:   FileCheck --check-prefix=CHECK1 %s
326bb836afSGulfem Savrun Yeniceri // RUN: clang-scan-deps -compilation-database %t_clangcl.cdb -j 2 -mode preprocess | \
336bb836afSGulfem Savrun Yeniceri // RUN:   FileCheck --check-prefix=CHECK1 %s
34*b58a420fSArgyrios Kyrtzidis // RUN: clang-scan-deps -compilation-database %t.cdb -j 2 -mode preprocess-dependency-directives | \
359ab6d823SMichael Spencer // RUN:   FileCheck --check-prefix=CHECK2 %s
36*b58a420fSArgyrios Kyrtzidis // RUN: clang-scan-deps -compilation-database %t_clangcl.cdb -j 2 -mode preprocess-dependency-directives | \
376bb836afSGulfem Savrun Yeniceri // RUN:   FileCheck --check-prefix=CHECK2 %s
389ab6d823SMichael Spencer // RUN: clang-scan-deps -compilation-database %t.cdb -j 2 -mode preprocess | \
399ab6d823SMichael Spencer // RUN:   FileCheck --check-prefix=CHECK2 %s
406bb836afSGulfem Savrun Yeniceri // RUN: clang-scan-deps -compilation-database %t_clangcl.cdb -j 2 -mode preprocess | \
416bb836afSGulfem Savrun Yeniceri // RUN:   FileCheck --check-prefix=CHECK2 %s
429ab6d823SMichael Spencer 
439ab6d823SMichael Spencer #include "header.h"
449ab6d823SMichael Spencer 
45d8bab69eSJan Svoboda // CHECK1: modules_cdb_input2.o:
469ab6d823SMichael Spencer // CHECK1-NEXT: modules_cdb_input2.cpp
479ab6d823SMichael Spencer // CHECK1-NEXT: Inputs{{/|\\}}module.modulemap
489ab6d823SMichael Spencer // CHECK1-NEXT: Inputs{{/|\\}}header2.h
499ab6d823SMichael Spencer // CHECK1: Inputs{{/|\\}}header.h
509ab6d823SMichael Spencer 
511d8882b5SJan Svoboda // CHECK2: {{(modules_cdb_input)|(a)|(b)}}.o:
52d8bab69eSJan Svoboda // CHECK2-NEXT: modules_cdb_input.cpp
539ab6d823SMichael Spencer // CHECK2-NEXT: Inputs{{/|\\}}module.modulemap
549ab6d823SMichael Spencer // CHECK2-NEXT: Inputs{{/|\\}}header.h
559ab6d823SMichael Spencer // CHECK2NO-NOT: header2
56