Skip to content

Commit

Permalink
Uncomment test which was blocked on extensions not being picked up (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
ktoso authored Dec 5, 2022
1 parent 83d75a6 commit b7b531f
Showing 1 changed file with 50 additions and 52 deletions.
102 changes: 50 additions & 52 deletions fdbserver/swift/tests/swift_test_task.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,58 +33,56 @@ struct TaskTests: SimpleSwiftTestSuite {
_ = try await voidF.waitValue
}

// FIXME(swift): Somehow the waitValue is broken on FutureCInt: https://github.com/FoundationDB/foundationdb-swift/pull/31
// TestCase("await \(FutureCInt.self)") {
// let p = PromiseCInt()
// var intF: FutureCInt = p.__getFutureUnsafe()
//
// var value: CInt = 42
// p.send(&value)
// let got = try await intF.waitValue
// precondition(got == value, "\(got) did not equal \(value)")
// }

// FIXME(swift): Somehow the waitValue is broken on FutureCInt: https://github.com/FoundationDB/foundationdb-swift/pull/31
// TestCase("more Flow task await tests") {
// let p: PromiseCInt = PromiseCInt()
// var f: FutureCInt = p.__getFutureUnsafe() // FIXME(swift): getFuture: C++ method 'getFuture' that returns unsafe projection of type 'Future' not imported
// // TODO(swift): we perhaps should add a note that __getFutureUnsafe is available?
//
// pprint("got PromiseCInt") // FIXME(swift/c++): printing the promise crashes!
// precondition(!f.isReady(), "Future should not be ready yet")
//
// var num = 1111
// pprint("send \(num)") // FIXME: printing the promise crashes!
// p.send(&num) // FIXME: rdar://99583467 ([C++ interop][fdb] Support xvalues, so we can use Future.send(U&& value))
// pprint("without wait, f.get(): \(f.__getUnsafe().pointee)")
//
// pprint("wait...")
// let value: CInt = try await f.waitValue
// assertOnNet2EventLoop() // hopped back to the right executor, yay
// precondition(f.isReady(), "Future should be ready by now")
//
// pprint("await value = \(value)")
// precondition((value ?? -1) == num, "Value obtained from await did not match \(num), was: \(String(describing: value))!")
//
// pprint("[swift][tid:\(_tid())][\(#fileID):\(#line)](\(#function)) future 2 --------------------")
// let p2 = PromiseCInt()
// var f2: FutureCInt = p2.__getFutureUnsafe() // FIXME: Make these not unsafe...
// let num2 = 2222
// Task { [num2] in
// assertOnNet2EventLoop()
//
// pprint("[swift][tid:\(_tid())][\(#fileID):\(#line)](\(#function)) future 2: send \(num2)")
// var workaroundVar = num2 // FIXME workaround since we need inout xvalue for the C++ send()
// p2.send(&workaroundVar)
// }
// pprint("[swift][tid:\(_tid())][\(#fileID):\(#line)](\(#function)) future 2: waiting...")
// let got2: CInt? = try? await f2.waitValue
// pprint("[swift][tid:\(_tid())][\(#fileID):\(#line)](\(#function)) future 2, got: \(String(describing: got2))")
// precondition(got2! == num2, "Value obtained from send after await did not match \(num2), was: \(String(describing: got2))!")
//
// // assert that we hopped back and are again on the Net2 event loop thread:
// assertOnNet2EventLoop()
// }
TestCase("await \(FutureCInt.self)") {
let p = PromiseCInt()
var intF: FutureCInt = p.__getFutureUnsafe()

var value: CInt = 42
p.send(&value)
let got = try await intF.waitValue
precondition(got == value, "\(got) did not equal \(value)")
}

TestCase("more Flow task await tests") {
let p: PromiseCInt = PromiseCInt()
var f: FutureCInt = p.__getFutureUnsafe() // FIXME(swift): getFuture: C++ method 'getFuture' that returns unsafe projection of type 'Future' not imported
// TODO(swift): we perhaps should add a note that __getFutureUnsafe is available?

pprint("got PromiseCInt") // FIXME(swift/c++): printing the promise crashes!
precondition(!f.isReady(), "Future should not be ready yet")

var num = 1111
pprint("send \(num)") // FIXME: printing the promise crashes!
p.send(&num) // FIXME: rdar://99583467 ([C++ interop][fdb] Support xvalues, so we can use Future.send(U&& value))
pprint("without wait, f.get(): \(f.__getUnsafe().pointee)")

pprint("wait...")
let value: CInt = try await f.waitValue
assertOnNet2EventLoop() // hopped back to the right executor, yay
precondition(f.isReady(), "Future should be ready by now")

pprint("await value = \(value)")
precondition((value) == num, "Value obtained from await did not match \(num), was: \(String(describing: value))!")

pprint("[swift][tid:\(_tid())][\(#fileID):\(#line)](\(#function)) future 2 --------------------")
let p2 = PromiseCInt()
var f2: FutureCInt = p2.__getFutureUnsafe() // FIXME: Make these not unsafe...
let num2 = 2222
Task { [num2] in
assertOnNet2EventLoop()

pprint("[swift][tid:\(_tid())][\(#fileID):\(#line)](\(#function)) future 2: send \(num2)")
var workaroundVar = num2 // FIXME workaround since we need inout xvalue for the C++ send()
p2.send(&workaroundVar)
}
pprint("[swift][tid:\(_tid())][\(#fileID):\(#line)](\(#function)) future 2: waiting...")
let got2: CInt? = try? await f2.waitValue
pprint("[swift][tid:\(_tid())][\(#fileID):\(#line)](\(#function)) future 2, got: \(String(describing: got2))")
precondition(got2! == num2, "Value obtained from send after await did not match \(num2), was: \(String(describing: got2))!")

// assert that we hopped back and are again on the Net2 event loop thread:
assertOnNet2EventLoop()
}

TestCase("Flow task priorities in Task.priority") {
await Task { assertOnNet2EventLoop() }.value
Expand Down

0 comments on commit b7b531f

Please sign in to comment.