Skip to content
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

[SR-5954] Assertion failure in void _XCTFailureHandler when running unit tests on Swift 4 #368

Closed
swift-ci opened this issue Sep 21, 2017 · 2 comments

Comments

@swift-ci
Copy link

Previous ID SR-5954
Radar None
Original Reporter ylin (JIRA User)
Type Bug
Environment

Xcode 9 from App Store, Swift 4.0

Additional Detail from JIRA
Votes 0
Component/s XCTest
Labels Bug
Assignee None
Priority Medium

md5: 3490a89fea916f1631607373b1b22a51

Issue Description:

I have Xcode 9 downloaded from the App Store. Here is how to reproduce the error:

1. Clone https://github.com/IBM-Swift/Configuration
2. Run unit tests using a Swift 4 toolchain (change `.swift-version` if you are using `swiftenv`): `swift test`
3. Get assertion failures in the logs, like this:

Test Suite 'All tests' started at 2017-09-21 10:53:21.238
Test Suite 'ConfigurationPackageTests.xctest' started at 2017-09-21 10:53:21.238
Test Suite 'ConfigurationManagerTest' started at 2017-09-21 10:53:21.238
2017-09-21 10:53:21.266 xctest[7061:67158] *** Assertion failure in void _XCTFailureHandler(XCTestCase * _Nonnull, BOOL, const char * _Nonnull, NSUInteger, NSString * _Nonnull, NSString * _Nullable, ...)(), /Library/Caches/com.apple.xbs/Sources/XCTest/XCTest-13201/Sources/XCTestFramework/Core/XCTestAssertionsImpl.m:41
<unknown>:0: error: ConfigurationManagerTest : Parameter "test" must not be nil.
(
    0   CoreFoundation                      0x00007fff84fdc57b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x00007fff9a23d1da objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff84fe1132 +[NSException raise:format:arguments:] + 98
    3   Foundation                          0x00007fff86ab0da6 -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 166
    4   XCTest                              0x000000010d9ce687 _XCTFailureHandler + 583
    5   XCTest                              0x000000010d9ce923 _XCTPreformattedFailureHandler + 81
    6   libswiftXCTest.dylib                0x00000001115bf019 _T06XCTest7XCTFailySS_s12StaticStringV4fileSu4linetFTf4gXxn_n + 473
    7   libswiftXCTest.dylib                0x00000001115b9b66 _T06XCTest7XCTFailySS_s12StaticStringV4fileSu4linetF + 22
    8   ConfigurationPackageTests           0x000000010e16e504 _T018ConfigurationTests0A11ManagerTestC5setUpyyFZ + 1396
    9   ConfigurationPackageTests           0x000000010e16e568 _T018ConfigurationTests0A11ManagerTestC5setUpyyFZTo + 24
    10  XCTest                              0x000000010d9c1376 __27-[XCTestSuite performTest:]_block_invoke + 58
    11  XCTest                              0x000000010d9c0e0e -[XCTestSuite _performProtectedSectionForTest:testSection:] + 26
    12  XCTest                              0x000000010d9c100b -[XCTestSuite performTest:] + 239
    13  XCTest                              0x000000010d9c14a7 __27-[XCTestSuite performTest:]_block_invoke + 363
    14  XCTest                              0x000000010d9c0e0e -[XCTestSuite _performProtectedSectionForTest:testSection:] + 26
    15  XCTest                              0x000000010d9c100b -[XCTestSuite performTest:] + 239
    16  XCTest                              0x000000010d9c14a7 __27-[XCTestSuite performTest:]_block_invoke + 363
    17  XCTest                              0x000000010d9c0e0e -[XCTestSuite _performProtectedSectionForTest:testSection:] + 26
    18  XCTest                              0x000000010d9c100b -[XCTestSuite performTest:] + 239
    19  XCTest                              0x000000010da1fb9d __44-[XCTTestRunSession runTestsAndReturnError:]_block_invoke + 40
    20  XCTest                              0x000000010d9dc2e2 -[XCTestObservationCenter _observeTestExecutionForBlock:] + 477
    21  XCTest                              0x000000010da1fa3b -[XCTTestRunSession runTestsAndReturnError:] + 281
    22  XCTest                              0x000000010d9b10b5 -[XCTestDriver runTestsAndReturnError:] + 314
    23  XCTest                              0x000000010da10250 _XCTestMain + 833
    24  xctest                              0x000000010d94e3d2 xctest + 9170
    25  libdyld.dylib                       0x00007fff9ab1e235 start + 1
)
2017-09-21 10:53:21.275 xctest[7061:67158] *** Assertion failure in void _XCTFailureHandler(XCTestCase * _Nonnull, BOOL, const char * _Nonnull, NSUInteger, NSString * _Nonnull, NSString * _Nullable, ...)(), /Library/Caches/com.apple.xbs/Sources/XCTest/XCTest-13201/Sources/XCTestFramework/Core/XCTestAssertionsImpl.m:41
<unknown>:0: error: ConfigurationManagerTest : Parameter "test" must not be nil.
(
    0   CoreFoundation                      0x00007fff84fdc57b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x00007fff9a23d1da objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff84fe1132 +[NSException raise:format:arguments:] + 98
    3   Foundation                          0x00007fff86ab0da6 -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 166
    4   XCTest                              0x000000010d9ce687 _XCTFailureHandler + 583
    5   XCTest                              0x000000010d9ce923 _XCTPreformattedFailureHandler + 81
    6   libswiftXCTest.dylib                0x00000001115bf019 _T06XCTest7XCTFailySS_s12StaticStringV4fileSu4linetFTf4gXxn_n + 473
    7   libswiftXCTest.dylib                0x00000001115b9b66 _T06XCTest7XCTFailySS_s12StaticStringV4fileSu4linetF + 22
    8   ConfigurationPackageTests           0x000000010e16ea44 _T018ConfigurationTests0A11ManagerTestC8tearDownyyFZ + 1236
    9   ConfigurationPackageTests           0x000000010e16eaa8 _T018ConfigurationTests0A11ManagerTestC8tearDownyyFZTo + 24
    10  XCTest                              0x000000010d9c0e0e -[XCTestSuite _performProtectedSectionForTest:testSection:] + 26
    11  XCTest                              0x000000010d9c1050 -[XCTestSuite performTest:] + 308
    12  XCTest                              0x000000010d9c14a7 __27-[XCTestSuite performTest:]_block_invoke + 363
    13  XCTest                              0x000000010d9c0e0e -[XCTestSuite _performProtectedSectionForTest:testSection:] + 26
    14  XCTest                              0x000000010d9c100b -[XCTestSuite performTest:] + 239
    15  XCTest                              0x000000010d9c14a7 __27-[XCTestSuite performTest:]_block_invoke + 363
    16  XCTest                              0x000000010d9c0e0e -[XCTestSuite _performProtectedSectionForTest:testSection:] + 26
    17  XCTest                              0x000000010d9c100b -[XCTestSuite performTest:] + 239
    18  XCTest                              0x000000010da1fb9d __44-[XCTTestRunSession runTestsAndReturnError:]_block_invoke + 40
    19  XCTest                              0x000000010d9dc2e2 -[XCTestObservationCenter _observeTestExecutionForBlock:] + 477
    20  XCTest                              0x000000010da1fa3b -[XCTTestRunSession runTestsAndReturnError:] + 281
    21  XCTest                              0x000000010d9b10b5 -[XCTestDriver runTestsAndReturnError:] + 314
    22  XCTest                              0x000000010da10250 _XCTestMain + 833
    23  xctest                              0x000000010d94e3d2 xctest + 9170
    24  libdyld.dylib                       0x00007fff9ab1e235 start + 1
)
Test Suite 'ConfigurationManagerTest' failed at 2017-09-21 10:53:21.276.
     Executed 0 tests, with 2 failures (2 unexpected) in 0.000 (0.038) seconds
Test Suite 'ConfigurationNodeTest' started at 2017-09-21 10:53:21.276
Test Case '-[ConfigurationTests.ConfigurationNodeTest testMergeOverwrite]' started.
Test Case '-[ConfigurationTests.ConfigurationNodeTest testMergeOverwrite]' passed (0.198 seconds).
Test Case '-[ConfigurationTests.ConfigurationNodeTest testRawValue]' started.
Test Case '-[ConfigurationTests.ConfigurationNodeTest testRawValue]' passed (0.001 seconds).
Test Case '-[ConfigurationTests.ConfigurationNodeTest testSplitKeys]' started.
Test Case '-[ConfigurationTests.ConfigurationNodeTest testSplitKeys]' passed (0.000 seconds).
Test Case '-[ConfigurationTests.ConfigurationNodeTest testSubscript]' started.
Test Case '-[ConfigurationTests.ConfigurationNodeTest testSubscript]' passed (0.001 seconds).
Test Suite 'ConfigurationNodeTest' passed at 2017-09-21 10:53:21.476.
     Executed 4 tests, with 0 failures (0 unexpected) in 0.200 (0.200) seconds
Test Suite 'ConfigurationPackageTests.xctest' failed at 2017-09-21 10:53:21.476.
     Executed 4 tests, with 2 failures (2 unexpected) in 0.200 (0.238) seconds
Test Suite 'All tests' failed at 2017-09-21 10:53:21.476.
     Executed 4 tests, with 2 failures (2 unexpected) in 0.200 (0.239) seconds

The tests will complete without this runtime failure if I comment out `setup` and `teardown` functions in `ConfigurationManagerTest.swift`. Those functions deal with creating and deleting symlinks inside `/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Xcode/Agents/`, so it's entirely possibly that I'm running into a permissions issue. However, that is not at all clear from the assertion failure printed.

@swift-ci
Copy link
Author

Comment by Youming Lin (JIRA)

@briancroom has informed me that this is likely due to my test code calling `XCTFail` inside class level `setup` and `teardown` functions. It would be nice if the error message points this out as it is hard to figure out exactly what is wrong with my code with the current error message.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 9, 2022
@grynspan
Copy link
Contributor

Looks like this issue was reported against the version of XCTest that ships within Xcode for macOS/iOS/etc. If you are still seeing an unexpected issue here, please let Apple know by filing feedback at https://feedback.apple.com

@grynspan grynspan closed this as not planned Won't fix, can't repro, duplicate, stale Jan 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants