Dmitri Gribenko | fdd4f30 | 2014-02-12 10:40:07 +0000 | [diff] [blame] | 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 | // === |
Ben Langmuir | acb803e | 2014-11-10 22:13:10 +0000 | [diff] [blame] | 9 | // Create a module. We will use -I or -isystem to determine whether to treat |
| 10 | // foo.h as a system header. |
Dmitri Gribenko | fdd4f30 | 2014-02-12 10:40:07 +0000 | [diff] [blame] | 11 | // RUN: echo 'void meow(void);' > %t/Inputs/foo.h |
Ben Langmuir | acb803e | 2014-11-10 22:13:10 +0000 | [diff] [blame] | 12 | // RUN: echo 'module Foo { header "foo.h" }' > %t/Inputs/module.map |
Dmitri Gribenko | fdd4f30 | 2014-02-12 10:40:07 +0000 | [diff] [blame] | 13 | |
| 14 | // === |
| 15 | // Compile the module. |
Richard Smith | 47972af | 2015-06-16 00:08:24 +0000 | [diff] [blame] | 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 |
Dmitri Gribenko | fdd4f30 | 2014-02-12 10:40:07 +0000 | [diff] [blame] | 18 | // RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp |
Ben Langmuir | acb803e | 2014-11-10 22:13:10 +0000 | [diff] [blame] | 19 | // RUN: ls -R %t/modules-cache-user | grep Foo.pcm.timestamp |
Dmitri Gribenko | fdd4f30 | 2014-02-12 10:40:07 +0000 | [diff] [blame] | 20 | // RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-before.pcm |
Ben Langmuir | acb803e | 2014-11-10 22:13:10 +0000 | [diff] [blame] | 21 | // RUN: cp %t/modules-cache-user/Foo.pcm %t/modules-to-compare/Foo-before-user.pcm |
Dmitri Gribenko | fdd4f30 | 2014-02-12 10:40:07 +0000 | [diff] [blame] | 22 | |
| 23 | // === |
| 24 | // Use it, and make sure that we did not recompile it. |
Richard Smith | 47972af | 2015-06-16 00:08:24 +0000 | [diff] [blame] | 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 |
Dmitri Gribenko | fdd4f30 | 2014-02-12 10:40:07 +0000 | [diff] [blame] | 27 | // RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp |
Ben Langmuir | acb803e | 2014-11-10 22:13:10 +0000 | [diff] [blame] | 28 | // RUN: ls -R %t/modules-cache-user | grep Foo.pcm.timestamp |
Dmitri Gribenko | e7f8cba | 2014-02-12 11:50:37 +0000 | [diff] [blame] | 29 | // RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-after.pcm |
Ben Langmuir | acb803e | 2014-11-10 22:13:10 +0000 | [diff] [blame] | 30 | // RUN: cp %t/modules-cache-user/Foo.pcm %t/modules-to-compare/Foo-after-user.pcm |
Dmitri Gribenko | fdd4f30 | 2014-02-12 10:40:07 +0000 | [diff] [blame] | 31 | |
| 32 | // RUN: diff %t/modules-to-compare/Foo-before.pcm %t/modules-to-compare/Foo-after.pcm |
Ben Langmuir | acb803e | 2014-11-10 22:13:10 +0000 | [diff] [blame] | 33 | // RUN: diff %t/modules-to-compare/Foo-before-user.pcm %t/modules-to-compare/Foo-after-user.pcm |
Dmitri Gribenko | fdd4f30 | 2014-02-12 10:40:07 +0000 | [diff] [blame] | 34 | |
| 35 | // === |
| 36 | // Change the sources. |
| 37 | // RUN: echo 'void meow2(void);' > %t/Inputs/foo.h |
| 38 | |
| 39 | // === |
Ben Langmuir | acb803e | 2014-11-10 22:13:10 +0000 | [diff] [blame] | 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. |
Richard Smith | 47972af | 2015-06-16 00:08:24 +0000 | [diff] [blame] | 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 |
Dmitri Gribenko | fdd4f30 | 2014-02-12 10:40:07 +0000 | [diff] [blame] | 44 | // RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp |
Ben Langmuir | acb803e | 2014-11-10 22:13:10 +0000 | [diff] [blame] | 45 | // RUN: ls -R %t/modules-cache-user | grep Foo.pcm.timestamp |
Dmitri Gribenko | e7f8cba | 2014-02-12 11:50:37 +0000 | [diff] [blame] | 46 | // RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-after.pcm |
Ben Langmuir | acb803e | 2014-11-10 22:13:10 +0000 | [diff] [blame] | 47 | // RUN: cp %t/modules-cache-user/Foo.pcm %t/modules-to-compare/Foo-after-user.pcm |
Dmitri Gribenko | fdd4f30 | 2014-02-12 10:40:07 +0000 | [diff] [blame] | 48 | |
| 49 | // RUN: diff %t/modules-to-compare/Foo-before.pcm %t/modules-to-compare/Foo-after.pcm |
Ben Langmuir | acb803e | 2014-11-10 22:13:10 +0000 | [diff] [blame] | 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 |
Dmitri Gribenko | fdd4f30 | 2014-02-12 10:40:07 +0000 | [diff] [blame] | 52 | |
| 53 | // === |
| 54 | // Recompile the module if the today's date is before 01 January 2030. |
Richard Smith | 47972af | 2015-06-16 00:08:24 +0000 | [diff] [blame] | 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 |
Dmitri Gribenko | fdd4f30 | 2014-02-12 10:40:07 +0000 | [diff] [blame] | 56 | // RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp |
Dmitri Gribenko | e7f8cba | 2014-02-12 11:50:37 +0000 | [diff] [blame] | 57 | // RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-after.pcm |
Dmitri Gribenko | fdd4f30 | 2014-02-12 10:40:07 +0000 | [diff] [blame] | 58 | |
| 59 | // RUN: not diff %t/modules-to-compare/Foo-before.pcm %t/modules-to-compare/Foo-after.pcm |