Skip to content

Commit 2e12ac8

Browse files
authored
Merge pull request #24836 from bob-wilson/rdar50173830
[Test] Conditionalize KVOKeyPaths tests that only work with Swift 5.1
2 parents 8c1a1dc + 1e3317b commit 2e12ac8

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

test/stdlib/KVOKeyPaths.swift

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
// RUN: %target-run-simple-swift | %FileCheck %s
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-build-swift %s -o %t/a.out
3+
// RUN: %target-codesign %t/a.out
4+
// RUN: %target-run %t/a.out | grep 'check-prefix' > %t/prefix-option
5+
// RUN: %target-run %t/a.out | %FileCheck -check-prefix=CHECK `cat %t/prefix-option` %s
26
// REQUIRES: executable_test
37

48
// REQUIRES: objc_interop
@@ -117,6 +121,16 @@ print("target removed")
117121
// Test NSKeyValueObservingCustomization issue with observing from the callbacks
118122
//===----------------------------------------------------------------------===//
119123

124+
// The following tests are only expected to pass when running with the
125+
// Swift 5.1 and later libraries.
126+
if #available(iOS 9999, macOS 9999, tvOS 9999, watchOS 9999, *) {
127+
print("-check-prefix=CHECK-51")
128+
} else {
129+
print("-check-prefix=DONT-CHECK")
130+
// Need at least one check, otherwise FileCheck will complain.
131+
// DONT-CHECK: {{.}}
132+
}
133+
120134
class Target2 : NSObject, NSKeyValueObservingCustomization {
121135
@objc dynamic var name: String?
122136

@@ -151,10 +165,10 @@ withExtendedLifetime(Target2()) { (target) in
151165
}
152166
print("observer removed")
153167

154-
// CHECK-LABEL: registering observer for Target2
155-
// CHECK-DAG: keyPathsAffectingValue: key == \.name: true
156-
// CHECK-DAG: automaticallyNotifiesObservers: key == \.name: true
157-
// CHECK-NEXT: observer removed
168+
// CHECK-51-LABEL: registering observer for Target2
169+
// CHECK-51-DAG: keyPathsAffectingValue: key == \.name: true
170+
// CHECK-51-DAG: automaticallyNotifiesObservers: key == \.name: true
171+
// CHECK-51-NEXT: observer removed
158172

159173
//===----------------------------------------------------------------------===//
160174
// Test NSSortDescriptor keyPath support
@@ -175,5 +189,5 @@ let descriptor = NSSortDescriptor(keyPath: \Sortable1.name, ascending: true)
175189
_ = NSSortDescriptor(keyPath: \Sortable2.name, ascending: true)
176190
print("keyPath == \\Sortable1.name:", descriptor.keyPath == \Sortable1.name)
177191

178-
// CHECK-LABEL: creating NSSortDescriptor
179-
// CHECK-NEXT: keyPath == \Sortable1.name: true
192+
// CHECK-51-LABEL: creating NSSortDescriptor
193+
// CHECK-51-NEXT: keyPath == \Sortable1.name: true

0 commit comments

Comments
 (0)