Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests fail to build in Xcode 16 beta #167

Closed
bdbergeron opened this issue Jun 13, 2024 · 3 comments
Closed

Tests fail to build in Xcode 16 beta #167

bdbergeron opened this issue Jun 13, 2024 · 3 comments
Labels
apple bug Something isn't working due to a bug on Apple's platforms

Comments

@bdbergeron
Copy link

bdbergeron commented Jun 13, 2024

Describe the bug
I'm using this library as part of a feature that uses TCA, and I believe that it's the CasePaths library specifically that's causing my test suite to fail to build. The app itself builds and runs as expected.

To Reproduce
I have two tests that cover both the success and failure cases of an Action that has an associated value of Result<Void, Error> type, used within a feature annotated with the @Reducer macro:

@Reducer
struct MyFeature {
  enum Action: Sendable {
    case didFinishLoading(Result<Void, Error>)
    ...
  }
  ...
}

My test cases look like this:

final class MyFeatureTests: XCTestCase {
  @MainActor
  func test_fetch_success() async {
    let store = TestStore(initialState: MyFeature.State()) {
        MyFeature()
    }
    await store.send(.fetch) {
      $0.isFetching = true
    }
    await store.receive(\.setFetchingFinished.success) {
      $0.isFetching = false
    }
  }

  @MainActor
  func test_fetch_failure() async {
    let store = TestStore(initialState: MyFeature.State()) {
      MyFeature()
    } withDependencies: {
      $0.fetchAction = {
        throw TestError.expected
      }
    }
    await store.send(.fetch) {
      $0.isFetching = true
    }
    await store.receive(\.setFetchingFinished.failure) {
      $0.isFetching = false
      $0.navigationDestination = .alert(AlertState { TextState("Expected error.") })
    }
  }
}

private enum TestError: LocalizedError {
  case expected

  var errorDescription: String? {
    switch self {
    case .expected:
      "Expected error."
    }
  }
}

Expected behavior
The test suite should build without error.

Environment

  • swift-case-paths 1.4.2
  • Xcode 16.0 beta 1
  • Swift 6.0
  • OS: macOS Sonoma 14.5

Additional context
Changing the Void success type to some other concrete type such as Bool results in the tests building successfully. Also removing the .success and .failure from the case path in the .receive() calls results in the tests building successfully.

I use the Void type in this instance because I have an external (non-TCA) object that handles the loading and data management that the .fetch action triggers.

@bdbergeron bdbergeron changed the title Tests fail to build in Xcode 16 beta when using Swift 6 language mode Tests fail to build in Xcode 16 beta Jun 13, 2024
@stephencelis
Copy link
Member

@bdbergeron Can you zip up and share a project that reproduces the issue? The code snippet above unfortunately isn't enough to debug things.

@bdbergeron
Copy link
Author

@stephencelis sure thing, here y'a go: TCATestIssueRepro.zip

@stephencelis
Copy link
Member

@bdbergeron As far as I can tell this is a Swift bug/regression that affects all the way back to swift-case-paths 1.1, where the macros were first introduced, and I haven't been able to figure out a workaround in the library itself to support the preexisting types.

Can you file a bug with apple/swift and report back here? I'll try to spend some time reducing the problem tomorrow, but it'd be good to flag the regression with Apple.

Since this is an Apple bug that we can't do much about, I'm going to convert to a discussion, but hopefully it gets fixed soon.

@stephencelis stephencelis added the apple bug Something isn't working due to a bug on Apple's platforms label Jun 14, 2024
@pointfreeco pointfreeco locked and limited conversation to collaborators Jun 14, 2024
@stephencelis stephencelis converted this issue into discussion #169 Jun 14, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
apple bug Something isn't working due to a bug on Apple's platforms
Projects
None yet
Development

No branches or pull requests

2 participants