Skip to content

Commit 9af514f

Browse files
committed
Merge pull request #2544 from rintaro/test-nondarwin-1
2 parents eb435cb + 385cbfc commit 9af514f

File tree

6 files changed

+89
-41
lines changed

6 files changed

+89
-41
lines changed

Diff for: test/1_stdlib/ManagedBuffer.swift

+5-4
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@
1212
// RUN: %target-run-simple-swift
1313
// REQUIRES: executable_test
1414

15-
// FIXME: rdar://problem/19648117 Needs splitting objc parts out
16-
// XFAIL: linux
17-
1815
import StdlibUnittest
1916

2017

18+
#if _runtime(_ObjC)
2119
import Foundation
20+
#endif
2221

2322
// Check that `NonObjectiveCBase` can be subclassed and the subclass can be
2423
// created.
@@ -147,7 +146,7 @@ tests.test("basic") {
147146
let s = TestManagedBuffer<LifetimeTracked>.create(10)
148147
expectEqual(0, s.count)
149148
expectLE(10, s.myCapacity)
150-
expectGE(12, s.myCapacity) // allow some over-allocation but not too much
149+
expectGE(13, s.myCapacity) // allow some over-allocation but not too much
151150

152151
expectEqual(1, LifetimeTracked.instances)
153152
for i in 1..<6 {
@@ -262,8 +261,10 @@ tests.test("isUniquelyReferencedNonObjC") {
262261
var s2 = s
263262
expectFalse(isUniquelyReferencedNonObjC(&s))
264263
expectFalse(isUniquelyReferencedNonObjC(&s2))
264+
#if _runtime(_ObjC)
265265
var s3 = NSArray()
266266
expectFalse(isUniquelyReferencedNonObjC(&s3))
267+
#endif
267268
_fixLifetime(s)
268269
_fixLifetime(s2)
269270
}

Diff for: test/1_stdlib/Mirror.swift

+14-4
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@
1212
// RUN: rm -rf %t
1313
// RUN: mkdir -p %t
1414
//
15-
// RUN: %target-clang %S/Inputs/Mirror/Mirror.mm -c -o %t/Mirror.mm.o -g
16-
// RUN: %target-build-swift %s -I %S/Inputs/Mirror/ -Xlinker %t/Mirror.mm.o -o %t/Mirror
15+
// RUN: if [ %target-runtime == "objc" ]; \
16+
// RUN: then \
17+
// RUN: %target-clang %S/Inputs/Mirror/Mirror.mm -c -o %t/Mirror.mm.o -g && \
18+
// RUN: %target-build-swift %s -I %S/Inputs/Mirror/ -Xlinker %t/Mirror.mm.o -o %t/Mirror; \
19+
// RUN: else \
20+
// RUN: %target-build-swift %s -o %t/Mirror; \
21+
// RUN: fi
1722
// RUN: %target-run %t/Mirror
1823
// REQUIRES: executable_test
1924

20-
// XFAIL: linux
21-
2225
import StdlibUnittest
2326

2427

@@ -354,6 +357,7 @@ mirrors.test("class/CustomizedSuper/Synthesized") {
354357
}
355358
}
356359

360+
#if _runtime(_ObjC)
357361
import Foundation
358362

359363
//===--- ObjC Base Classes ------------------------------------------------===//
@@ -461,6 +465,7 @@ mirrors.test("class/ObjCCustomizedSuper/Synthesized") {
461465
}
462466
}
463467
}
468+
#endif // _runtime(_ObjC)
464469

465470
//===--- Suppressed Superclass Mirrors ------------------------------------===//
466471
mirrors.test("Class/Root/NoSuperclassMirror") {
@@ -717,7 +722,10 @@ mirrors.test("PlaygroundQuickLook") {
717722
struct X {}
718723
switch PlaygroundQuickLook(reflecting: X()) {
719724
case .text(let text):
725+
#if _runtime(_ObjC)
726+
// FIXME: Enable if non-objc hasSuffix is implemented.
720727
expectTrue(text.hasSuffix(".(X #1)()"), text)
728+
#endif
721729
default:
722730
expectTrue(false)
723731
}
@@ -759,13 +767,15 @@ mirrors.test("_DefaultCustomPlaygroundQuickLookable") {
759767
}
760768
}
761769

770+
#if _runtime(_ObjC)
762771
import MirrorObjC
763772
mirrors.test("ObjC") {
764773
// Some Foundation classes lie about their ivars, which would crash
765774
// a mirror; make sure we are not automatically exposing ivars of
766775
// Objective-C classes from the default mirror implementation.
767776
expectEqual(0, Mirror(reflecting: HasIVars()).children.count)
768777
}
778+
#endif
769779

770780
mirrors.test("String.init") {
771781
expectEqual("42", String(42))

Diff for: test/Interpreter/SDK/libc.swift

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
// RUN: %target-run-simple-swift %s %t | FileCheck %s
66
// REQUIRES: executable_test
77

8-
// XFAIL: linux
9-
10-
import Darwin
8+
#if os(OSX) || os(iOS) || os(watchOS) || os(tvOS)
9+
import Darwin
10+
#elseif os(Linux) || os(FreeBSD) || os(Android)
11+
import Glibc
12+
#endif
1113

1214
let sourcePath = Process.arguments[1]
1315
let tempPath = Process.arguments[2] + "/libc.txt"

Diff for: validation-test/stdlib/ArrayNew.swift.gyb

+19-8
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,19 @@
22
// RUN: mkdir -p %t
33
//
44
// RUN: %S/../../utils/gyb %s -o %t/main.swift
5-
// RUN: %target-clang -fobjc-arc %S/Inputs/SlurpFastEnumeration/SlurpFastEnumeration.m -c -o %t/SlurpFastEnumeration.o
6-
// RUN: %S/../../utils/line-directive %t/main.swift -- %target-build-swift %S/Inputs/DictionaryKeyValueTypes.swift %S/Inputs/DictionaryKeyValueTypesObjC.swift %t/main.swift -I %S/Inputs/SlurpFastEnumeration/ -Xlinker %t/SlurpFastEnumeration.o -o %t/Array -Xfrontend -disable-access-control
5+
// RUN: if [ %target-runtime == "objc" ]; then \
6+
// RUN: %target-clang -fobjc-arc %S/Inputs/SlurpFastEnumeration/SlurpFastEnumeration.m -c -o %t/SlurpFastEnumeration.o; \
7+
// RUN: %S/../../utils/line-directive %t/main.swift -- %target-build-swift %S/Inputs/DictionaryKeyValueTypes.swift %S/Inputs/DictionaryKeyValueTypesObjC.swift %t/main.swift -I %S/Inputs/SlurpFastEnumeration/ -Xlinker %t/SlurpFastEnumeration.o -o %t/Array -Xfrontend -disable-access-control; \
8+
// RUN: else \
9+
// RUN: %S/../../utils/line-directive %t/main.swift -- %target-build-swift %S/Inputs/DictionaryKeyValueTypes.swift %t/main.swift -o %t/Array -Xfrontend -disable-objc-attr-requires-foundation-module -Xfrontend -disable-access-control; \
10+
// RUN: fi
711
// RUN: %S/../../utils/line-directive %t/main.swift -- %target-run %t/Array
812
// REQUIRES: executable_test
913

10-
// XFAIL: linux
11-
12-
import Darwin
1314
import StdlibUnittest
1415
import StdlibCollectionUnittest
1516

1617

17-
import StdlibUnittestFoundationExtras
18-
import Foundation
19-
2018
%{
2119
all_array_types = ['ContiguousArray', 'ArraySlice', 'Array']
2220
}%
@@ -56,6 +54,9 @@ func withInoutT<T>(_ x: inout T, body: (x: inout T) -> Void) {
5654

5755
% for element_type in ['TestValueTy', 'TestBridgedValueTy']:
5856
% for array_type in all_array_types:
57+
% if element_type == 'TestBridgedValueTy':
58+
#if _runtime(_ObjC)
59+
% end
5960

6061
ArrayTestSuite.test("${array_type}<${element_type}>/subscript(_: Int)/COW") {
6162
var a: ${array_type}<${array_type}<${element_type}>> = [[
@@ -225,9 +226,17 @@ ArrayTestSuite.test("${array_type}<${element_type}>/subscript(_: Range<Int>)/COW
225226
expectEqual(90, a[0][8].value)
226227
}
227228

229+
% if element_type == 'TestBridgedValueTy':
230+
#endif // _runtime(_ObjC)
231+
% end
228232
% end
229233
% end
230234

235+
#if _runtime(_ObjC)
236+
import Darwin
237+
import StdlibUnittestFoundationExtras
238+
import Foundation
239+
231240
// FIXME: all the tests below are applicable to ArraySlice, too.
232241

233242
//===----------------------------------------------------------------------===//
@@ -1140,5 +1149,7 @@ ArrayTestSuite.tearDown {
11401149
}
11411150
}
11421151

1152+
#endif // _runtime(_ObjC)
1153+
11431154
runAllTests()
11441155

Diff for: validation-test/stdlib/Dictionary.swift

+36-15
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,30 @@
22
// RUN: mkdir -p %t
33
//
44
// RUN: %S/../../utils/gyb %s -o %t/main.swift
5-
// RUN: %target-clang -fobjc-arc %S/Inputs/SlurpFastEnumeration/SlurpFastEnumeration.m -c -o %t/SlurpFastEnumeration.o
6-
// RUN: %S/../../utils/line-directive %t/main.swift -- %target-build-swift %S/Inputs/DictionaryKeyValueTypes.swift %S/Inputs/DictionaryKeyValueTypesObjC.swift %t/main.swift -I %S/Inputs/SlurpFastEnumeration/ -Xlinker %t/SlurpFastEnumeration.o -o %t/Dictionary -Xfrontend -disable-access-control
5+
// RUN: if [ %target-runtime == "objc" ]; then \
6+
// RUN: %target-clang -fobjc-arc %S/Inputs/SlurpFastEnumeration/SlurpFastEnumeration.m -c -o %t/SlurpFastEnumeration.o; \
7+
// RUN: %S/../../utils/line-directive %t/main.swift -- %target-build-swift %S/Inputs/DictionaryKeyValueTypes.swift %S/Inputs/DictionaryKeyValueTypesObjC.swift %t/main.swift -I %S/Inputs/SlurpFastEnumeration/ -Xlinker %t/SlurpFastEnumeration.o -o %t/Dictionary -Xfrontend -disable-access-control; \
8+
// RUN: else \
9+
// RUN: %S/../../utils/line-directive %t/main.swift -- %target-build-swift %S/Inputs/DictionaryKeyValueTypes.swift %t/main.swift -o %t/Dictionary -Xfrontend -disable-access-control -Xfrontend -disable-objc-attr-requires-foundation-module; \
10+
// RUN: fi
711
//
812
// RUN: %S/../../utils/line-directive %t/main.swift -- %target-run %t/Dictionary
913
// REQUIRES: executable_test
1014

11-
// XFAIL: linux
12-
15+
#if os(OSX) || os(iOS) || os(tvOS) || os(watchOS)
1316
import Darwin
17+
#else
18+
import Glibc
19+
#endif
20+
1421
import StdlibUnittest
1522
import StdlibCollectionUnittest
1623

1724

25+
#if _runtime(_ObjC)
1826
import Foundation
1927
import StdlibUnittestFoundationExtras
28+
#endif
2029

2130
// Check that the generic parameters are called 'Key' and 'Value'.
2231
protocol TestProtocol1 {}
@@ -1142,6 +1151,7 @@ DictionaryTestSuite.test("init(dictionaryLiteral:)") {
11421151
}
11431152
}
11441153

1154+
#if _runtime(_ObjC)
11451155
//===---
11461156
// NSDictionary -> Dictionary bridging tests.
11471157
//===---
@@ -3410,6 +3420,7 @@ DictionaryTestSuite.test("DictionaryBridgeFromObjectiveCConditional") {
34103420
assert(false)
34113421
}
34123422
}
3423+
#endif // _runtime(_ObjC)
34133424

34143425
//===---
34153426
// Tests for APIs implemented strictly based on public interface. We only need
@@ -3426,6 +3437,18 @@ func getDerivedAPIsDictionary() -> Dictionary<Int, Int> {
34263437

34273438
var DictionaryDerivedAPIs = TestSuite("DictionaryDerivedAPIs")
34283439

3440+
DictionaryDerivedAPIs.test("isEmpty") {
3441+
do {
3442+
var empty = Dictionary<Int, Int>()
3443+
expectTrue(empty.isEmpty)
3444+
}
3445+
do {
3446+
var d = getDerivedAPIsDictionary()
3447+
expectFalse(d.isEmpty)
3448+
}
3449+
}
3450+
3451+
#if _runtime(_ObjC)
34293452
@objc
34303453
class MockDictionaryWithCustomCount : NSDictionary {
34313454
init(count: Int) {
@@ -3478,17 +3501,6 @@ func getMockDictionaryWithCustomCount(count: Int)
34783501
return MockDictionaryWithCustomCount(count: count) as Dictionary
34793502
}
34803503

3481-
DictionaryDerivedAPIs.test("isEmpty") {
3482-
do {
3483-
var empty = Dictionary<Int, Int>()
3484-
expectTrue(empty.isEmpty)
3485-
}
3486-
do {
3487-
var d = getDerivedAPIsDictionary()
3488-
expectFalse(d.isEmpty)
3489-
}
3490-
}
3491-
34923504
func callGenericIsEmpty<C : Collection>(_ collection: C) -> Bool {
34933505
return collection.isEmpty
34943506
}
@@ -3520,6 +3532,7 @@ DictionaryDerivedAPIs.test("isEmpty/ImplementationIsCustomized") {
35203532
expectEqual(1, MockDictionaryWithCustomCount.timesCountWasCalled)
35213533
}
35223534
}
3535+
#endif // _runtime(_ObjC)
35233536

35243537
DictionaryDerivedAPIs.test("keys") {
35253538
do {
@@ -3552,6 +3565,7 @@ DictionaryDerivedAPIs.test("values") {
35523565
}
35533566
}
35543567

3568+
#if _runtime(_ObjC)
35553569
var ObjCThunks = TestSuite("ObjCThunks")
35563570

35573571
class ObjCThunksHelper : NSObject {
@@ -3695,6 +3709,7 @@ ObjCThunks.test("Dictionary/Return") {
36953709
expectEqual(0, TestBridgedValueTy.bridgeOperations)
36963710
}
36973711
}
3712+
#endif // _runtime(_ObjC)
36983713

36993714
//===---
37003715
// Check that iterators traverse a snapshot of the collection.
@@ -3822,6 +3837,7 @@ DictionaryTestSuite.test("misc") {
38223837
}
38233838
}
38243839

3840+
#if _runtime(_ObjC)
38253841
DictionaryTestSuite.test("dropsBridgedCache") {
38263842
// rdar://problem/18544533
38273843
// Previously this code would segfault due to a double free in the Dictionary
@@ -3861,6 +3877,7 @@ DictionaryTestSuite.test("getObjects:andKeys:") {
38613877
expectEqual([2, 1] as [NSNumber], Array(keys))
38623878
expectEqual(["two", "one"] as [NSString], Array(values))
38633879
}
3880+
#endif
38643881

38653882
DictionaryTestSuite.test("popFirst") {
38663883
// Empty
@@ -3909,12 +3926,16 @@ DictionaryTestSuite.test("removeAt") {
39093926

39103927
DictionaryTestSuite.setUp {
39113928
resetLeaksOfDictionaryKeysValues()
3929+
#if _runtime(_ObjC)
39123930
resetLeaksOfObjCDictionaryKeysValues()
3931+
#endif
39133932
}
39143933

39153934
DictionaryTestSuite.tearDown {
39163935
expectNoLeaksOfDictionaryKeysValues()
3936+
#if _runtime(_ObjC)
39173937
expectNoLeaksOfObjCDictionaryKeysValues()
3938+
#endif
39183939
}
39193940

39203941
runAllTests()

Diff for: validation-test/stdlib/Unicode.swift

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
// RUN: %target-run-simple-swift
1+
// RUN: rm -rf %t
2+
// RUN: mkdir -p %t
3+
// RUN: %target-build-swift %s -o %t/a.out -Xfrontend -disable-objc-attr-requires-foundation-module
4+
// RUN: %target-run %t/a.out
25
// REQUIRES: executable_test
36

4-
// FIXME: rdar://problem/19648117 Needs splitting objc parts out
5-
// XFAIL: linux
6-
77
import SwiftPrivate
88
import StdlibUnittest
99
import StdlibCollectionUnittest
1010

1111

12-
import Foundation
13-
1412
var UTF16APIs = TestSuite("UTF16APIs")
1513

1614
UTF16APIs.test("width") {
@@ -816,7 +814,7 @@ UTF8Decoder.test("Internal/_decodeOne") {
816814
var validLengthCounts = [ 0, 0, 0, 0, 0 ]
817815
var maximalSubpartCounts = [ 0, 0, 0, 0, 0 ]
818816
func countValidSequences(
819-
head head: CountableClosedRange<UInt32>, tail: CountableClosedRange<UInt32>
817+
head: CountableClosedRange<UInt32>, tail: CountableClosedRange<UInt32>
820818
) {
821819
for cu0 in head {
822820
for rest in tail {
@@ -2157,6 +2155,9 @@ UnicodeAPIs.test("transcode/ReferenceTypedArray") {
21572155
expectEqual(input, transcoded)
21582156
}
21592157

2158+
#if _runtime(_ObjC)
2159+
import Foundation
2160+
21602161
// The most simple subclass of NSString that CoreFoundation does not know
21612162
// about.
21622163
class NonContiguousNSString : NSString {
@@ -2461,5 +2462,7 @@ StringTests.test("StreamableConformance") {
24612462
}
24622463
}
24632464

2465+
#endif // _runtime(_ObjC)
2466+
24642467
runAllTests()
24652468

0 commit comments

Comments
 (0)