Skip to content

Commit 45dc14a

Browse files
author
Nathan Hawes
committed
[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.
1 parent a785fa6 commit 45dc14a

File tree

1 file changed

+89
-53
lines changed

1 file changed

+89
-53
lines changed
Lines changed: 89 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
// RUN: %empty-directory(%t)
2+
// RUN: %empty-directory(%t/mcp)
23
// RUN: cp -r %S/../Inputs/CrossImport %t/CrossImport
34
// RUN: %{python} %S/../../CrossImport/Inputs/rewrite-module-triples.py %t/CrossImport %module-target-triple
45

5-
// 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
6+
// 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
67
// RUN: c-index-test core -print-unit %t/idx > %t/units
7-
// RUN: %FileCheck %s --input-file %t/units --check-prefix=UNIT
8-
// RUN: %FileCheck %s --input-file %t/units --check-prefix=UNIT-NEGATIVE
98

109
import A
1110
import B
@@ -16,59 +15,96 @@ fromB()
1615
from_ABAdditions()
1716
from__ABAdditionsCAdditions()
1817

19-
// Check the overlay modules' names match the names of their underlying modules.
18+
// Check the overlay modules pick up the name of their underlying module.
2019
//
21-
// UNIT: module-name: cross_import_overlay
22-
// UNIT: main-path: {{.*}}/cross-import-overlay.swift
23-
// UNIT: DEPEND START
24-
// UNIT: Unit | system | B | {{.*}}/B.swiftmodule/{{.*}}
25-
// UNIT: Unit | system | C | {{.*}}/C.swiftmodule/{{.*}}
26-
// UNIT: Unit | system | A | {{.*}}/__ABAdditionsCAdditions.swiftmodule/{{.*}}
27-
// UNIT: Record | user | {{.*}}/cross-import-overlay.swift | cross-import-overlay.swift-{{.*}}
28-
// UNIT: DEPEND END
29-
// UNIT: --------
30-
// UNIT: module-name: A
31-
// UNIT: out-file: {{.*}}/_ABAdditions.swiftmodule/{{.*}}
32-
// UNIT: DEPEND START
33-
// UNIT: Unit | system | A | {{.*}}/A.swiftmodule/{{.*}}
34-
// UNIT: Unit | system | B | {{.*}}/B.swiftmodule/{{.*}}
35-
// UNIT: Record | system | A | {{.*}}/_ABAdditions.swiftmodule/{{.*}}
36-
// UNIT: DEPEND END
37-
// UNIT: --------
38-
// UNIT: module-name: A
39-
// UNIT: out-file: {{.*}}/__ABAdditionsCAdditions.swiftmodule/{{.*}}
40-
// UNIT: DEPEND START
41-
// UNIT: Unit | system | C | {{.*}}/C.swiftmodule/{{.*}}
42-
// UNIT: Unit | system | A | {{.*}}/_ABAdditions.swiftmodule/{{.*}}
43-
// UNIT: Record | system | A | {{.*}}/__ABAdditionsCAdditions.swiftmodule/{{.*}}
44-
// UNIT: DEPEND END
45-
// UNIT: --------
46-
// UNIT: module-name: C
47-
// UNIT: out-file: {{.*}}/C.swiftmodule/{{.*}}
48-
// UNIT: DEPEND START
49-
// UNIT: Record | system | C | {{.*}}/C.swiftmodule/{{.*}}
50-
// UNIT: DEPEND END
51-
// UNIT: --------
52-
// UNIT: module-name: B
53-
// UNIT: out-file: {{.*}}/B.swiftmodule/{{.*}}
54-
// UNIT: DEPEND START
55-
// UNIT: Record | system | B | {{.*}}/B.swiftmodule/{{.*}}
56-
// UNIT: DEPEND END
57-
// UNIT: --------
58-
// UNIT: module-name: A
59-
// UNIT: out-file: {{.*}}/A.swiftmodule/{{.*}}
60-
// UNIT: DEPEND START
61-
// UNIT: Record | system | A | {{.*}}/A.swiftmodule/{{.*}}
62-
// UNIT: DEPEND END
20+
// FIXME: the units are sorted by their unit name, which for the frameworks in
21+
// this test end up just being the target triple + a hash of the output file
22+
// path which changes depending on where this test is run. We should fix this
23+
// properly, but for now work around it by checking for each unit in a separate
24+
// pass and do our best to make sure we don't match across unit boundaries.
25+
//
26+
// RUN: %FileCheck %s --input-file %t/units --check-prefix=MAIN
27+
// MAIN: module-name: cross_import_overlay
28+
// MAIN: out-file: {{.*}}/file1.o
29+
// MAIN-NEXT: target: {{.*}}
30+
// MAIN-NEXT: is-debug: 1
31+
// MAIN-NEXT: DEPEND START
32+
// MAIN-NEXT: Unit | system | Swift | {{.*}}/Swift.swiftmodule
33+
// MAIN-NEXT: Unit | system | B | {{.*}}/B.swiftmodule/{{.*}}
34+
// MAIN-NEXT: Unit | system | C | {{.*}}/C.swiftmodule/{{.*}}
35+
// MAIN-NEXT: Unit | system | A | {{.*}}/__ABAdditionsCAdditions.swiftmodule/{{.*}}
36+
// MAIN-NEXT: Record | user | {{.*}}/cross-import-overlay.swift
37+
// MAIN-NEXT: DEPEND END
38+
//
39+
// RUN: %FileCheck %s --input-file %t/units --check-prefix=AB_OVERLAY
40+
// AB_OVERLAY: module-name: A
41+
// AB_OVERLAY: out-file:{{.*}}/_ABAdditions.swiftmodule/{{.*}}
42+
// AB_OVERLAY-NEXT: target: {{.*}}
43+
// AB_OVERLAY-NEXT: is-debug: 1
44+
// AB_OVERLAY-NEXT: DEPEND START
45+
// AB_OVERLAY-NEXT: Unit | system | A | {{.*}}/A.swiftmodule/{{.*}}
46+
// AB_OVERLAY-NEXT: Unit | system | B | {{.*}}/B.swiftmodule/{{.*}}
47+
// AB_OVERLAY-NEXT: Unit | system | Swift | {{.*}}/Swift.swiftmodule
48+
// AB_OVERLAY-NEXT: Record | system | A | {{.*}}/_ABAdditions.swiftmodule/{{.*}}
49+
// AB_OVERLAY-NEXT: DEPEND END
50+
//
51+
// RUN: %FileCheck %s --input-file %t/units --check-prefix=ABC_OVERLAY
52+
// ABC_OVERLAY: module-name: A
53+
// ABC_OVERLAY: out-file: {{.*}}/__ABAdditionsCAdditions.swiftmodule/{{.*}}
54+
// ABC_OVERLAY-NEXT: target: {{.*}}
55+
// ABC_OVERLAY-NEXT: is-debug: 1
56+
// ABC_OVERLAY-NEXT: DEPEND START
57+
// ABC_OVERLAY-NEXT: Unit | system | C | {{.*}}/C.swiftmodule/{{.*}}
58+
// ABC_OVERLAY-NEXT: Unit | system | Swift | {{.*}}/Swift.swiftmodule
59+
// ABC_OVERLAY-NEXT: Unit | system | A | {{.*}}/_ABAdditions.swiftmodule/{{.*}}
60+
// ABC_OVERLAY-NEXT: Record | system | A | {{.*}}/__ABAdditionsCAdditions.swiftmodule/{{.*}}
61+
// ABC_OVERLAY-NEXT: DEPEND END
62+
//
63+
// RUN: %FileCheck %s --input-file %t/units --check-prefix=C_MODULE
64+
// C_MODULE: module-name: C
65+
// C_MODULE: out-file: {{.*}}/C.swiftmodule/{{.*}}
66+
// C_MODULE-NEXT: target: {{.*}}
67+
// C_MODULE-NEXT: is-debug: 1
68+
// C_MODULE-NEXT: DEPEND START
69+
// C_MODULE-NEXT: Unit | system | Swift | {{.*}}/Swift.swiftmodule
70+
// C_MODULE-NEXT: Record | system | C | {{.*}}/C.swiftmodule/{{.*}}
71+
// C_MODULE-NEXT: DEPEND END
72+
//
73+
// RUN: %FileCheck %s --input-file %t/units --check-prefix=B_MODULE
74+
// B_MODULE: module-name: B
75+
// B_MODULE: out-file: {{.*}}/B.swiftmodule/{{.*}}
76+
// B_MODULE-NEXT: target: {{.*}}
77+
// B_MODULE-NEXT: is-debug: 1
78+
// B_MODULE-NEXT: DEPEND START
79+
// B_MODULE-NEXT: Unit | system | Swift | {{.*}}/Swift.swiftmodule
80+
// B_MODULE-NEXT: Record | system | B | {{.*}}/B.swiftmodule/{{.*}}
81+
// B_MODULE-NEXT: DEPEND END
82+
//
83+
// RUN: %FileCheck %s --input-file %t/units --check-prefix=A_MODULE
84+
// A_MODULE: module-name: A
85+
// A_MODULE: out-file: {{.*}}/A.swiftmodule/{{.*}}
86+
// A_MODULE-NEXT: target: {{.*}}
87+
// A_MODULE-NEXT: is-debug: 1
88+
// A_MODULE-NEXT: DEPEND START
89+
// A_MODULE-NEXT: Unit | system | Swift | {{.*}}/Swift.swiftmodule
90+
// A_MODULE-NEXT: Record | system | A | {{.*}}/A.swiftmodule/{{.*}}
91+
// A_MODULE-NEXT: DEPEND END
92+
6393

64-
// Make sure we aren't leaking the underscored overlay names anywhere
94+
// Make sure there are three units with module-name 'A' (A, _ABAdditions and
95+
// __ABAdditionsCAdditions) in case we matched across unit boundaries above
96+
// due to the nondeterministic ordering.
6597
//
66-
// UNIT-NEGATIVE-NOT: Unit | {{.*}} | _ABAdditions |
67-
// UNIT-NEGATIVE-NOT: Record | {{.*}} | _ABAdditions |
68-
// UNIT-NEGATIVE-NOT: Unit | {{.*}} | __ABAdditionsCAdditions |
69-
// UNIT-NEGATIVE-NOT: Record | {{.*}} | __ABAdditionsCAdditions |
98+
// RUN: %FileCheck %s --input-file %t/units --check-prefix=UNITS
99+
// UNITS-COUNT-3: module-name: A
70100

71-
// Make sure we don't regress test performance by indexing the stdlib.
101+
// Make sure we aren't leaking the underscored overlay names anywhere and don't
102+
// regress test performance by indexing the stdlib.
72103
//
73-
// UNIT-NEGATIVE-NOT: Record | system | Swift |
104+
// RUN: %FileCheck %s --input-file %t/units --check-prefix=UNITS-NEGATIVE
105+
// UNITS-NEGATIVE-NOT: Unit | {{.*}} | _ABAdditions
106+
// UNITS-NEGATIVE-NOT: Record | {{.*}} | _ABAdditions
107+
// UNITS-NEGATIVE-NOT: Unit | {{.*}} | __ABAdditionsCAdditions
108+
// UNITS-NEGATIVE-NOT: Record | {{.*}} | __ABAdditionsCAdditions
109+
// UNITS-NEGATIVE-NOT: Record | system | Swift
74110

0 commit comments

Comments
 (0)