Skip to content

Skip transpiler fails transpiling XCTest with async setup #651

@dfabulich

Description

@dfabulich
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()
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions