Skip to content

Commit bbffc09

Browse files
author
David Ungar
committed
Tests for type fingerprints are enabled.
1 parent f2c61d8 commit bbffc09

18 files changed

+765
-6
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env sh
2+
# Fine-grained swiftdeps files use multiple lines for each graph node.
3+
# Compress such a file so that each entry is one line of the form:
4+
# <kind> <aspect> <context> <name> <isProvides>
5+
# Also sort for consistency, since the node order can vary.
6+
7+
awk '/kind:/ {k = $2; f = "<no fingerprint>"}; /aspect:/ {a = $2}; /context:/ {c = $2}; /name/ {n = $2}; /sequenceNumber/ {s = $2}; /fingerprint:/ {f = $2 }; /isProvides:/ {isP = $2; print k, a, c, n, isP, f}' | sort
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// REQUIRES: shell
2+
// Also uses awk:
3+
// XFAIL OS=windows
4+
5+
// When adding a private protocol method, the interface hash should stay the same
6+
// The per-type fingerprint should change
7+
8+
// RUN: %empty-directory(%t)
9+
// RUN: %{python} %utils/split_file.py -o %t %s
10+
// RUN: cp %t/{a,x}.swift
11+
// RUN: %target-swift-frontend -typecheck -enable-type-fingerprints -primary-file %t/x.swift -emit-reference-dependencies-path %t/x.swiftdeps -module-name main
12+
// RUN: %S/../Inputs/process_fine_grained_swiftdeps_with_fingerprints.sh <%t/x.swiftdeps >%t/a-processed.swiftdeps
13+
// RUN: cp %t/{b,x}.swift
14+
// RUN: %target-swift-frontend -typecheck -enable-type-fingerprints -primary-file %t/x.swift -emit-reference-dependencies-path %t/x.swiftdeps -module-name main
15+
// RUN: %S/../Inputs/process_fine_grained_swiftdeps_with_fingerprints.sh <%t/x.swiftdeps >%t/b-processed.swiftdeps
16+
17+
// RUN: not diff %t/{a,b}-processed.swiftdeps >%t/diffs
18+
19+
// BEGIN a.swift
20+
class C {
21+
func f2() -> Int {
22+
return 0
23+
}
24+
}
25+
26+
// BEGIN b.swift
27+
class C {
28+
func f2() -> Int {
29+
return 0
30+
}
31+
32+
func f3() -> Int {
33+
return 1
34+
}
35+
}
36+
37+
// RUN: %FileCheck %s <%t/diffs -check-prefix=CHECK-SAME-INTERFACE-HASH
38+
// RUN: %FileCheck %s <%t/diffs -check-prefix=CHECK-DIFFERENT-TYPE-FINGERPRINT
39+
40+
// CHECK-SAME-INTERFACE-HASH-NOT: sourceFileProvides
41+
42+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: < topLevel implementation '' C true
43+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: < topLevel interface '' C true
44+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: > topLevel implementation '' C true
45+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: > topLevel interface '' C true
46+
47+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: < nominal implementation 4main1C{{[^ ]+}} '' true
48+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: < nominal interface 4main1C{{[^ ]+}} '' true
49+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: > nominal implementation 4main1C{{[^ ]+}} '' true
50+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: > nominal interface 4main1C{{[^ ]+}} '' true
51+
52+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: < potentialMember implementation 4main1C{{[^ ]+}} '' true
53+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: < potentialMember interface 4main1C{{[^ ]+}} '' true
54+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: > potentialMember implementation 4main1C{{[^ ]+}} '' true
55+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: > potentialMember interface 4main1C{{[^ ]+}} '' true
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// REQUIRES: shell
2+
// Also uses awk:
3+
// XFAIL OS=windows
4+
5+
// RUN: %empty-directory(%t)
6+
// RUN: %{python} %utils/split_file.py -o %t %s
7+
// RUN: cp %t/{a,x}.swift
8+
// RUN: %target-swift-frontend -typecheck -enable-type-fingerprints -primary-file %t/x.swift -emit-reference-dependencies-path %t/x.swiftdeps -module-name main
9+
// RUN: %S/../Inputs/process_fine_grained_swiftdeps_with_fingerprints.sh <%t/x.swiftdeps >%t/a-processed.swiftdeps
10+
// RUN: cp %t/{b,x}.swift
11+
// RUN: %target-swift-frontend -typecheck -enable-type-fingerprints -primary-file %t/x.swift -emit-reference-dependencies-path %t/x.swiftdeps -module-name main
12+
// RUN: %S/../Inputs/process_fine_grained_swiftdeps_with_fingerprints.sh <%t/x.swiftdeps >%t/b-processed.swiftdeps
13+
14+
// RUN: not diff %t/{a,b}-processed.swiftdeps >%t/diffs
15+
16+
// BEGIN a.swift
17+
private class C {
18+
func f2() -> Int {
19+
return 0
20+
}
21+
}
22+
23+
// BEGIN b.swift
24+
private class C {
25+
func f2() -> Int {
26+
return 0
27+
}
28+
29+
private var x: Int = 0
30+
}
31+
32+
// Since C is a type or extension, the interface hash ought to not get the
33+
// changed token hash.
34+
35+
// RUN: %FileCheck %s <%t/diffs -check-prefix=CHECK-SAME-INTERFACE-HASH
36+
// RUN: %FileCheck %s <%t/diffs -check-prefix=CHECK-DIFFERENT-TYPE-FINGERPRINT
37+
38+
// CHECK-SAME-INTERFACE-HASH-NOT: sourceFileProvides
39+
40+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: < topLevel implementation '' C true
41+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: < topLevel interface '' C true
42+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: > topLevel implementation '' C true
43+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: > topLevel interface '' C true
44+
45+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: < nominal implementation 4main1C{{[^ ]+}} '' true
46+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: < nominal interface 4main1C{{[^ ]+}} '' true
47+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: > nominal implementation 4main1C{{[^ ]+}} '' true
48+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: > nominal interface 4main1C{{[^ ]+}} '' true
49+
50+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: < potentialMember implementation 4main1C{{[^ ]+}} '' true
51+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: < potentialMember interface 4main1C{{[^ ]+}} '' true
52+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: > potentialMember implementation 4main1C{{[^ ]+}} '' true
53+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: > potentialMember interface 4main1C{{[^ ]+}} '' true
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// REQUIRES: shell
2+
// Also uses awk:
3+
// XFAIL OS=windows
4+
5+
// RUN: %empty-directory(%t)
6+
// RUN: %{python} %utils/split_file.py -o %t %s
7+
// RUN: cp %t/{a,x}.swift
8+
// RUN: %target-swift-frontend -typecheck -enable-type-fingerprints -primary-file %t/x.swift -emit-reference-dependencies-path %t/x.swiftdeps -module-name main
9+
// RUN: %S/../Inputs/process_fine_grained_swiftdeps_with_fingerprints.sh <%t/x.swiftdeps >%t/a-processed.swiftdeps
10+
// RUN: cp %t/{b,x}.swift
11+
// RUN: %target-swift-frontend -typecheck -enable-type-fingerprints -primary-file %t/x.swift -emit-reference-dependencies-path %t/x.swiftdeps -module-name main
12+
// RUN: %S/../Inputs/process_fine_grained_swiftdeps_with_fingerprints.sh <%t/x.swiftdeps >%t/b-processed.swiftdeps
13+
14+
// RUN: not diff %t/{a,b}-processed.swiftdeps >%t/diffs
15+
16+
// BEGIN a.swift
17+
class C {
18+
func f2() -> Int {
19+
return 0
20+
}
21+
}
22+
23+
// BEGIN b.swift
24+
class C {
25+
func f2() -> Int {
26+
return 0
27+
}
28+
29+
private var x: Int = 0
30+
}
31+
32+
// Since C is a type or extension, the interface hash ought to not get the
33+
// changed token hash.
34+
35+
// RUN: %FileCheck %s <%t/diffs -check-prefix=CHECK-SAME-INTERFACE-HASH
36+
// RUN: %FileCheck %s <%t/diffs -check-prefix=CHECK-DIFFERENT-TYPE-FINGERPRINT
37+
38+
// CHECK-SAME-INTERFACE-HASH-NOT: sourceFileProvides
39+
40+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: < topLevel implementation '' C true
41+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: < topLevel interface '' C true
42+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: > topLevel implementation '' C true
43+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: > topLevel interface '' C true
44+
45+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: < nominal implementation 4main1C{{[^ ]+}} '' true
46+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: < nominal interface 4main1C{{[^ ]+}} '' true
47+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: > nominal implementation 4main1C{{[^ ]+}} '' true
48+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: > nominal interface 4main1C{{[^ ]+}} '' true
49+
50+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: < potentialMember implementation 4main1C{{[^ ]+}} '' true
51+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: < potentialMember interface 4main1C{{[^ ]+}} '' true
52+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: > potentialMember implementation 4main1C{{[^ ]+}} '' true
53+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: > potentialMember interface 4main1C{{[^ ]+}} '' true
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// REQUIRES: shell
2+
// Also uses awk:
3+
// XFAIL OS=windows
4+
5+
// When adding a private protocol method, the interface hash should stay the same
6+
// The per-type fingerprint should change
7+
8+
// RUN: %empty-directory(%t)
9+
// RUN: %{python} %utils/split_file.py -o %t %s
10+
// RUN: cp %t/{a,x}.swift
11+
// RUN: %target-swift-frontend -typecheck -enable-type-fingerprints -primary-file %t/x.swift -emit-reference-dependencies-path %t/x.swiftdeps -module-name main
12+
// RUN: %S/../Inputs/process_fine_grained_swiftdeps_with_fingerprints.sh <%t/x.swiftdeps >%t/a-processed.swiftdeps
13+
// RUN: cp %t/{b,x}.swift
14+
// RUN: %target-swift-frontend -typecheck -enable-type-fingerprints -primary-file %t/x.swift -emit-reference-dependencies-path %t/x.swiftdeps -module-name main
15+
// RUN: %S/../Inputs/process_fine_grained_swiftdeps_with_fingerprints.sh <%t/x.swiftdeps >%t/b-processed.swiftdeps
16+
17+
// RUN: not diff %t/{a,b}-processed.swiftdeps >%t/diffs
18+
19+
20+
// BEGIN a.swift
21+
private enum A {
22+
case x, y
23+
func f2() -> Int {
24+
return 0
25+
}
26+
}
27+
28+
// BEGIN b.swift
29+
private enum A {
30+
case x, y
31+
func f2() -> Int {
32+
return 0
33+
}
34+
35+
var foo: Int { return 0 }
36+
}
37+
38+
// RUN: %FileCheck %s <%t/diffs -check-prefix=CHECK-SAME-INTERFACE-HASH
39+
// RUN: %FileCheck %s <%t/diffs -check-prefix=CHECK-DIFFERENT-TYPE-FINGERPRINT
40+
41+
// CHECK-SAME-INTERFACE-HASH-NOT: sourceFileProvides
42+
43+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: < topLevel implementation '' A true
44+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: < topLevel interface '' A true
45+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: > topLevel implementation '' A true
46+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: > topLevel interface '' A true
47+
48+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: < nominal implementation 4main1A{{[^ ]+}} '' true
49+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: < nominal interface 4main1A{{[^ ]+}} '' true
50+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: > nominal implementation 4main1A{{[^ ]+}} '' true
51+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: > nominal interface 4main1A{{[^ ]+}} '' true
52+
53+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: < potentialMember implementation 4main1A{{[^ ]+}} '' true
54+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: < potentialMember interface 4main1A{{[^ ]+}} '' true
55+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: > potentialMember implementation 4main1A{{[^ ]+}} '' true
56+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: > potentialMember interface 4main1A{{[^ ]+}} '' true
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// REQUIRES: shell
2+
// Also uses awk:
3+
// XFAIL OS=windows
4+
5+
// When adding a private protocol method, the interface hash should stay the same
6+
// The per-type fingerprint should change
7+
8+
// RUN: %empty-directory(%t)
9+
// RUN: %{python} %utils/split_file.py -o %t %s
10+
// RUN: cp %t/{a,x}.swift
11+
// RUN: %target-swift-frontend -typecheck -enable-type-fingerprints -primary-file %t/x.swift -emit-reference-dependencies-path %t/x.swiftdeps -module-name main
12+
// RUN: %S/../Inputs/process_fine_grained_swiftdeps_with_fingerprints.sh <%t/x.swiftdeps >%t/a-processed.swiftdeps
13+
// RUN: cp %t/{b,x}.swift
14+
// RUN: %target-swift-frontend -typecheck -enable-type-fingerprints -primary-file %t/x.swift -emit-reference-dependencies-path %t/x.swiftdeps -module-name main
15+
// RUN: %S/../Inputs/process_fine_grained_swiftdeps_with_fingerprints.sh <%t/x.swiftdeps >%t/b-processed.swiftdeps
16+
17+
// RUN: not diff %t/{a,b}-processed.swiftdeps >%t/diffs
18+
19+
// BEGIN a.swift
20+
enum A {
21+
case x, y
22+
func f2() -> Int {
23+
return 0
24+
}
25+
}
26+
27+
// BEGIN b.swift
28+
enum A {
29+
case x, y
30+
func f2() -> Int {
31+
return 0
32+
}
33+
34+
private var foo: Int { return 0 }
35+
}
36+
37+
// RUN: %FileCheck %s <%t/diffs -check-prefix=CHECK-SAME-INTERFACE-HASH
38+
// RUN: %FileCheck %s <%t/diffs -check-prefix=CHECK-DIFFERENT-TYPE-FINGERPRINT
39+
40+
// CHECK-SAME-INTERFACE-HASH-NOT: sourceFileProvides
41+
42+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: < topLevel implementation '' A true
43+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: < topLevel interface '' A true
44+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: > topLevel implementation '' A true
45+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: > topLevel interface '' A true
46+
47+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: < nominal implementation 4main1A{{[^ ]+}} '' true
48+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: < nominal interface 4main1A{{[^ ]+}} '' true
49+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: > nominal implementation 4main1A{{[^ ]+}} '' true
50+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: > nominal interface 4main1A{{[^ ]+}} '' true
51+
52+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: < potentialMember implementation 4main1A{{[^ ]+}} '' true
53+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: < potentialMember interface 4main1A{{[^ ]+}} '' true
54+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: > potentialMember implementation 4main1A{{[^ ]+}} '' true
55+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: > potentialMember interface 4main1A{{[^ ]+}} '' true
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// REQUIRES: shell
2+
// Also uses awk:
3+
// XFAIL OS=windows
4+
5+
// When adding a private protocol method, the interface hash should stay the same
6+
// The per-type fingerprint should change
7+
8+
// RUN: %empty-directory(%t)
9+
// RUN: %{python} %utils/split_file.py -o %t %s
10+
// RUN: cp %t/{a,x}.swift
11+
// RUN: %target-swift-frontend -typecheck -enable-type-fingerprints -primary-file %t/x.swift -emit-reference-dependencies-path %t/x.swiftdeps -module-name main
12+
// RUN: %S/../Inputs/process_fine_grained_swiftdeps_with_fingerprints.sh <%t/x.swiftdeps >%t/a-processed.swiftdeps
13+
// RUN: cp %t/{b,x}.swift
14+
// RUN: %target-swift-frontend -typecheck -enable-type-fingerprints -primary-file %t/x.swift -emit-reference-dependencies-path %t/x.swiftdeps -module-name main
15+
// RUN: %S/../Inputs/process_fine_grained_swiftdeps_with_fingerprints.sh <%t/x.swiftdeps >%t/b-processed.swiftdeps
16+
17+
// RUN: not diff %t/{a,b}-processed.swiftdeps >%t/diffs
18+
19+
// BEGIN a.swift
20+
class C {
21+
func f2() -> Int {
22+
return 0
23+
}
24+
}
25+
26+
// BEGIN b.swift
27+
class C {
28+
func f2() -> Int {
29+
return 0
30+
}
31+
32+
private func f3() -> Int {
33+
return 1
34+
}
35+
}
36+
37+
// RUN: %FileCheck %s <%t/diffs -check-prefix=CHECK-SAME-INTERFACE-HASH
38+
// RUN: %FileCheck %s <%t/diffs -check-prefix=CHECK-DIFFERENT-TYPE-FINGERPRINT
39+
40+
// CHECK-SAME-INTERFACE-HASH-NOT: sourceFileProvides
41+
42+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: < topLevel implementation '' C true
43+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: < topLevel interface '' C true
44+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: > topLevel implementation '' C true
45+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: > topLevel interface '' C true
46+
47+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: < nominal implementation 4main1C{{[^ ]+}} '' true
48+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: < nominal interface 4main1C{{[^ ]+}} '' true
49+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: > nominal implementation 4main1C{{[^ ]+}} '' true
50+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: > nominal interface 4main1C{{[^ ]+}} '' true
51+
52+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: < potentialMember implementation 4main1C{{[^ ]+}} '' true
53+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: < potentialMember interface 4main1C{{[^ ]+}} '' true
54+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: > potentialMember implementation 4main1C{{[^ ]+}} '' true
55+
// CHECK-DIFFERENT-TYPE-FINGERPRINT-DAG: > potentialMember interface 4main1C{{[^ ]+}} '' true

0 commit comments

Comments
 (0)