Skip to content

Commit 9788492

Browse files
authored
[test] Fix class_getImageName.swift on 32-bit iOS simulator (#17943)
The deallocation order is important in these tests, so we need to take autorelease pools out of the equation. rdar://problem/42178988
1 parent 9c6ab5b commit 9788492

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

test/Interpreter/SDK/class_getImageName.swift

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -65,38 +65,44 @@ testSuite.test("KVO/Simple") {
6565
// We use object_getClass in this test to not look through KVO's artificial
6666
// subclass.
6767
let obj = SimpleNSObject()
68-
let observation = obj.observe(\.observableName) { _, _ in }
69-
withExtendedLifetime(observation) {
70-
let theClass = object_getClass(obj)
71-
precondition(theClass !== SimpleNSObject.self, "no KVO subclass?")
72-
expectNil(class_getImageName(theClass),
73-
"should match what happens with NSObject (below)")
68+
autoreleasepool {
69+
let observation = obj.observe(\.observableName) { _, _ in }
70+
withExtendedLifetime(observation) {
71+
let theClass = object_getClass(obj)
72+
precondition(theClass !== SimpleNSObject.self, "no KVO subclass?")
73+
expectNil(class_getImageName(theClass),
74+
"should match what happens with NSObject (below)")
75+
}
7476
}
7577
}
7678

7779
testSuite.test("KVO/GenericAncestry") {
7880
// We use object_getClass in this test to not look through KVO's artificial
7981
// subclass.
8082
let obj = GenericAncestryNSObject()
81-
let observation = obj.observe(\.observableName) { _, _ in }
82-
withExtendedLifetime(observation) {
83-
let theClass = object_getClass(obj)
84-
precondition(theClass !== GenericAncestryNSObject.self, "no KVO subclass?")
85-
expectNil(class_getImageName(theClass),
86-
"should match what happens with NSObject (below)")
83+
autoreleasepool {
84+
let observation = obj.observe(\.observableName) { _, _ in }
85+
withExtendedLifetime(observation) {
86+
let theClass = object_getClass(obj)
87+
precondition(theClass !== GenericAncestryNSObject.self, "no KVO subclass?")
88+
expectNil(class_getImageName(theClass),
89+
"should match what happens with NSObject (below)")
90+
}
8791
}
8892
}
8993

9094
testSuite.test("KVO/ObjC") {
9195
// We use object_getClass in this test to not look through KVO's artificial
9296
// subclass.
9397
let obj = NSObject()
94-
let observation = obj.observe(\.description) { _, _ in }
95-
withExtendedLifetime(observation) {
96-
let theClass = object_getClass(obj)
97-
precondition(theClass !== NSObject.self, "no KVO subclass?")
98-
expectNil(class_getImageName(theClass),
99-
"should match what happens with the Swift objects (above)")
98+
autoreleasepool {
99+
let observation = obj.observe(\.description) { _, _ in }
100+
withExtendedLifetime(observation) {
101+
let theClass = object_getClass(obj)
102+
precondition(theClass !== NSObject.self, "no KVO subclass?")
103+
expectNil(class_getImageName(theClass),
104+
"should match what happens with the Swift objects (above)")
105+
}
100106
}
101107
}
102108

0 commit comments

Comments
 (0)