1 | #include "foo.h" |
2 | |
3 | // Clear the module cache. |
4 | // RUN: rm -rf %t |
5 | // RUN: mkdir -p %t/Inputs |
6 | // RUN: mkdir -p %t/modules-to-compare |
7 | |
8 | // === |
9 | // Create a module. We will use -I or -isystem to determine whether to treat |
10 | // foo.h as a system header. |
11 | // RUN: echo 'void meow(void);' > %t/Inputs/foo.h |
12 | // RUN: echo 'module Foo { header "foo.h" }' > %t/Inputs/module.map |
13 | |
14 | // === |
15 | // Compile the module. |
16 | // RUN: %clang_cc1 -cc1 -fmodules -fimplicit-module-maps -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -isystem %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s |
17 | // RUN: %clang_cc1 -cc1 -fmodules -fimplicit-module-maps -fdisable-module-hash -fmodules-cache-path=%t/modules-cache-user -fsyntax-only -I %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s |
18 | // RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp |
19 | // RUN: ls -R %t/modules-cache-user | grep Foo.pcm.timestamp |
20 | // RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-before.pcm |
21 | // RUN: cp %t/modules-cache-user/Foo.pcm %t/modules-to-compare/Foo-before-user.pcm |
22 | |
23 | // === |
24 | // Use it, and make sure that we did not recompile it. |
25 | // RUN: %clang_cc1 -cc1 -fmodules -fimplicit-module-maps -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -isystem %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s |
26 | // RUN: %clang_cc1 -cc1 -fmodules -fimplicit-module-maps -fdisable-module-hash -fmodules-cache-path=%t/modules-cache-user -fsyntax-only -I %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s |
27 | // RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp |
28 | // RUN: ls -R %t/modules-cache-user | grep Foo.pcm.timestamp |
29 | // RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-after.pcm |
30 | // RUN: cp %t/modules-cache-user/Foo.pcm %t/modules-to-compare/Foo-after-user.pcm |
31 | |
32 | // RUN: diff %t/modules-to-compare/Foo-before.pcm %t/modules-to-compare/Foo-after.pcm |
33 | // RUN: diff %t/modules-to-compare/Foo-before-user.pcm %t/modules-to-compare/Foo-after-user.pcm |
34 | |
35 | // === |
36 | // Change the sources. |
37 | // RUN: echo 'void meow2(void);' > %t/Inputs/foo.h |
38 | |
39 | // === |
40 | // Use the module, and make sure that we did not recompile it if foo.h is a |
41 | // system header, even though the sources changed. |
42 | // RUN: %clang_cc1 -cc1 -fmodules -fimplicit-module-maps -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -isystem %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s |
43 | // RUN: %clang_cc1 -cc1 -fmodules -fimplicit-module-maps -fdisable-module-hash -fmodules-cache-path=%t/modules-cache-user -fsyntax-only -I %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s |
44 | // RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp |
45 | // RUN: ls -R %t/modules-cache-user | grep Foo.pcm.timestamp |
46 | // RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-after.pcm |
47 | // RUN: cp %t/modules-cache-user/Foo.pcm %t/modules-to-compare/Foo-after-user.pcm |
48 | |
49 | // RUN: diff %t/modules-to-compare/Foo-before.pcm %t/modules-to-compare/Foo-after.pcm |
50 | // When foo.h is a user header, we will always validate it. |
51 | // RUN: not diff %t/modules-to-compare/Foo-before-user.pcm %t/modules-to-compare/Foo-after-user.pcm |
52 | |
53 | // === |
54 | // Recompile the module if the today's date is before 01 January 2030. |
55 | // RUN: %clang_cc1 -cc1 -fmodules -fimplicit-module-maps -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -isystem %t/Inputs -fbuild-session-timestamp=1893456000 -fmodules-validate-once-per-build-session %s |
56 | // RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp |
57 | // RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-after.pcm |
58 | |
59 | // RUN: not diff %t/modules-to-compare/Foo-before.pcm %t/modules-to-compare/Foo-after.pcm |
60 | |