Skip to content

Commit 93f017b

Browse files
committed
adding one XFAIL'ed task & actor lifetime test
The `executor_deinit1` test fails 100% of the time (from what I've seen) so I thought we could track and see when/if someone happens to fix this bug. Also, added extra coverage for swiftlang#36298 via `executor_deinit2`
1 parent 872afda commit 93f017b

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// RUN: %target-run-simple-swift(-parse-as-library -Xfrontend -enable-experimental-concurrency %import-libdispatch) | %FileCheck %s
2+
3+
// REQUIRES: executable_test
4+
// REQUIRES: concurrency
5+
// REQUIRES: libdispatch
6+
7+
// FIXME: this should pass! from rdar://73266050
8+
// XFAIL: *
9+
10+
// doesn't matter that it's bool identity function or not
11+
func boolIdentityFn(_ x : Bool) -> Bool { return x }
12+
13+
actor FirstActor {
14+
func startTest() { // whether startTest is async or sync doesn't matter
15+
16+
// do not remove this call or if-statement.
17+
if boolIdentityFn(true) {}
18+
19+
}
20+
21+
deinit() {
22+
// CHECK: called deinit
23+
print("called deinit")
24+
}
25+
}
26+
27+
@main struct RunIt {
28+
static func main() async {
29+
let actor = FirstActor()
30+
await actor.startTest() // do not remove this call
31+
}
32+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// RUN: %target-run-simple-swift(-parse-as-library -Xfrontend -enable-experimental-concurrency %import-libdispatch) | %FileCheck %s
2+
3+
// REQUIRES: executable_test
4+
// REQUIRES: concurrency
5+
// REQUIRES: libdispatch
6+
7+
// this needs to match with the check count below.
8+
let NUM_TASKS : Int = 100
9+
10+
final class Capture : ConcurrentValue {
11+
func doSomething() { }
12+
deinit {
13+
// CHECK-COUNT-100: deinit was called!
14+
print("deinit was called!")
15+
}
16+
}
17+
18+
@main
19+
struct App {
20+
static func main() async {
21+
var n = 0
22+
for _ in 1...NUM_TASKS {
23+
let c = Capture()
24+
let r = Task.runDetached {
25+
c.doSomething()
26+
}
27+
await r.get()
28+
n += 1
29+
}
30+
print("test complete")
31+
}
32+
}

0 commit comments

Comments
 (0)