pointfreeco / swift-snapshot-testing

📸 Delightful Swift snapshot testing.

Home Page:https://www.pointfree.co/episodes/ep41-a-tour-of-snapshot-testing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Test delays with “Timed out waiting for the exit barrier block”

jaanus opened this issue · comments

Describe the bug

Running snapshot tests with existing screenshots results in test delays and “Timed out waiting for the exit barrier block” messages on console.

To Reproduce

Have this test class.

import SwiftUI
import SnapshotTesting
import XCTest

final class SettingsViewTests: XCTestCase {  
  func test_simple_view() {
    let sut = Text("Hello settings")
      .frame(width: 100, height: 100)
    SnapshotTesting.assertSnapshot(matching: sut, as: .image)
  }
}

When it is run without a snapshot being present, it quickly and correctly records the snapshot and reports a failure.

Test Suite 'Selected tests' started at 2023-07-30 14:35:52.852
Test Suite 'SettingsTests.xctest' started at 2023-07-30 14:35:52.853
Test Suite 'SettingsViewTests' started at 2023-07-30 14:35:52.853
Test Case '-[SettingsTests.SettingsViewTests test_simple_view]' started.
/Users/jaanus/Developer/Tact/Tact/Library/Targets/Settings/Tests/SettingsViewTests.swift:30: error: -[SettingsTests.SettingsViewTests test_simple_view] : failed - No reference was found on disk. Automatically recorded snapshot: …

open "/Users/jaanus/Developer/Tact/Tact/Library/Targets/Settings/Tests/__Snapshots__/SettingsViewTests/test_simple_view.1.png"

Re-run "test_simple_view" to test against the newly-recorded snapshot.
Test Case '-[SettingsTests.SettingsViewTests test_simple_view]' failed (0.069 seconds).
Test Suite 'SettingsViewTests' failed at 2023-07-30 14:35:52.922.
	 Executed 1 test, with 1 failure (0 unexpected) in 0.069 (0.069) seconds
Test Suite 'SettingsTests.xctest' failed at 2023-07-30 14:35:52.922.
	 Executed 1 test, with 1 failure (0 unexpected) in 0.069 (0.070) seconds
Test Suite 'Selected tests' failed at 2023-07-30 14:35:52.923.
	 Executed 1 test, with 1 failure (0 unexpected) in 0.069 (0.071) seconds
Program ended with exit code: 1

When the snapshot is present, the test works correctly (passes or fails as expected). However, the process has several seconds of delay in the end.

Test Suite 'Selected tests' started at 2023-07-30 14:36:29.432
Test Suite 'SettingsTests.xctest' started at 2023-07-30 14:36:29.432
Test Suite 'SettingsViewTests' started at 2023-07-30 14:36:29.432
Test Case '-[SettingsTests.SettingsViewTests test_simple_view]' started.
Test Case '-[SettingsTests.SettingsViewTests test_simple_view]' passed (0.071 seconds).
Test Suite 'SettingsViewTests' passed at 2023-07-30 14:36:29.503.
	 Executed 1 test, with 0 failures (0 unexpected) in 0.071 (0.071) seconds
Test Suite 'SettingsTests.xctest' passed at 2023-07-30 14:36:29.504.
	 Executed 1 test, with 0 failures (0 unexpected) in 0.071 (0.072) seconds
Test Suite 'Selected tests' passed at 2023-07-30 14:36:29.504.
	 Executed 1 test, with 0 failures (0 unexpected) in 0.071 (0.072) seconds
2023-07-30 14:36:32.011572+0300 xctest[18827:731647] [client] Timed out waiting for the exit barrier block. activeSendTransactions=0
Program ended with exit code: 0

Expected behavior

When snapshots are present, the test should complete without any delay.

Environment

  • swift-snapshot-testing version 1.11.1
  • Xcode Version 14.3.1 (14E300c)
  • Swift 5.8.1
  • OS: macOS Ventura 13.5 (22G74)
  • iOS Simulator: iPhone 14 Pro, iOS 16.4

I just created a new project without this library as a dependency and experienced the same issue. So this would indicate that it is not an issue of swift-snapshot-testing and could therefore be an Apple issue. Please test a project without swift-snapshot-testing and report back whether you experience the same thing. Thank you.