87 lines · c
1// RUN: rm -rf %t2// RUN: split-file %s %t3 4// Test fallback directory remapping, ie. a directory "Base" which is used as5// a fallback if files are missing from "UseFirst"6 7// RUN: sed -e "s@EXTERNAL_DIR@%{/t:regex_replacement}/Both/Base@g" -e "s@NAME_DIR@%{/t:regex_replacement}/Both/UseFirst@g" %t/vfs/base.yaml > %t/vfs/both.yaml8 9// RUN: cp -R %t/Both %t/UseFirstOnly10// RUN: rm -rf %t/UseFirstOnly/Base11// RUN: sed -e "s@EXTERNAL_DIR@%{/t:regex_replacement}/UseFirstOnly/Base@g" -e "s@NAME_DIR@%{/t:regex_replacement}/UseFirstOnly/UseFirst@g" %t/vfs/base.yaml > %t/vfs/use-first-only.yaml12 13// RUN: cp -R %t/Both %t/BaseOnly14// RUN: rm -rf %t/BaseOnly/UseFirst15// RUN: sed -e "s@EXTERNAL_DIR@%{/t:regex_replacement}/BaseOnly/Base@g" -e "s@NAME_DIR@%{/t:regex_replacement}/BaseOnly/UseFirst@g" %t/vfs/base.yaml > %t/vfs/base-only.yaml16 17// RUN: cp -R %t/Both %t/BFallback18// RUN: rm %t/BFallback/UseFirst/B.h19// RUN: sed -e "s@EXTERNAL_DIR@%{/t:regex_replacement}/BFallback/Base@g" -e "s@NAME_DIR@%{/t:regex_replacement}/BFallback/UseFirst@g" %t/vfs/base.yaml > %t/vfs/b-fallback.yaml20 21// RUN: cp -R %t/Both %t/CFallback22// RUN: rm %t/CFallback/UseFirst/C.h23// RUN: sed -e "s@EXTERNAL_DIR@%{/t:regex_replacement}/CFallback/Base@g" -e "s@NAME_DIR@%{/t:regex_replacement}/CFallback/UseFirst@g" %t/vfs/base.yaml > %t/vfs/c-fallback.yaml24 25// Both B.h and C.h are in both folders26// RUN: %clang_cc1 -Werror -I %t/Both/UseFirst -ivfsoverlay %t/vfs/both.yaml -E -C %t/main.c 2>&1 | FileCheck --check-prefix=IN_UF %s27 28// IN_UF: # 1 "{{.*(/|\\\\)UseFirst(/|\\\\)}}B.h"29// IN_UF-NEXT: // B.h in UseFirst30// IN_UF: # 1 "{{.*(/|\\\\)UseFirst(/|\\\\)}}C.h"31// IN_UF-NEXT: // C.h in UseFirst32 33// Base missing, so now they are only in UseFirst34// RUN: %clang_cc1 -Werror -I %t/UseFirstOnly/UseFirst -ivfsoverlay %t/vfs/use-first-only.yaml -E -C %t/main.c 2>&1 | FileCheck --check-prefix=IN_UF %s35 36// UseFirst missing, fallback to Base37// RUN: %clang_cc1 -Werror -I %t/BaseOnly/UseFirst -ivfsoverlay %t/vfs/base-only.yaml -E -C %t/main.c 2>&1 | FileCheck --check-prefix=IN_BASE %s38 39// IN_BASE: # 1 "{{.*(/|\\\\)Base(/|\\\\)}}B.h"40// IN_BASE-NEXT: // B.h in Base41// IN_BASE: # 1 "{{.*(/|\\\\)Base(/|\\\\)}}C.h"42// IN_BASE-NEXT: // C.h in Base43 44// B.h missing from UseFirst45// RUN: %clang_cc1 -Werror -I %t/BFallback/UseFirst -ivfsoverlay %t/vfs/b-fallback.yaml -E -C %t/main.c 2>&1 | FileCheck --check-prefix=B_FALLBACK %s46 47// B_FALLBACK: # 1 "{{.*(/|\\\\)Base(/|\\\\)}}B.h"48// B_FALLBACK-NEXT: // B.h in Base49// B_FALLBACK: # 1 "{{.*(/|\\\\)UseFirst(/|\\\\)}}C.h"50// B_FALLBACK-NEXT: // C.h in UseFirst51 52// C.h missing from UseFirst53// RUN: %clang_cc1 -Werror -I %t/CFallback/UseFirst -ivfsoverlay %t/vfs/c-fallback.yaml -E -C %t/main.c 2>&1 | FileCheck --check-prefix=C_FALLBACK %s54 55// C_FALLBACK: # 1 "{{.*(/|\\\\)UseFirst(/|\\\\)}}B.h"56// C_FALLBACK-NEXT: // B.h in UseFirst57// C_FALLBACK: # 1 "{{.*(/|\\\\)Base(/|\\\\)}}C.h"58// C_FALLBACK-NEXT: // C.h in Base59 60//--- main.c61#include "B.h"62 63//--- Both/UseFirst/B.h64// B.h in UseFirst65#include "C.h"66 67//--- Both/UseFirst/C.h68// C.h in UseFirst69 70//--- Both/Base/B.h71// B.h in Base72#include "C.h"73 74//--- Both/Base/C.h75// C.h in Base76 77//--- vfs/base.yaml78{79 'version' : 0,80 'redirecting-with' : 'fallback',81 'roots' : [82 {'name' : 'NAME_DIR',83 'type' : 'directory-remap',84 'external-contents' : 'EXTERNAL_DIR'}85 ]86}87