Fix hanging and failing tests in SwiftBarTests#490
Open
melonamin wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The SwiftBarTests scheme hosts
SwiftBarTests.xctestinsideSwiftBar.app, soAppDelegate.applicationDidFinishLaunchingruns in the test process. Three things kept it running long after the last@Testcompleted and prevented the host from terminating, which madexcodebuild testhang indefinitely after every test actually finished in milliseconds:SPUUpdaterregisters persistent runloop sources for update checks.NSAlertthat the test runner cannot dismiss.PluginManager.loadPlugins()spawns plugin processes, file-system observers, and timers.Detect the XCTest environment via
XCTestConfigurationFilePathand skip the heavy setup, keeping only the lightweightpluginManagerassignment that one integration test references viadelegate.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 (returnsENOTDIR). Resolve the symlink insidePackagedPlugin.findMainExecutablebefore enumerating, while keeping the.swiftbarextension check on the unresolved URL. InpackagedPluginFileStatepass the unresolvedpackageURLtofindMainExecutablefor the same reason.Before/after
xcodebuild testruns the test cases in <1s but the test process stays alive indefinitely (observed >30 min) until killed.Test plan
xcodebuild testcompletes cleanly with** TEST SUCCEEDED **testSyncFilePlugins_keepsSymlinkedPackagedPluginMatchedByBundlePathnow passesXCTestConfigurationFilePathis set)