blob: 7bc771f7843d580659e58cbe9882cdee173f9410 [file] [log] [blame]
Douglas Gregord44d2872013-03-25 21:19:16 +00001// Test the automatic pruning of module cache entries.
2#ifdef IMPORT_DEPENDS_ON_MODULE
3@import DependsOnModule;
4#else
5@import Module;
6#endif
7
8// We need 'touch' and 'find' for this test to work.
9// REQUIRES: shell
10
11// Clear out the module cache
12// RUN: rm -rf %t
13// Run Clang twice so we end up creating the timestamp file (the second time).
14// RUN: %clang_cc1 -DIMPORT_DEPENDS_ON_MODULE -fmodules-ignore-macro=DIMPORT_DEPENDS_ON_MODULE -fmodules -F %S/Inputs -fmodules-cache-path=%t %s -verify
15// RUN: %clang_cc1 -DIMPORT_DEPENDS_ON_MODULE -fmodules-ignore-macro=DIMPORT_DEPENDS_ON_MODULE -fmodules -F %S/Inputs -fmodules-cache-path=%t %s -verify
16// RUN: ls %t | grep modules.timestamp
Stephen Hines6bcf27b2014-05-29 04:14:42 -070017// RUN: ls -R %t | grep ^Module.*pcm
18// RUN: ls -R %t | grep DependsOnModule.*pcm
Douglas Gregord44d2872013-03-25 21:19:16 +000019
20// Set the timestamp back more than two days. We should try to prune,
21// but nothing gets pruned because the module files are new enough.
Douglas Gregor5dca66c2013-03-25 21:27:57 +000022// RUN: touch -m -a -t 201101010000 %t/modules.timestamp
Douglas Gregord44d2872013-03-25 21:19:16 +000023// RUN: %clang_cc1 -fmodules -F %S/Inputs -fmodules-cache-path=%t -fmodules -fmodules-prune-interval=172800 -fmodules-prune-after=345600 %s -verify
24// RUN: ls %t | grep modules.timestamp
Stephen Hines6bcf27b2014-05-29 04:14:42 -070025// RUN: ls -R %t | grep ^Module.*pcm
26// RUN: ls -R %t | grep DependsOnModule.*pcm
Douglas Gregord44d2872013-03-25 21:19:16 +000027
28// Set the DependsOnModule access time back more than four days.
29// This shouldn't prune anything, because the timestamp has been updated, so
30// the pruning mechanism won't fire.
Stephen Hines6bcf27b2014-05-29 04:14:42 -070031// RUN: find %t -name DependsOnModule*.pcm | xargs touch -a -t 201101010000
Douglas Gregord44d2872013-03-25 21:19:16 +000032// RUN: %clang_cc1 -fmodules -F %S/Inputs -fmodules-cache-path=%t -fmodules -fmodules-prune-interval=172800 -fmodules-prune-after=345600 %s -verify
33// RUN: ls %t | grep modules.timestamp
Stephen Hines6bcf27b2014-05-29 04:14:42 -070034// RUN: ls -R %t | grep ^Module.*pcm
35// RUN: ls -R %t | grep DependsOnModule.*pcm
Douglas Gregord44d2872013-03-25 21:19:16 +000036
37// Set both timestamp and DependsOnModule.pcm back beyond the cutoff.
38// This should trigger pruning, which will remove DependsOnModule but not Module.
Douglas Gregor5dca66c2013-03-25 21:27:57 +000039// RUN: touch -m -a -t 201101010000 %t/modules.timestamp
Stephen Hines6bcf27b2014-05-29 04:14:42 -070040// RUN: find %t -name DependsOnModule*.pcm | xargs touch -a -t 201101010000
Douglas Gregord44d2872013-03-25 21:19:16 +000041// RUN: %clang_cc1 -fmodules -F %S/Inputs -fmodules-cache-path=%t -fmodules -fmodules-prune-interval=172800 -fmodules-prune-after=345600 %s -verify
42// RUN: ls %t | grep modules.timestamp
Stephen Hines6bcf27b2014-05-29 04:14:42 -070043// RUN: ls -R %t | grep ^Module.*pcm
44// RUN: ls -R %t | not grep DependsOnModule.*pcm
Douglas Gregord44d2872013-03-25 21:19:16 +000045
46// expected-no-diagnostics