Skip transpiler fails transpiling XCTest with async setup
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 3.2k
- Forks
- 106
- Avg merge
- 6d 13h
- Merged PRs (30d)
- 1
Description
import XCTest
final class AsyncSetUpTranspilerReproTests: XCTestCase {
private var valueFromAsyncSetUp: String!
override func setUp() async throws {
try await super.setUp()
valueFromAsyncSetUp = try await Self.sleepThenReturnExpectedString()
}
private static func sleepThenReturnExpectedString() async throws -> String {
try await Task.sleep(nanoseconds: 10_000_000)
return "expected-after-sleep"
}
func testAsyncSetUpStoresExpectedString() throws {
XCTAssertEqual(valueFromAsyncSetUp, "expected-after-sleep")
}
}
This test passes in native Swift, but, after transpilation, it fails to compile.
e: file:///private/tmp/tp/lib-project/.build/plugins/outputs/lib-project/ModuleNameTests/destination/skipstone/ModuleName/src/test/kotlin/module/name/AsyncSetUpTranspilerReproTests.kt:11:26 Suspend function 'setUp' cannot override non-suspend function 'fun setUp(): Unit' defined in 'skip.unit.XCTestCase'.
The setUp() function transpiles to this:
override suspend fun setUp(): Unit = Async.run {
super.setUp()
valueFromAsyncSetUp = Companion.sleepThenReturnExpectedString()
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Swift XCTest reproduction and the generated Kotlin file at .build/plugins/outputs/lib-project/ModuleNameTests/destination/skipstone/ModuleName/src/test/kotlin/module/name/AsyncSetUpTranspilerReproTests.kt. Trace how async XCTest setUp is transpiled and compare the generated override with skip.unit.XCTestCase. Done means the transpiled test compiles and passes like the native Swift test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin, swift
- Domain
- mobile-dev, testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100