[Index][test] Fix test/Index/Store/cross-import-overly.swift to handle units being printed out of order.

c-index-test sorts the units by their file name, which for the modules in
in this test is just [target-triple].swiftinterface-[hash-of-full-output-path]
and so changes depending on where it's run.
This commit is contained in:
Nathan Hawes
2020-03-25 18:49:45 -07:00
parent a785fa6cee
commit 45dc14a275

View File

@@ -1,11 +1,10 @@
// RUN: %empty-directory(%t)
// RUN: %empty-directory(%t/mcp)
// RUN: cp -r %S/../Inputs/CrossImport %t/CrossImport
// RUN: %{python} %S/../../CrossImport/Inputs/rewrite-module-triples.py %t/CrossImport %module-target-triple
// RUN: %target-swift-frontend -c -index-store-path %t/idx -index-system-modules -index-ignore-stdlib -enable-cross-import-overlays %s -Fsystem %t/CrossImport -o %t/file1.o -module-name cross_import_overlay
// RUN: %target-swift-frontend -c -index-store-path %t/idx -module-cache-path %t/mcp -index-system-modules -index-ignore-stdlib -enable-cross-import-overlays %s -Fsystem %t/CrossImport -o %t/file1.o -module-name cross_import_overlay
// RUN: c-index-test core -print-unit %t/idx > %t/units
// RUN: %FileCheck %s --input-file %t/units --check-prefix=UNIT
// RUN: %FileCheck %s --input-file %t/units --check-prefix=UNIT-NEGATIVE
import A
import B
@@ -16,59 +15,96 @@ fromB()
from_ABAdditions()
from__ABAdditionsCAdditions()
// Check the overlay modules' names match the names of their underlying modules.
// Check the overlay modules pick up the name of their underlying module.
//
// UNIT: module-name: cross_import_overlay
// UNIT: main-path: {{.*}}/cross-import-overlay.swift
// UNIT: DEPEND START
// UNIT: Unit | system | B | {{.*}}/B.swiftmodule/{{.*}}
// UNIT: Unit | system | C | {{.*}}/C.swiftmodule/{{.*}}
// UNIT: Unit | system | A | {{.*}}/__ABAdditionsCAdditions.swiftmodule/{{.*}}
// UNIT: Record | user | {{.*}}/cross-import-overlay.swift | cross-import-overlay.swift-{{.*}}
// UNIT: DEPEND END
// UNIT: --------
// UNIT: module-name: A
// UNIT: out-file: {{.*}}/_ABAdditions.swiftmodule/{{.*}}
// UNIT: DEPEND START
// UNIT: Unit | system | A | {{.*}}/A.swiftmodule/{{.*}}
// UNIT: Unit | system | B | {{.*}}/B.swiftmodule/{{.*}}
// UNIT: Record | system | A | {{.*}}/_ABAdditions.swiftmodule/{{.*}}
// UNIT: DEPEND END
// UNIT: --------
// UNIT: module-name: A
// UNIT: out-file: {{.*}}/__ABAdditionsCAdditions.swiftmodule/{{.*}}
// UNIT: DEPEND START
// UNIT: Unit | system | C | {{.*}}/C.swiftmodule/{{.*}}
// UNIT: Unit | system | A | {{.*}}/_ABAdditions.swiftmodule/{{.*}}
// UNIT: Record | system | A | {{.*}}/__ABAdditionsCAdditions.swiftmodule/{{.*}}
// UNIT: DEPEND END
// UNIT: --------
// UNIT: module-name: C
// UNIT: out-file: {{.*}}/C.swiftmodule/{{.*}}
// UNIT: DEPEND START
// UNIT: Record | system | C | {{.*}}/C.swiftmodule/{{.*}}
// UNIT: DEPEND END
// UNIT: --------
// UNIT: module-name: B
// UNIT: out-file: {{.*}}/B.swiftmodule/{{.*}}
// UNIT: DEPEND START
// UNIT: Record | system | B | {{.*}}/B.swiftmodule/{{.*}}
// UNIT: DEPEND END
// UNIT: --------
// UNIT: module-name: A
// UNIT: out-file: {{.*}}/A.swiftmodule/{{.*}}
// UNIT: DEPEND START
// UNIT: Record | system | A | {{.*}}/A.swiftmodule/{{.*}}
// UNIT: DEPEND END
// Make sure we aren't leaking the underscored overlay names anywhere
// FIXME: the units are sorted by their unit name, which for the frameworks in
// this test end up just being the target triple + a hash of the output file
// path which changes depending on where this test is run. We should fix this
// properly, but for now work around it by checking for each unit in a separate
// pass and do our best to make sure we don't match across unit boundaries.
//
// UNIT-NEGATIVE-NOT: Unit | {{.*}} | _ABAdditions |
// UNIT-NEGATIVE-NOT: Record | {{.*}} | _ABAdditions |
// UNIT-NEGATIVE-NOT: Unit | {{.*}} | __ABAdditionsCAdditions |
// UNIT-NEGATIVE-NOT: Record | {{.*}} | __ABAdditionsCAdditions |
// Make sure we don't regress test performance by indexing the stdlib.
// RUN: %FileCheck %s --input-file %t/units --check-prefix=MAIN
// MAIN: module-name: cross_import_overlay
// MAIN: out-file: {{.*}}/file1.o
// MAIN-NEXT: target: {{.*}}
// MAIN-NEXT: is-debug: 1
// MAIN-NEXT: DEPEND START
// MAIN-NEXT: Unit | system | Swift | {{.*}}/Swift.swiftmodule
// MAIN-NEXT: Unit | system | B | {{.*}}/B.swiftmodule/{{.*}}
// MAIN-NEXT: Unit | system | C | {{.*}}/C.swiftmodule/{{.*}}
// MAIN-NEXT: Unit | system | A | {{.*}}/__ABAdditionsCAdditions.swiftmodule/{{.*}}
// MAIN-NEXT: Record | user | {{.*}}/cross-import-overlay.swift
// MAIN-NEXT: DEPEND END
//
// UNIT-NEGATIVE-NOT: Record | system | Swift |
// RUN: %FileCheck %s --input-file %t/units --check-prefix=AB_OVERLAY
// AB_OVERLAY: module-name: A
// AB_OVERLAY: out-file:{{.*}}/_ABAdditions.swiftmodule/{{.*}}
// AB_OVERLAY-NEXT: target: {{.*}}
// AB_OVERLAY-NEXT: is-debug: 1
// AB_OVERLAY-NEXT: DEPEND START
// AB_OVERLAY-NEXT: Unit | system | A | {{.*}}/A.swiftmodule/{{.*}}
// AB_OVERLAY-NEXT: Unit | system | B | {{.*}}/B.swiftmodule/{{.*}}
// AB_OVERLAY-NEXT: Unit | system | Swift | {{.*}}/Swift.swiftmodule
// AB_OVERLAY-NEXT: Record | system | A | {{.*}}/_ABAdditions.swiftmodule/{{.*}}
// AB_OVERLAY-NEXT: DEPEND END
//
// RUN: %FileCheck %s --input-file %t/units --check-prefix=ABC_OVERLAY
// ABC_OVERLAY: module-name: A
// ABC_OVERLAY: out-file: {{.*}}/__ABAdditionsCAdditions.swiftmodule/{{.*}}
// ABC_OVERLAY-NEXT: target: {{.*}}
// ABC_OVERLAY-NEXT: is-debug: 1
// ABC_OVERLAY-NEXT: DEPEND START
// ABC_OVERLAY-NEXT: Unit | system | C | {{.*}}/C.swiftmodule/{{.*}}
// ABC_OVERLAY-NEXT: Unit | system | Swift | {{.*}}/Swift.swiftmodule
// ABC_OVERLAY-NEXT: Unit | system | A | {{.*}}/_ABAdditions.swiftmodule/{{.*}}
// ABC_OVERLAY-NEXT: Record | system | A | {{.*}}/__ABAdditionsCAdditions.swiftmodule/{{.*}}
// ABC_OVERLAY-NEXT: DEPEND END
//
// RUN: %FileCheck %s --input-file %t/units --check-prefix=C_MODULE
// C_MODULE: module-name: C
// C_MODULE: out-file: {{.*}}/C.swiftmodule/{{.*}}
// C_MODULE-NEXT: target: {{.*}}
// C_MODULE-NEXT: is-debug: 1
// C_MODULE-NEXT: DEPEND START
// C_MODULE-NEXT: Unit | system | Swift | {{.*}}/Swift.swiftmodule
// C_MODULE-NEXT: Record | system | C | {{.*}}/C.swiftmodule/{{.*}}
// C_MODULE-NEXT: DEPEND END
//
// RUN: %FileCheck %s --input-file %t/units --check-prefix=B_MODULE
// B_MODULE: module-name: B
// B_MODULE: out-file: {{.*}}/B.swiftmodule/{{.*}}
// B_MODULE-NEXT: target: {{.*}}
// B_MODULE-NEXT: is-debug: 1
// B_MODULE-NEXT: DEPEND START
// B_MODULE-NEXT: Unit | system | Swift | {{.*}}/Swift.swiftmodule
// B_MODULE-NEXT: Record | system | B | {{.*}}/B.swiftmodule/{{.*}}
// B_MODULE-NEXT: DEPEND END
//
// RUN: %FileCheck %s --input-file %t/units --check-prefix=A_MODULE
// A_MODULE: module-name: A
// A_MODULE: out-file: {{.*}}/A.swiftmodule/{{.*}}
// A_MODULE-NEXT: target: {{.*}}
// A_MODULE-NEXT: is-debug: 1
// A_MODULE-NEXT: DEPEND START
// A_MODULE-NEXT: Unit | system | Swift | {{.*}}/Swift.swiftmodule
// A_MODULE-NEXT: Record | system | A | {{.*}}/A.swiftmodule/{{.*}}
// A_MODULE-NEXT: DEPEND END
// Make sure there are three units with module-name 'A' (A, _ABAdditions and
// __ABAdditionsCAdditions) in case we matched across unit boundaries above
// due to the nondeterministic ordering.
//
// RUN: %FileCheck %s --input-file %t/units --check-prefix=UNITS
// UNITS-COUNT-3: module-name: A
// Make sure we aren't leaking the underscored overlay names anywhere and don't
// regress test performance by indexing the stdlib.
//
// RUN: %FileCheck %s --input-file %t/units --check-prefix=UNITS-NEGATIVE
// UNITS-NEGATIVE-NOT: Unit | {{.*}} | _ABAdditions
// UNITS-NEGATIVE-NOT: Record | {{.*}} | _ABAdditions
// UNITS-NEGATIVE-NOT: Unit | {{.*}} | __ABAdditionsCAdditions
// UNITS-NEGATIVE-NOT: Record | {{.*}} | __ABAdditionsCAdditions
// UNITS-NEGATIVE-NOT: Record | system | Swift