brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.5 KiB · 2348ca1 Raw
135 lines · c
1// This tests the behavior of -fmodules-validate-once-per-build-session with2// different combinations of flags and states of the module cache.3 4// Note: The `sleep 1` commands sprinkled throughout this test make the strict5//       comparisons of epoch mtimes work as expected. Some may be unnecessary,6//       but make the intent clearer.7 8// RUN: rm -rf %t9// RUN: split-file %s %t10// RUN: echo "-fsyntax-only -fmodules -fmodules-cache-path=%/t/module-cache" > %t/ctx.rsp11// RUN: echo "-fbuild-session-file=%/t/module-cache/session.timestamp"      >> %t/ctx.rsp12// RUN: echo "-fmodules-validate-once-per-build-session"                    >> %t/ctx.rsp13// RUN: echo "-Rmodule-build -Rmodule-validation"                           >> %t/ctx.rsp14 15//--- include/foo.h16//--- include/module.modulemap17module Foo { header "foo.h" }18 19//--- clean.c20// Clean module cache. Modules will get compiled regardless of validation settings.21// RUN: mkdir %t/module-cache22// RUN: sleep 123// RUN: touch %t/module-cache/session.timestamp24// RUN: sleep 125// 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.c28// 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.c31// 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.c34#include "foo.h"35// CHECK: building module 'Foo'36 37//--- no-change-same-session.c38// 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 141// 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-empty44// 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-ONLY47// 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-empty50#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.c57// 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 160// RUN: touch %t/include/foo.h61// RUN: sleep 162// 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-empty65// 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-BUILD68// 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-empty71#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.c78// Populated module cache in a new build session with changed inputs.79// All configurations validate and recompile.80// RUN: sleep 181// RUN: touch %t/include/foo.h82// RUN: sleep 183// RUN: touch %t/module-cache/session.timestamp84// RUN: sleep 185// 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-ONCE88// 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-TWICE92// 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-ONCE95#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.c102// Populated module cache in a new build session with unchanged inputs.103// At first, all configurations validate but don't recompile.104// RUN: sleep 1105// RUN: touch %t/module-cache/session.timestamp106// RUN: sleep 1107// 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-ONCE110// 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-ONCE113// 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-ONCE116//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 1120// 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-empty123// 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-ONCE127// 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-empty130#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'135