blob: dc552eaabde7be5fff188cfec4eeeaf5692fc745 [file] [log] [blame]
Dmitri Gribenkofdd4f302014-02-12 10:40:07 +00001#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 Langmuiracb803e2014-11-10 22:13:10 +00009// Create a module. We will use -I or -isystem to determine whether to treat
10// foo.h as a system header.
Dmitri Gribenkofdd4f302014-02-12 10:40:07 +000011// RUN: echo 'void meow(void);' > %t/Inputs/foo.h
Ben Langmuiracb803e2014-11-10 22:13:10 +000012// RUN: echo 'module Foo { header "foo.h" }' > %t/Inputs/module.map
Dmitri Gribenkofdd4f302014-02-12 10:40:07 +000013
14// ===
15// Compile the module.
Richard Smith47972af2015-06-16 00:08:24 +000016// 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 Gribenkofdd4f302014-02-12 10:40:07 +000018// RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp
Ben Langmuiracb803e2014-11-10 22:13:10 +000019// RUN: ls -R %t/modules-cache-user | grep Foo.pcm.timestamp
Dmitri Gribenkofdd4f302014-02-12 10:40:07 +000020// RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-before.pcm
Ben Langmuiracb803e2014-11-10 22:13:10 +000021// RUN: cp %t/modules-cache-user/Foo.pcm %t/modules-to-compare/Foo-before-user.pcm
Dmitri Gribenkofdd4f302014-02-12 10:40:07 +000022
23// ===
24// Use it, and make sure that we did not recompile it.
Richard Smith47972af2015-06-16 00:08:24 +000025// 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 Gribenkofdd4f302014-02-12 10:40:07 +000027// RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp
Ben Langmuiracb803e2014-11-10 22:13:10 +000028// RUN: ls -R %t/modules-cache-user | grep Foo.pcm.timestamp
Dmitri Gribenkoe7f8cba2014-02-12 11:50:37 +000029// RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-after.pcm
Ben Langmuiracb803e2014-11-10 22:13:10 +000030// RUN: cp %t/modules-cache-user/Foo.pcm %t/modules-to-compare/Foo-after-user.pcm
Dmitri Gribenkofdd4f302014-02-12 10:40:07 +000031
32// RUN: diff %t/modules-to-compare/Foo-before.pcm %t/modules-to-compare/Foo-after.pcm
Ben Langmuiracb803e2014-11-10 22:13:10 +000033// RUN: diff %t/modules-to-compare/Foo-before-user.pcm %t/modules-to-compare/Foo-after-user.pcm
Dmitri Gribenkofdd4f302014-02-12 10:40:07 +000034
35// ===
36// Change the sources.
37// RUN: echo 'void meow2(void);' > %t/Inputs/foo.h
38
39// ===
Ben Langmuiracb803e2014-11-10 22:13:10 +000040// 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 Smith47972af2015-06-16 00:08:24 +000042// 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 Gribenkofdd4f302014-02-12 10:40:07 +000044// RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp
Ben Langmuiracb803e2014-11-10 22:13:10 +000045// RUN: ls -R %t/modules-cache-user | grep Foo.pcm.timestamp
Dmitri Gribenkoe7f8cba2014-02-12 11:50:37 +000046// RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-after.pcm
Ben Langmuiracb803e2014-11-10 22:13:10 +000047// RUN: cp %t/modules-cache-user/Foo.pcm %t/modules-to-compare/Foo-after-user.pcm
Dmitri Gribenkofdd4f302014-02-12 10:40:07 +000048
49// RUN: diff %t/modules-to-compare/Foo-before.pcm %t/modules-to-compare/Foo-after.pcm
Ben Langmuiracb803e2014-11-10 22:13:10 +000050// 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 Gribenkofdd4f302014-02-12 10:40:07 +000052
53// ===
54// Recompile the module if the today's date is before 01 January 2030.
Richard Smith47972af2015-06-16 00:08:24 +000055// 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 Gribenkofdd4f302014-02-12 10:40:07 +000056// RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp
Dmitri Gribenkoe7f8cba2014-02-12 11:50:37 +000057// RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-after.pcm
Dmitri Gribenkofdd4f302014-02-12 10:40:07 +000058
59// RUN: not diff %t/modules-to-compare/Foo-before.pcm %t/modules-to-compare/Foo-after.pcm