Skip to content

Fix hanging and failing tests in SwiftBarTests#490

Open
melonamin wants to merge 1 commit into
mainfrom
fix/test-suite-hangs
Open

Fix hanging and failing tests in SwiftBarTests#490
melonamin wants to merge 1 commit into
mainfrom
fix/test-suite-hangs

Conversation

@melonamin
Copy link
Copy Markdown
Member

Summary

The SwiftBarTests scheme hosts SwiftBarTests.xctest inside SwiftBar.app, so AppDelegate.applicationDidFinishLaunching runs in the test process. Three things kept it running long after the last @Test completed and prevented the host from terminating, which made xcodebuild test hang indefinitely after every test actually finished in milliseconds:

  • Sparkle's SPUUpdater registers persistent runloop sources for update checks.
  • The missing-plugin-folder branch shows a modal NSAlert that the test runner cannot dismiss.
  • PluginManager.loadPlugins() spawns plugin processes, file-system observers, and timers.

Detect the XCTest environment via XCTestConfigurationFilePath and skip the heavy setup, keeping only the lightweight pluginManager assignment that one integration test references via delegate.pluginManager.

Also fix testSyncFilePlugins_keepsSymlinkedPackagedPluginMatchedByBundlePath, a pre-existing failure: FileManager.contentsOfDirectory(at:) does not follow a directory-typed URL when the URL itself is a symlink (returns ENOTDIR). Resolve the symlink inside PackagedPlugin.findMainExecutable before enumerating, while keeping the .swiftbar extension check on the unresolved URL. In packagedPluginFileState pass the unresolved packageURL to findMainExecutable for the same reason.

Before/after

  • Before: xcodebuild test runs the test cases in <1s but the test process stays alive indefinitely (observed >30 min) until killed.
  • After: full suite runs in ~4s, 164/164 passing.

Test plan

  • xcodebuild test completes cleanly with ** TEST SUCCEEDED **
  • Previously-failing testSyncFilePlugins_keepsSymlinkedPackagedPluginMatchedByBundlePath now passes
  • Production launch path unaffected (the test-mode guard returns early only when XCTestConfigurationFilePath is set)

The test scheme hosts SwiftBarTests.xctest inside SwiftBar.app, so
AppDelegate.applicationDidFinishLaunching runs in the test process.
Three things kept it running long after the last @test completed and
prevented the host from terminating:

- Sparkle's SPUUpdater registers persistent runloop sources for update
  checks.
- The missing-plugin-folder branch shows a modal NSAlert that the test
  runner cannot dismiss.
- PluginManager.loadPlugins() spawns plugin processes, file-system
  observers, and timers.

Detect the XCTest environment via XCTestConfigurationFilePath and skip
the heavy setup, keeping only the lightweight pluginManager assignment
that one integration test still references via delegate.pluginManager.
Test runtime drops from "indefinite hang" to ~4 seconds.

Also fix testSyncFilePlugins_keepsSymlinkedPackagedPluginMatchedByBundlePath
which was a pre-existing failure: contentsOfDirectory(at:) does not
follow a directory-typed URL when the URL is itself a symlink (returns
ENOTDIR). Resolve the symlink inside PackagedPlugin.findMainExecutable
before enumerating, while keeping the `.swiftbar` extension check on
the unresolved URL. In packagedPluginFileState pass the unresolved
packageURL to findMainExecutable for the same reason.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant