Skip to content

Commit f714ff5

Browse files
committed
[libdispatch] fixup tests for new syntax
* Several swift tests rely on old libdispatch syntax. This change adopts the new syntax throughout the swift tests.
1 parent 11a6dcd commit f714ff5

File tree

6 files changed

+35
-34
lines changed

6 files changed

+35
-34
lines changed

test/1_stdlib/Dispatch.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ DispatchAPI.test("constants") {
1818

1919
// This is a lousy test, but really we just care that
2020
// DISPATCH_QUEUE_CONCURRENT comes through at all.
21-
_ = DispatchQueueAttributes.concurrent
21+
_ = DispatchQueue.Attributes.concurrent
2222
}
2323

2424
DispatchAPI.test("OS_OBJECT support") {
@@ -56,7 +56,7 @@ if #available(OSX 10.10, iOS 8.0, *) {
5656
_ = 1
5757
}
5858

59-
DispatchQueue.main.asynchronously(execute: block)
59+
DispatchQueue.main.async(execute: block)
6060
// This will trap if the block's pointer identity is not preserved.
6161
block.cancel()
6262
}

test/1_stdlib/DispatchTypes.swift

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,30 @@ func getAnyValue<T>(_ opt: T?) -> T { return opt! }
99
// dispatch/io.h
1010
let io = DispatchIO(type: .stream, fileDescriptor: 0, queue: DispatchQueue.main, cleanupHandler: { (error: Int32) -> () in fatalError() })
1111
io.close(flags: .stop)
12-
io.setInterval(interval: 0, flags: .strictInterval)
12+
io.setInterval(interval: .seconds(0), flags: .strictInterval)
1313

1414
// dispatch/queue.h
15-
let q = DispatchQueue(label: "", attributes: .serial)
15+
let q = DispatchQueue(label: "", attributes: [])
1616
_ = DispatchQueue(label: "", attributes: .concurrent)
1717
_ = q.label
1818
if #available(OSX 10.10, iOS 8.0, *) {
19-
_ = DispatchQueue.global(attributes: .qosUserInteractive)
20-
_ = DispatchQueue.global(attributes: .qosBackground)
21-
_ = DispatchQueue.global(attributes: .qosDefault)
19+
_ = DispatchQueue.global(qos: .userInteractive)
20+
_ = DispatchQueue.global(qos: .background)
21+
_ = DispatchQueue.global(qos: .default)
2222
}
2323

2424
// dispatch/source.h
25-
_ = DispatchSource.userDataAdd()
26-
_ = DispatchSource.userDataOr()
27-
_ = DispatchSource.machSend(port: mach_port_t(0), eventMask: [])
28-
_ = DispatchSource.machReceive(port: mach_port_t(0))
29-
_ = DispatchSource.memoryPressure(eventMask: [])
30-
_ = DispatchSource.process(identifier: 0, eventMask: [])
31-
_ = DispatchSource.read(fileDescriptor: 0)
32-
_ = DispatchSource.signal(signal: SIGINT)
33-
_ = DispatchSource.timer()
34-
_ = DispatchSource.fileSystemObject(fileDescriptor: 0, eventMask: [])
35-
_ = DispatchSource.write(fileDescriptor: 0)
25+
_ = DispatchSource.makeUserDataAddSource()
26+
_ = DispatchSource.makeUserDataOrSource()
27+
_ = DispatchSource.makeMachSendSource(port: mach_port_t(0), eventMask: [])
28+
_ = DispatchSource.makeMachReceiveSource(port: mach_port_t(0))
29+
_ = DispatchSource.makeMemoryPressureSource(eventMask: [])
30+
_ = DispatchSource.makeProcessSource(identifier: 0, eventMask: [])
31+
_ = DispatchSource.makeReadSource(fileDescriptor: 0)
32+
_ = DispatchSource.makeSignalSource(signal: SIGINT)
33+
_ = DispatchSource.makeTimerSource()
34+
_ = DispatchSource.makeFileSystemObjectSource(fileDescriptor: 0, eventMask: [])
35+
_ = DispatchSource.makeWriteSource(fileDescriptor: 0)
3636

3737
// dispatch/time.h
3838
_ = DispatchTime.now()

test/1_stdlib/NoFoundation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ _ = no as No
3535

3636
import Dispatch
3737
if #available(OSX 10.10, iOS 8.0, *) {
38-
print(DispatchQueue.global(attributes: .qosDefault))
38+
print(DispatchQueue.global(qos: .default))
3939
}

test/Prototypes/CollectionTransformers.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,11 +425,11 @@ final class _ForkJoinWorkerThread {
425425
internal func startAsync() {
426426
var queue: DispatchQueue? = nil
427427
if #available(OSX 10.10, iOS 8.0, *) {
428-
queue = DispatchQueue.global(attributes: .qosBackground)
428+
queue = DispatchQueue.global(qos: .background)
429429
} else {
430-
queue = DispatchQueue.global(attributes: .priorityBackground)
430+
queue = DispatchQueue.global(priority: .background)
431431
}
432-
queue!.asynchronously {
432+
queue!.async {
433433
self._thread()
434434
}
435435
}

test/Runtime/weak-reference-racetests-dispatch.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ WeakReferenceRaceTests.test("class instance property [SR-192] (copy)") {
3838
_blackHole(nbox)
3939
}
4040

41-
q.asynchronously(execute: closure)
42-
q.asynchronously(execute: closure)
41+
q.async(execute: closure)
42+
q.async(execute: closure)
4343
}
4444

45-
q.asynchronously(flags: .barrier) {}
45+
q.async(flags: .barrier) {}
4646
}
4747

4848
WeakReferenceRaceTests.test("class instance property [SR-192] (load)") {
@@ -58,11 +58,11 @@ WeakReferenceRaceTests.test("class instance property [SR-192] (load)") {
5858
}
5959
}
6060

61-
q.asynchronously(execute: closure)
62-
q.asynchronously(execute: closure)
61+
q.async(execute: closure)
62+
q.async(execute: closure)
6363
}
6464

65-
q.asynchronously(flags: .barrier) {}
65+
q.async(flags: .barrier) {}
6666
}
6767

6868
WeakReferenceRaceTests.test("direct capture (copy)") {
@@ -77,11 +77,11 @@ WeakReferenceRaceTests.test("direct capture (copy)") {
7777
_blackHole(nbox)
7878
}
7979

80-
q.asynchronously(execute: closure)
81-
q.asynchronously(execute: closure)
80+
q.async(execute: closure)
81+
q.async(execute: closure)
8282
}
8383

84-
q.asynchronously(flags: .barrier) {}
84+
q.async(flags: .barrier) {}
8585
}
8686

8787
WeakReferenceRaceTests.test("direct capture (load)") {
@@ -96,11 +96,11 @@ WeakReferenceRaceTests.test("direct capture (load)") {
9696
}
9797
}
9898

99-
q.asynchronously(execute: closure)
100-
q.asynchronously(execute: closure)
99+
q.async(execute: closure)
100+
q.async(execute: closure)
101101
}
102102

103-
q.asynchronously(flags: .barrier) {}
103+
q.async(flags: .barrier) {}
104104
}
105105

106106
runAllTests()

test/SILGen/lit.local.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ config.substitutions = list(config.substitutions)
33

44
config.substitutions.insert(0, ('%build-silgen-test-overlays',
55
'%target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) -emit-module -o %t %S/Inputs/ObjectiveC.swift && '
6+
'%target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) -emit-module -o %t %S/Inputs/Dispatch.swift && '
67
'%target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) -emit-module -o %t %S/Inputs/Foundation.swift'))

0 commit comments

Comments
 (0)