Skip to content

Commit 2bd112d

Browse files
committed
[Incremental] Rudimentary Tests for Verified Dependencies
1 parent 3c9b592 commit 2bd112d

File tree

8 files changed

+183
-0
lines changed

8 files changed

+183
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
open class Base {}
2+
3+
public protocol BaseProtocol {}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
final public class Subclass: Base {}
2+
3+
public protocol PublicProtocol: BaseProtocol {}
4+
5+
// expected-no-dependency {{main.BaseProtocol}}

test/Incremental/fail/main.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %{python} %S/../gen-output-file-map.py -o %t %S/Inputs
3+
// RUN: find %S -name "*.swift" > %t/Sources.resp
4+
// RUN: cd %t
5+
// RUN: not %target-swiftc_driver -no-color-diagnostics -typecheck -output-file-map %t/output.json -incremental -module-name main -verify-incremental-dependencies @%t/Sources.resp 2>&1 | %FileCheck %s
6+
7+
// N.B. We use CHECK-DAG so we aren't subject to ordering problems caused by the
8+
// driver choosing to reschedule different frontend processes, and various
9+
// terminal emulators choosing to buffer rerouted file descriptors differently.
10+
11+
// CHECK-DAG: unexpected cascading dependency: main.Subclass.init
12+
// CHECK-DAG: unexpected cascading dependency: main.Subclass.deinit
13+
// CHECK-DAG: unexpected provided entity: PublicProtocol
14+
// CHECK-DAG: unexpected provided entity: BaseProtocol
15+
// CHECK-DAG: unexpected provided entity: Base
16+
// CHECK-DAG: unexpected provided entity: Subclass
17+
// CHECK-DAG: unexpected cascading dependency: main.Base.init
18+
// CHECK-DAG: unexpected dependency exists: main.BaseProtocol
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
open class OpenBase {} // expected-provides {{OpenBase}}
2+
// expected-cascading-member {{main.OpenBase.init}}
3+
// expected-cascading-member {{main.OpenBase.deinit}}
4+
5+
public class PublicBase {} // expected-provides {{PublicBase}}
6+
// expected-cascading-member {{main.PublicBase.init}}
7+
// expected-cascading-member {{main.PublicBase.deinit}}
8+
9+
internal class InternalBase {} // expected-provides {{InternalBase}}
10+
// expected-cascading-member {{main.InternalBase.init}}
11+
// expected-cascading-member {{main.InternalBase.deinit}}
12+
13+
fileprivate class FilePrivateBase {} // expected-provides {{FilePrivateBase}}
14+
// expected-cascading-member {{main.FilePrivateBase.init}}
15+
// expected-private-member {{main.FilePrivateBase.deinit}}
16+
17+
private class PrivateBase {} // expected-provides {{PrivateBase}}
18+
// expected-cascading-member {{main.PrivateBase.init}}
19+
// expected-private-member {{main.PrivateBase.deinit}}
20+
21+
final fileprivate class FilePrivateSubclass: FilePrivateBase {} // expected-provides {{FilePrivateSubclass}} expected-private-superclass {{main.FilePrivateBase}}
22+
// expected-cascading-member {{main.FilePrivateSubclass.init}}
23+
// expected-private-member {{main.FilePrivateSubclass.deinit}}
24+
25+
final private class PrivateSubclass: PrivateBase {} // expected-provides {{PrivateSubclass}} expected-private-superclass {{main.PrivateBase}}
26+
// expected-cascading-member {{main.PrivateSubclass.init}}
27+
// expected-private-member {{main.PrivateSubclass.deinit}}
28+
29+
public protocol PublicBaseProtocol {} // expected-provides {{PublicBaseProtocol}}
30+
31+
internal protocol InternalBaseProtocol {} // expected-provides {{InternalBaseProtocol}}
32+
33+
fileprivate protocol FilePrivateBaseProtocol {} // expected-provides {{FilePrivateBaseProtocol}}
34+
35+
private protocol PrivateBaseProtocol {} // expected-provides {{PrivateBaseProtocol}}
36+
37+
fileprivate protocol FilePrivateProtocol: FilePrivateBaseProtocol {} // expected-provides {{FilePrivateProtocol}} expected-private-conformance {{main.FilePrivateBaseProtocol}}
38+
39+
private protocol PrivateProtocol: PrivateBaseProtocol {} // expected-provides {{PrivateProtocol}} expected-private-conformance {{main.PrivateBaseProtocol}}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
final public class OpenSubclass: OpenBase {} // expected-provides {{OpenSubclass}} expected-cascading-superclass {{main.OpenBase}}
2+
// expected-provides {{OpenBase}}
3+
// expected-cascading-member {{main.OpenBase.init}}
4+
// expected-cascading-member {{main.OpenSubclass.init}}
5+
// expected-cascading-member {{main.OpenSubclass.deinit}}
6+
7+
final public class PublicSubclass: PublicBase {} // expected-provides {{PublicSubclass}} expected-cascading-superclass {{main.PublicBase}}
8+
// expected-provides {{PublicBase}}
9+
// expected-cascading-member {{main.PublicBase.init}}
10+
// expected-cascading-member {{main.PublicSubclass.init}}
11+
// expected-cascading-member {{main.PublicSubclass.deinit}}
12+
13+
final internal class InternalSubclass: InternalBase {} // expected-provides {{InternalSubclass}} expected-cascading-superclass {{main.InternalBase}}
14+
// expected-provides {{InternalBase}}
15+
// expected-cascading-member {{main.InternalBase.init}}
16+
// expected-cascading-member {{main.InternalSubclass.init}}
17+
// expected-cascading-member {{main.InternalSubclass.deinit}}
18+
19+
public protocol PublicProtocol: PublicBaseProtocol {}
20+
// expected-provides {{PublicProtocol}}
21+
// expected-provides {{PublicBaseProtocol}}
22+
// expected-cascading-conformance {{main.PublicBaseProtocol}}
23+
24+
internal protocol InternalProtocol: InternalBaseProtocol {}
25+
// expected-provides {{InternalProtocol}}
26+
// expected-provides {{InternalBaseProtocol}}
27+
// expected-cascading-conformance {{main.InternalBaseProtocol}}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %{python} %S/../gen-output-file-map.py -o %t %S/Inputs
3+
// RUN: find %S -name "*.swift" > %t/Sources.resp
4+
// RUN: cd %t && %target-swiftc_driver -typecheck -output-file-map %t/output.json -incremental -module-name main -verify-incremental-dependencies @%t/Sources.resp
5+
// RUN: cd %t && %target-swiftc_driver -typecheck -output-file-map %t/output.json -incremental -enable-batch-mode -module-name main -verify-incremental-dependencies @%t/Sources.resp
6+
7+
// N.B. These tests are meant to continue to expand to more and more input files
8+
// as more kinds of cross-type dependencies are discovered. This will naturally
9+
// increase the chance that input ordering bugs will be surfaced by batch mode.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// REQUIRES: objc_interop
2+
3+
// RUN: %empty-directory(%t)
4+
// RUN: %{python} %S/../gen-output-file-map.py -o %t %S
5+
// RUN: cd %t && %target-swiftc_driver -typecheck -output-file-map %t/output.json -incremental -module-name main -verify-incremental-dependencies %s
6+
7+
import Foundation
8+
9+
// expected-provides {{LookupFactory}}
10+
// expected-provides {{NSObject}}
11+
// expected-private-superclass {{ObjectiveC.NSObject}}
12+
// expected-private-conformance {{Foundation._KeyValueCodingAndObserving}}
13+
// expected-private-conformance {{Swift.Hashable}}
14+
// expected-private-conformance {{Swift.Equatable}}
15+
// expected-private-conformance {{Swift.CustomDebugStringConvertible}}
16+
// expected-private-conformance {{Swift.CVarArg}}
17+
// expected-private-conformance {{ObjectiveC.NSObjectProtocol}}
18+
// expected-private-conformance {{Swift.CustomStringConvertible}}
19+
@objc private class LookupFactory: NSObject {
20+
// expected-provides {{AssignmentPrecedence}}
21+
// expected-provides {{IntegerLiteralType}}
22+
// expected-provides {{FloatLiteralType}}
23+
// expected-provides {{Int}}
24+
// expected-cascading-member {{ObjectiveC.NSObject.someMember}}
25+
// expected-cascading-member {{ObjectiveC.NSObject.Int}}
26+
// expected-cascading-member {{main.LookupFactory.Int}}
27+
@objc var someMember: Int = 0
28+
// expected-cascading-member {{ObjectiveC.NSObject.someMethod}}
29+
@objc func someMethod() {}
30+
31+
// expected-cascading-member {{ObjectiveC.NSObject.init}}
32+
// expected-cascading-member {{main.LookupFactory.init}}
33+
// expected-cascading-member {{main.LookupFactory.deinit}}
34+
// expected-cascading-member {{main.LookupFactory.someMember}}
35+
// expected-cascading-member {{main.LookupFactory.someMethod}}
36+
}
37+
38+
// expected-private-member {{Swift.ExpressibleByNilLiteral.callAsFunction}}
39+
// expected-private-member {{Swift.CustomReflectable.callAsFunction}}
40+
// expected-private-member {{Swift._ObjectiveCBridgeable.callAsFunction}}
41+
// expected-private-member {{Swift.Optional.callAsFunction}}
42+
// expected-private-member {{Swift.CustomDebugStringConvertible.callAsFunction}}
43+
// expected-private-member {{Swift.Equatable.callAsFunction}}
44+
// expected-private-member {{Swift.Hashable.callAsFunction}}
45+
// expected-private-member {{Swift.Encodable.callAsFunction}}
46+
// expected-private-member {{Swift.Decodable.callAsFunction}}
47+
// expected-private-member {{Foundation._OptionalForKVO.callAsFunction}}
48+
49+
// expected-provides {{AnyObject}}
50+
func lookupOnAnyObject(object: AnyObject) { // expected-provides {{lookupOnAnyObject}}
51+
_ = object.someMember // expected-private-dynamic-member {{someMember}}
52+
object.someMethod() // expected-private-dynamic-member {{someMethod}}
53+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %{python} %S/../gen-output-file-map.py -o %t %S
3+
// RUN: cd %t && %target-swiftc_driver -typecheck -output-file-map %t/output.json -incremental -module-name main -verify-incremental-dependencies %s
4+
5+
public protocol PublicProtocol { } // expected-provides {{PublicProtocol}}
6+
internal protocol InternalProtocol { } // expected-provides {{InternalProtocol}}
7+
fileprivate protocol FilePrivateProtocol { } // expected-provides {{FilePrivateProtocol}}
8+
private protocol PrivateProtocol { } // expected-provides {{PrivateProtocol}}
9+
10+
public struct PublicConformance { } // expected-provides {{PublicConformance}}
11+
// expected-cascading-member {{main.PublicConformance.init}}
12+
13+
// expected-cascading-member {{main.PublicConformance.deinit}}
14+
extension PublicConformance: PublicProtocol { }
15+
extension PublicConformance: InternalProtocol { }
16+
extension PublicConformance: FilePrivateProtocol { }
17+
extension PublicConformance: PrivateProtocol { }
18+
19+
20+
private struct PrivateConformance { } // expected-provides {{PrivateConformance}}
21+
// expected-cascading-member {{main.PrivateConformance.init}}
22+
23+
// FIXME: This could be a private dependency...
24+
// expected-cascading-member {{main.PrivateConformance.deinit}}
25+
extension PrivateConformance: PublicProtocol { } // expected-cascading-conformance {{main.PublicProtocol}}
26+
extension PrivateConformance: InternalProtocol { } // expected-cascading-conformance {{main.InternalProtocol}}
27+
extension PrivateConformance: FilePrivateProtocol { } // expected-cascading-conformance {{main.FilePrivateProtocol}}
28+
extension PrivateConformance: PrivateProtocol { } // expected-cascading-conformance {{main.PrivateProtocol}}
29+

0 commit comments

Comments
 (0)