Skip to content

Cannot use conformance of 'Never' to 'TestScoping' here; 'Testing' has been imported as implementation-only in SnapshotsTestTrait.swift #969

@legoesbenr

Description

@legoesbenr

We have successfully been using the framework for snapshot testing for a long time.
This morning all our Xcode Cloud build has started failing with the error:

Cannot use conformance of 'Never' to 'TestScoping' here; 'Testing' has been imported as implementation-only
SnapshotsTestTrait.swift:37

This appears to be a problem with the implemenation-only import in that file.

#if canImport(Testing)
  // NB: We are importing only the implementation of Testing because that framework is not available
  //     in Xcode UI test targets.
  @_implementationOnly import Testing

  @_spi(Experimental)
  extension Trait where Self == _SnapshotsTestTrait {
    /// Configure snapshot testing in a suite or test.
    ///
    /// - Parameters:
    ///   - record: The record mode of the test.
    ///   - diffTool: The diff tool to use in failure messages.
    public static func snapshots(
      record: SnapshotTestingConfiguration.Record? = nil,
      diffTool: SnapshotTestingConfiguration.DiffTool? = nil
    ) -> Self {
      _SnapshotsTestTrait(
        configuration: SnapshotTestingConfiguration(
          record: record,
          diffTool: diffTool
        )
      )
    }

    /// Configure snapshot testing in a suite or test.
    ///
    /// - Parameter configuration: The configuration to use.
    public static func snapshots(
      _ configuration: SnapshotTestingConfiguration
    ) -> Self {
      _SnapshotsTestTrait(configuration: configuration)
    }
  }

  /// A type representing the configuration of snapshot testing.
  @_spi(Experimental)
  public struct _SnapshotsTestTrait: SuiteTrait, TestTrait {
    public let isRecursive = true
    let configuration: SnapshotTestingConfiguration

    // public func execute(
    //   _ function: @escaping () async throws -> Void,
    //   for test: Test,
    //   testCase: Test.Case?
    // ) async throws {
    //   try await withSnapshotTesting(
    //     record: configuration.record,
    //     diffTool: configuration.diffTool
    //   ) {
    //     try await function()
    //   }
    // }
  }
#endif

Tests has run perfectly up to now and they work locally. So it appears to be a change in Xcode Cloud.

Here's the command Xcode Cloud uses to tune tests:

Run command: 'xcodebuild build-for-testing -scheme 'AM Operator' -project '/Volumes/workspace/repository/OperatorApp/AM-Operator-App/AM Operator.xcodeproj' -destination 'platform=iOS Simulator,id=40FDE0C9-320B-4030-AB16-39F7EB933F43' -testProductsPath /Volumes/workspace/TestProducts.xctestproducts -derivedDataPath /Volumes/workspace/DerivedData -resultBundleVersion 3 -resultBundlePath /Volumes/workspace/resultbundle.xcresult -resultStreamPath /Volumes/workspace/tmp/resultBundleStream45efeb29-8273-490a-be53-e173056c70e6.json -IDEPostProgressNotifications=YES CODE_SIGN_IDENTITY=- AD_HOC_CODE_SIGNING_ALLOWED=YES COMPILER_INDEX_STORE_ENABLE=NO -hideShellScriptEnvironment'

Error: Command exited with non-zero exit-code: 65

I can see 66 unmerged pull requests and 116 reported issues. Is this library dead?

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