| 1 |
// This tests the behavior of -fmodules-validate-once-per-build-session with |
| 2 |
// different combinations of flags and states of the module cache. |
| 3 |
|
| 4 |
// Note: The `sleep 1` commands sprinkled throughout this test make the strict |
| 5 |
// comparisons of epoch mtimes work as expected. Some may be unnecessary, |
| 6 |
// but make the intent clearer. |
| 7 |
|
| 8 |
// RUN: rm -rf %t |
| 9 |
// RUN: split-file %s %t |
| 10 |
// RUN: echo "-fsyntax-only -fmodules -fmodules-cache-path=%/t/module-cache" > %t/ctx.rsp |
| 11 |
// RUN: echo "-fbuild-session-file=%/t/module-cache/session.timestamp" >> %t/ctx.rsp |
| 12 |
// RUN: echo "-fmodules-validate-once-per-build-session" >> %t/ctx.rsp |
| 13 |
// RUN: echo "-Rmodule-build -Rmodule-validation" >> %t/ctx.rsp |
| 14 |
|
| 15 |
//--- include/foo.h |
| 16 |
//--- include/module.modulemap |
| 17 |
module Foo { header "foo.h" } |
| 18 |
|
| 19 |
//--- clean.c |
| 20 |
// Clean module cache. Modules will get compiled regardless of validation settings. |
| 21 |
// RUN: mkdir %t/module-cache |
| 22 |
// RUN: sleep 1 |
| 23 |
// RUN: touch %t/module-cache/session.timestamp |
| 24 |
// RUN: sleep 1 |
| 25 |
// RUN: %clang @%t/ctx.rsp %t/clean.c -DCTX=1 \ |
| 26 |
// RUN: -isystem %t/include -fmodules-validate-system-headers \ |
| 27 |
// RUN: 2>&1 | FileCheck %t/clean.c |
| 28 |
// RUN: %clang @%t/ctx.rsp %t/clean.c -DCTX=2 \ |
| 29 |
// RUN: -I %t/include -fmodules-validate-system-headers \ |
| 30 |
// RUN: 2>&1 | FileCheck %t/clean.c |
| 31 |
// RUN: %clang @%t/ctx.rsp %t/clean.c -DCTX=3 \ |
| 32 |
// RUN: -I %t/include -fmodules-validate-system-headers -Xclang -fno-modules-force-validate-user-headers \ |
| 33 |
// RUN: 2>&1 | FileCheck %t/clean.c |
| 34 |
#include "foo.h" |
| 35 |
// CHECK: building module 'Foo' |
| 36 |
|
| 37 |
//--- no-change-same-session.c |
| 38 |
// Populated module cache in the same build session with unchanged inputs. |
| 39 |
// Validation only happens when it's forced for user headers. No compiles. |
| 40 |
// RUN: sleep 1 |
| 41 |
// RUN: %clang @%t/ctx.rsp %t/no-change-same-session.c -DCTX=1 \ |
| 42 |
// RUN: -isystem %t/include -fmodules-validate-system-headers \ |
| 43 |
// RUN: 2>&1 | FileCheck %t/no-change-same-session.c --check-prefix=CHECK-NO-VALIDATION-OR-BUILD --allow-empty |
| 44 |
// RUN: %clang @%t/ctx.rsp %t/no-change-same-session.c -DCTX=2 \ |
| 45 |
// RUN: -I %t/include -fmodules-validate-system-headers \ |
| 46 |
// RUN: 2>&1 | FileCheck %t/no-change-same-session.c --check-prefix=CHECK-VALIDATION-ONLY |
| 47 |
// RUN: %clang @%t/ctx.rsp %t/no-change-same-session.c -DCTX=3 \ |
| 48 |
// RUN: -I %t/include -fmodules-validate-system-headers -Xclang -fno-modules-force-validate-user-headers \ |
| 49 |
// RUN: 2>&1 | FileCheck %t/no-change-same-session.c --check-prefix=CHECK-NO-VALIDATION-OR-BUILD --allow-empty |
| 50 |
#include "foo.h" |
| 51 |
// CHECK-NO-VALIDATION-OR-BUILD-NOT: validating {{[0-9]+}} input files in module 'Foo' |
| 52 |
// CHECK-NO-VALIDATION-OR-BUILD-NOT: building module 'Foo' |
| 53 |
// CHECK-VALIDATION-ONLY: validating {{[0-9]+}} input files in module 'Foo' |
| 54 |
// CHECK-VALIDATION-ONLY-NOT: building module 'Foo' |
| 55 |
|
| 56 |
//--- change-same-session.c |
| 57 |
// Populated module cache in the same build session with changed inputs. |
| 58 |
// Validation only happens when it's forced for user headers and results in compilation. |
| 59 |
// RUN: sleep 1 |
| 60 |
// RUN: touch %t/include/foo.h |
| 61 |
// RUN: sleep 1 |
| 62 |
// RUN: %clang @%t/ctx.rsp %t/change-same-session.c -DCTX=1 \ |
| 63 |
// RUN: -isystem %t/include -fmodules-validate-system-headers \ |
| 64 |
// RUN: 2>&1 | FileCheck %t/change-same-session.c --check-prefix=CHECK-NO-VALIDATION-OR-BUILD --allow-empty |
| 65 |
// RUN: %clang @%t/ctx.rsp %t/change-same-session.c -DCTX=2 \ |
| 66 |
// RUN: -I %t/include -fmodules-validate-system-headers \ |
| 67 |
// RUN: 2>&1 | FileCheck %t/change-same-session.c --check-prefix=CHECK-VALIDATION-AND-BUILD |
| 68 |
// RUN: %clang @%t/ctx.rsp %t/change-same-session.c -DCTX=3 \ |
| 69 |
// RUN: -I %t/include -fmodules-validate-system-headers -Xclang -fno-modules-force-validate-user-headers \ |
| 70 |
// RUN: 2>&1 | FileCheck %t/change-same-session.c --check-prefix=CHECK-NO-VALIDATION-OR-BUILD --allow-empty |
| 71 |
#include "foo.h" |
| 72 |
// CHECK-NO-VALIDATION-OR-BUILD-NOT: validating {{[0-9]+}} input files in module 'Foo' |
| 73 |
// CHECK-NO-VALIDATION-OR-BUILD-NOT: building module 'Foo' |
| 74 |
// CHECK-VALIDATION-AND-BUILD: validating {{[0-9]+}} input files in module 'Foo' |
| 75 |
// CHECK-VALIDATION-AND-BUILD: building module 'Foo' |
| 76 |
|
| 77 |
//--- change-new-session.c |
| 78 |
// Populated module cache in a new build session with changed inputs. |
| 79 |
// All configurations validate and recompile. |
| 80 |
// RUN: sleep 1 |
| 81 |
// RUN: touch %t/include/foo.h |
| 82 |
// RUN: sleep 1 |
| 83 |
// RUN: touch %t/module-cache/session.timestamp |
| 84 |
// RUN: sleep 1 |
| 85 |
// RUN: %clang @%t/ctx.rsp %t/change-new-session.c -DCTX=1 \ |
| 86 |
// RUN: -isystem %t/include -fmodules-validate-system-headers \ |
| 87 |
// RUN: 2>&1 | FileCheck %t/change-new-session.c --check-prefixes=CHECK,CHECK-VALIDATE-ONCE |
| 88 |
// NOTE: Forced user headers validation causes redundant validation of the just-built module. |
| 89 |
// RUN: %clang @%t/ctx.rsp %t/change-new-session.c -DCTX=2 \ |
| 90 |
// RUN: -I %t/include -fmodules-validate-system-headers \ |
| 91 |
// RUN: 2>&1 | FileCheck %t/change-new-session.c --check-prefixes=CHECK,CHECK-FORCE-VALIDATE-TWICE |
| 92 |
// RUN: %clang @%t/ctx.rsp %t/change-new-session.c -DCTX=3 \ |
| 93 |
// RUN: -I %t/include -fmodules-validate-system-headers -Xclang -fno-modules-force-validate-user-headers \ |
| 94 |
// RUN: 2>&1 | FileCheck %t/change-new-session.c --check-prefixes=CHECK,CHECK-VALIDATE-ONCE |
| 95 |
#include "foo.h" |
| 96 |
// CHECK: validating {{[0-9]+}} input files in module 'Foo' |
| 97 |
// CHECK: building module 'Foo' |
| 98 |
// CHECK-VALIDATE-ONCE-NOT: validating {{[0-9]+}} input files in module 'Foo' |
| 99 |
// CHECK-FORCE-VALIDATE-TWICE: validating {{[0-9]+}} input files in module 'Foo' |
| 100 |
|
| 101 |
//--- no-change-new-session-twice.c |
| 102 |
// Populated module cache in a new build session with unchanged inputs. |
| 103 |
// At first, all configurations validate but don't recompile. |
| 104 |
// RUN: sleep 1 |
| 105 |
// RUN: touch %t/module-cache/session.timestamp |
| 106 |
// RUN: sleep 1 |
| 107 |
// RUN: %clang @%t/ctx.rsp %t/no-change-new-session-twice.c -DCTX=1 \ |
| 108 |
// RUN: -isystem %t/include -fmodules-validate-system-headers \ |
| 109 |
// RUN: 2>&1 | FileCheck %t/no-change-new-session-twice.c --check-prefix=CHECK-ONCE |
| 110 |
// RUN: %clang @%t/ctx.rsp %t/no-change-new-session-twice.c -DCTX=2 \ |
| 111 |
// RUN: -I %t/include -fmodules-validate-system-headers \ |
| 112 |
// RUN: 2>&1 | FileCheck %t/no-change-new-session-twice.c --check-prefix=CHECK-ONCE |
| 113 |
// RUN: %clang @%t/ctx.rsp %t/no-change-new-session-twice.c -DCTX=3 \ |
| 114 |
// RUN: -I %t/include -fmodules-validate-system-headers -Xclang -fno-modules-force-validate-user-headers \ |
| 115 |
// RUN: 2>&1 | FileCheck %t/no-change-new-session-twice.c --check-prefix=CHECK-ONCE |
| 116 |
// |
| 117 |
// Then, only the forced user header validation performs redundant validation (but no compilation). |
| 118 |
// All other configurations do not validate and do not compile. |
| 119 |
// RUN: sleep 1 |
| 120 |
// RUN: %clang @%t/ctx.rsp %t/no-change-new-session-twice.c -DCTX=1 \ |
| 121 |
// RUN: -isystem %t/include -fmodules-validate-system-headers \ |
| 122 |
// RUN: 2>&1 | FileCheck %t/no-change-new-session-twice.c --check-prefix=CHECK-NOT-TWICE --allow-empty |
| 123 |
// NOTE: Forced user headers validation causes redundant validation of the just-validated module. |
| 124 |
// RUN: %clang @%t/ctx.rsp %t/no-change-new-session-twice.c -DCTX=2 \ |
| 125 |
// RUN: -I %t/include -fmodules-validate-system-headers \ |
| 126 |
// RUN: 2>&1 | FileCheck %t/no-change-new-session-twice.c --check-prefix=CHECK-ONCE |
| 127 |
// RUN: %clang @%t/ctx.rsp %t/no-change-new-session-twice.c -DCTX=3 \ |
| 128 |
// RUN: -I %t/include -fmodules-validate-system-headers -Xclang -fno-modules-force-validate-user-headers \ |
| 129 |
// RUN: 2>&1 | FileCheck %t/no-change-new-session-twice.c --check-prefix=CHECK-NOT-TWICE --allow-empty |
| 130 |
#include "foo.h" |
| 131 |
// CHECK-ONCE: validating {{[0-9]+}} input files in module 'Foo' |
| 132 |
// CHECK-ONCE-NOT: building module 'Foo' |
| 133 |
// CHECK-NOT-TWICE-NOT: validating {{[0-9]+}} input files in module 'Foo' |
| 134 |
// CHECK-NOT-TWICE-NOT: building module 'Foo' |