From 8a60fab6e05f373a8b068bd3993eb08c83c813fc Mon Sep 17 00:00:00 2001 From: Rachel Brindle Date: Tue, 19 Dec 2023 11:34:08 -0800 Subject: [PATCH 1/6] CwlCatchException and CwlPreconditionTesting dropped carthage support Stop embedding them, and pull them in through SPM or Cocoapods transitively. --- .../Checkouts/CwlCatchException/LICENSE.txt | 15 - .../Checkouts/CwlCatchException/Package.swift | 14 - .../Checkouts/CwlCatchException/README.md | 18 - .../CwlCatchException/CwlCatchException.swift | 35 -- .../CwlCatchException.m | 34 -- .../include/CwlCatchException.h | 23 - .../CwlPreconditionTesting/LICENSE.txt | 15 - .../CwlPreconditionTesting/Package.swift | 27 - .../CwlPreconditionTesting/README.md | 59 -- .../CwlMachBadInstructionHandler.m | 56 -- .../include/CwlMachBadInstructionHandler.h | 80 --- .../mach_excServer.c | 536 ------------------ .../mach_excServer.h | 329 ----------- .../CwlCatchBadInstructionPosix.swift | 119 ---- .../CwlBadInstructionException.swift | 92 --- .../CwlCatchBadInstruction.swift | 209 ------- .../CwlDarwinDefinitions.swift | 64 --- Nimble.podspec | 31 +- Nimble.xcodeproj/project.pbxproj | 175 ++---- .../contents.xcworkspacedata | 2 +- .../xcshareddata/swiftpm/Package.resolved | 23 + Sources/Nimble/Nimble.h | 4 +- 22 files changed, 85 insertions(+), 1875 deletions(-) delete mode 100644 Carthage/Checkouts/CwlCatchException/LICENSE.txt delete mode 100644 Carthage/Checkouts/CwlCatchException/Package.swift delete mode 100644 Carthage/Checkouts/CwlCatchException/README.md delete mode 100644 Carthage/Checkouts/CwlCatchException/Sources/CwlCatchException/CwlCatchException.swift delete mode 100644 Carthage/Checkouts/CwlCatchException/Sources/CwlCatchExceptionSupport/CwlCatchException.m delete mode 100644 Carthage/Checkouts/CwlCatchException/Sources/CwlCatchExceptionSupport/include/CwlCatchException.h delete mode 100644 Carthage/Checkouts/CwlPreconditionTesting/LICENSE.txt delete mode 100644 Carthage/Checkouts/CwlPreconditionTesting/Package.swift delete mode 100644 Carthage/Checkouts/CwlPreconditionTesting/README.md delete mode 100644 Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/CwlMachBadInstructionHandler.m delete mode 100644 Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/include/CwlMachBadInstructionHandler.h delete mode 100644 Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/mach_excServer.c delete mode 100644 Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/mach_excServer.h delete mode 100644 Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPosixPreconditionTesting/CwlCatchBadInstructionPosix.swift delete mode 100644 Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlBadInstructionException.swift delete mode 100644 Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlCatchBadInstruction.swift delete mode 100644 Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlDarwinDefinitions.swift create mode 100644 Nimble.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved diff --git a/Carthage/Checkouts/CwlCatchException/LICENSE.txt b/Carthage/Checkouts/CwlCatchException/LICENSE.txt deleted file mode 100644 index 693a2fe7d..000000000 --- a/Carthage/Checkouts/CwlCatchException/LICENSE.txt +++ /dev/null @@ -1,15 +0,0 @@ -ISC License - -Copyright © 2017 Matt Gallagher ( http://cocoawithlove.com ). All rights reserved. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY -SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR -IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/Carthage/Checkouts/CwlCatchException/Package.swift b/Carthage/Checkouts/CwlCatchException/Package.swift deleted file mode 100644 index acee3952a..000000000 --- a/Carthage/Checkouts/CwlCatchException/Package.swift +++ /dev/null @@ -1,14 +0,0 @@ -// swift-tools-version:5.0 -import PackageDescription - -let package = Package( - name: "CwlCatchException", - products: [ - .library(name: "CwlCatchException", targets: ["CwlCatchException"]), - ], - targets: [ - .target(name: "CwlCatchException", dependencies: [.target(name: "CwlCatchExceptionSupport")]), - .target(name: "CwlCatchExceptionSupport"), - .testTarget(name: "CwlCatchExceptionTests", dependencies: [.target(name: "CwlCatchException")]) - ] -) diff --git a/Carthage/Checkouts/CwlCatchException/README.md b/Carthage/Checkouts/CwlCatchException/README.md deleted file mode 100644 index 1e8a6ec56..000000000 --- a/Carthage/Checkouts/CwlCatchException/README.md +++ /dev/null @@ -1,18 +0,0 @@ -# CwlCatchException -A simple Swift wrapper around an Objective-C `@try`/`@catch` statement that selectively catches Objective-C exceptions by `NSException` subtype, rethrowing if any caught exception is not the expected subtype. - -Look at [CwlCatchExceptionTests.swift](https://github.com/mattgallagher/CwlCatchException/blob/master/Tests/CwlCatchExceptionTests/CwlCatchExceptionTests.swift) for syntax. - -## Requirements - -From version 2.0.0-beta.1, building CwlCatchException requires Swift 5 or newer and the Swift Package Manager. - -For use with older versions of Swift or other package managers, [use version 1.2.0 or older](https://github.com/mattgallagher/CwlCatchException/tree/1.2.0). - -## Adding to your project - -Add the following to the `dependencies` array in your "Package.swift" file: - - .package(url: "https://github.com/mattgallagher/CwlCatchException.git", from: Version("2.0.0-beta.1")) - -Or by adding `https://github.com/mattgallagher/CwlCatchException.git`, version 2.0.0-beta.1 or later, to the list of Swift packages for any project in Xcode. diff --git a/Carthage/Checkouts/CwlCatchException/Sources/CwlCatchException/CwlCatchException.swift b/Carthage/Checkouts/CwlCatchException/Sources/CwlCatchException/CwlCatchException.swift deleted file mode 100644 index 2cb9b2918..000000000 --- a/Carthage/Checkouts/CwlCatchException/Sources/CwlCatchException/CwlCatchException.swift +++ /dev/null @@ -1,35 +0,0 @@ -// -// CwlCatchException.swift -// CwlAssertionTesting -// -// Created by Matt Gallagher on 2016/01/10. -// Copyright © 2016 Matt Gallagher ( https://www.cocoawithlove.com ). All rights reserved. -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY -// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR -// IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// - -import Foundation - -#if SWIFT_PACKAGE -import CwlCatchExceptionSupport -#endif - -private func catchReturnTypeConverter(_ type: T.Type, block: @escaping () -> Void) -> T? { - return catchExceptionOfKind(type, block) as? T -} - -extension NSException { - public static func catchException(in block: @escaping () -> Void) -> Self? { - return catchReturnTypeConverter(self, block: block) - } -} diff --git a/Carthage/Checkouts/CwlCatchException/Sources/CwlCatchExceptionSupport/CwlCatchException.m b/Carthage/Checkouts/CwlCatchException/Sources/CwlCatchExceptionSupport/CwlCatchException.m deleted file mode 100644 index ff35465d8..000000000 --- a/Carthage/Checkouts/CwlCatchException/Sources/CwlCatchExceptionSupport/CwlCatchException.m +++ /dev/null @@ -1,34 +0,0 @@ -// -// CwlCatchException.m -// CwlAssertionTesting -// -// Created by Matt Gallagher on 2016/01/10. -// Copyright © 2016 Matt Gallagher ( https://www.cocoawithlove.com ). All rights reserved. -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY -// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR -// IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// - -#import "CwlCatchException.h" - -NSException* __nullable catchExceptionOfKind(Class __nonnull type, void (^ __nonnull inBlock)(void)) { - @try { - inBlock(); - } @catch (NSException *exception) { - if ([exception isKindOfClass:type]) { - return exception; - } else { - @throw; - } - } - return nil; -} diff --git a/Carthage/Checkouts/CwlCatchException/Sources/CwlCatchExceptionSupport/include/CwlCatchException.h b/Carthage/Checkouts/CwlCatchException/Sources/CwlCatchExceptionSupport/include/CwlCatchException.h deleted file mode 100644 index eb42378f5..000000000 --- a/Carthage/Checkouts/CwlCatchException/Sources/CwlCatchExceptionSupport/include/CwlCatchException.h +++ /dev/null @@ -1,23 +0,0 @@ -// -// CwlCatchException.h -// CwlCatchException -// -// Created by Matt Gallagher on 2016/01/10. -// Copyright © 2016 Matt Gallagher ( https://www.cocoawithlove.com ). All rights reserved. -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY -// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR -// IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// - -#import - -NSException* __nullable catchExceptionOfKind(Class __nonnull type, void (^ __nonnull inBlock)(void)); diff --git a/Carthage/Checkouts/CwlPreconditionTesting/LICENSE.txt b/Carthage/Checkouts/CwlPreconditionTesting/LICENSE.txt deleted file mode 100644 index 693a2fe7d..000000000 --- a/Carthage/Checkouts/CwlPreconditionTesting/LICENSE.txt +++ /dev/null @@ -1,15 +0,0 @@ -ISC License - -Copyright © 2017 Matt Gallagher ( http://cocoawithlove.com ). All rights reserved. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY -SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR -IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/Carthage/Checkouts/CwlPreconditionTesting/Package.swift b/Carthage/Checkouts/CwlPreconditionTesting/Package.swift deleted file mode 100644 index d6d183dbf..000000000 --- a/Carthage/Checkouts/CwlPreconditionTesting/Package.swift +++ /dev/null @@ -1,27 +0,0 @@ -// swift-tools-version:5.0 -import PackageDescription - -let package = Package( - name: "CwlPreconditionTesting", - products: [ - .library(name: "CwlPreconditionTesting", targets: ["CwlPreconditionTesting", "CwlMachBadInstructionHandler"]), - .library(name: "CwlPosixPreconditionTesting", targets: ["CwlPosixPreconditionTesting"]) - ], - dependencies: [ - .package(url: "https://github.com/mattgallagher/CwlCatchException.git", from: "2.0.0") - ], - targets: [ - .target( - name: "CwlPreconditionTesting", - dependencies: [ - .target(name: "CwlMachBadInstructionHandler"), - .product(name: "CwlCatchException") - ] - ), - .target( - name: "CwlPosixPreconditionTesting" - ), - .target(name: "CwlMachBadInstructionHandler"), - .testTarget(name: "CwlPreconditionTestingTests", dependencies: ["CwlPreconditionTesting", "CwlPosixPreconditionTesting"]) - ] -) diff --git a/Carthage/Checkouts/CwlPreconditionTesting/README.md b/Carthage/Checkouts/CwlPreconditionTesting/README.md deleted file mode 100644 index dd3fef111..000000000 --- a/Carthage/Checkouts/CwlPreconditionTesting/README.md +++ /dev/null @@ -1,59 +0,0 @@ -# CwlPreconditionTesting - -A Mach exception handler, written in Swift and Objective-C, that allows `EXC_BAD_INSTRUCTION` (as raised by Swift's `assertionFailure`/`preconditionFailure`/`fatalError`) to be caught and tested. - -NOTE: the iOS code runs in the simulator *only*. It is for logic testing and cannot be deployed to the device due to the Mach exception API being private on iOS. - -For an extended discussion of this code, please see the Cocoa with Love article: - -[Partial functions in Swift, Part 2: Catching precondition failures](http://cocoawithlove.com/blog/2016/02/02/partial-functions-part-two-catching-precondition-failures.html) - -## Requirements - -From version 2.0.0-beta.1, building CwlPreconditionTesting requires Swift 5 or newer and the Swift Package Manager, or CocoaPods. - -For use with older versions of Swift or other package managers, [use version 1.2.0 or older](https://github.com/mattgallagher/CwlPreconditionTesting/tree/1.2.0). - -## Adding to your project - -### Swift Package Manager - -Add the following to the `dependencies` array in your "Package.swift" file: - - .package(url: "https://github.com/mattgallagher/CwlPreconditionTesting.git", from: Version("2.0.0")) - -Or by adding `https://github.com/mattgallagher/CwlPreconditionTesting.git`, version 2.0.0 or later, to the list of Swift packages for any project in Xcode. - -### CocoaPods - -CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate CwlPreconditionTesting into your Xcode project using CocoaPods, specify it in your Podfile: - -pod 'CwlPreconditionTesting', '~> 2.0' - -## Usage - -On macOS and iOS you can use the regular version: - -```swift -import CwlPreconditionTesting - -let e = catchBadInstruction { - precondition(false, "THIS PRECONDITION FAILURE IS EXPECTED") -} -``` - -on tvOS, Linux and other platforms, you can use the POSIX version: - -```swift -import CwlPosixPreconditionTesting - -let e = catchBadInstruction { - precondition(false, "THIS PRECONDITION FAILURE IS EXPECTED") -} -``` - -**Warning**: this POSIX version can't be used when lldb is attached since lldb's Mach exception handler blocks the SIGILL from ever occurring. You should disable the "Debug Executable" setting for the tests in Xcode. The POSIX version of the signal handler is also whole process (rather than correctly scoped to the thread where the "catch" occurs). - -## Thanks - -Includes contributions from @abbeycode, @dnkoutso, @jeffh and @ikesyo. Extra thanks to @saagarjha for help with the ARM64 additions. \ No newline at end of file diff --git a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/CwlMachBadInstructionHandler.m b/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/CwlMachBadInstructionHandler.m deleted file mode 100644 index 168fa5b70..000000000 --- a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/CwlMachBadInstructionHandler.m +++ /dev/null @@ -1,56 +0,0 @@ -// -// CwlMachBadExceptionHandler.m -// CwlPreconditionTesting -// -// Created by Matt Gallagher on 2016/01/10. -// Copyright © 2016 Matt Gallagher ( https://www.cocoawithlove.com ). All rights reserved. -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY -// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR -// IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// - -#ifdef __APPLE__ -#import "TargetConditionals.h" -#if TARGET_OS_OSX || TARGET_OS_IOS - -#import "mach_excServer.h" -#import "CwlMachBadInstructionHandler.h" - -@protocol BadInstructionReply -+(int)receiveReply:(bad_instruction_exception_reply_t)reply; -@end - -/// A basic function that receives callbacks from mach_exc_server and relays them to the Swift implemented BadInstructionException.catch_mach_exception_raise_state. -kern_return_t catch_mach_exception_raise_state(mach_port_t exception_port, exception_type_t exception, const mach_exception_data_t code, mach_msg_type_number_t codeCnt, int *flavor, const thread_state_t old_state, mach_msg_type_number_t old_stateCnt, thread_state_t new_state, mach_msg_type_number_t *new_stateCnt) { - bad_instruction_exception_reply_t reply = { exception_port, exception, code, codeCnt, flavor, old_state, old_stateCnt, new_state, new_stateCnt }; - Class badInstructionClass = NSClassFromString(@"BadInstructionException"); - return [badInstructionClass receiveReply:reply]; -} - -// The mach port should be configured so that this function is never used. -kern_return_t catch_mach_exception_raise(mach_port_t exception_port, mach_port_t thread, mach_port_t task, exception_type_t exception, mach_exception_data_t code, mach_msg_type_number_t codeCnt) { - assert(false); - return KERN_FAILURE; -} - -// The mach port should be configured so that this function is never used. -kern_return_t catch_mach_exception_raise_state_identity(mach_port_t exception_port, mach_port_t thread, mach_port_t task, exception_type_t exception, mach_exception_data_t code, mach_msg_type_number_t codeCnt, int *flavor, thread_state_t old_state, mach_msg_type_number_t old_stateCnt, thread_state_t new_state, mach_msg_type_number_t *new_stateCnt) { - assert(false); - return KERN_FAILURE; -} - -NDR_record_t mach_ndr_record(void) { - return NDR_record; -} - -#endif /* TARGET_OS_OSX || TARGET_OS_IOS */ -#endif /* __APPLE__ */ diff --git a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/include/CwlMachBadInstructionHandler.h b/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/include/CwlMachBadInstructionHandler.h deleted file mode 100644 index 6feabe5ad..000000000 --- a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/include/CwlMachBadInstructionHandler.h +++ /dev/null @@ -1,80 +0,0 @@ -// -// CwlMachBadInstructionHandler.h -// CwlPreconditionTesting -// -// Created by Matt Gallagher on 2016/01/10. -// Copyright © 2016 Matt Gallagher ( https://www.cocoawithlove.com ). All rights reserved. -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY -// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR -// IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// - -#import - -#if TARGET_OS_OSX || TARGET_OS_IOS - -#import - -extern bool _swift_disableExclusivityChecking; -extern bool _swift_reportFatalErrorsToDebugger; - -NS_ASSUME_NONNULL_BEGIN - -extern boolean_t mach_exc_server(mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP); - -// The request_mach_exception_raise_t struct is passed to mach_msg which assumes its exact layout. To avoid problems with different layouts, we keep the definition in C rather than Swift. -typedef struct -{ - mach_msg_header_t Head; - /* start of the kernel processed data */ - mach_msg_body_t msgh_body; - mach_msg_port_descriptor_t thread; - mach_msg_port_descriptor_t task; - /* end of the kernel processed data */ - NDR_record_t NDR; - exception_type_t exception; - mach_msg_type_number_t codeCnt; - int64_t code[2]; - int flavor; - mach_msg_type_number_t old_stateCnt; - natural_t old_state[224]; -} request_mach_exception_raise_t; - -// The reply_mach_exception_raise_state_t struct is passed to mach_msg which assumes its exact layout. To avoid problems with different layouts, we keep the definition in C rather than Swift. -typedef struct -{ - mach_msg_header_t Head; - NDR_record_t NDR; - kern_return_t RetCode; - int flavor; - mach_msg_type_number_t new_stateCnt; - natural_t new_state[224]; -} reply_mach_exception_raise_state_t; - -typedef struct -{ - mach_port_t exception_port; - exception_type_t exception; - mach_exception_data_type_t const * _Nullable code; - mach_msg_type_number_t codeCnt; - int32_t * _Nullable flavor; - natural_t const * _Nullable old_state; - mach_msg_type_number_t old_stateCnt; - thread_state_t _Nullable new_state; - mach_msg_type_number_t * _Nullable new_stateCnt; -} bad_instruction_exception_reply_t; - -NDR_record_t mach_ndr_record(void); - -NS_ASSUME_NONNULL_END - -#endif diff --git a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/mach_excServer.c b/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/mach_excServer.c deleted file mode 100644 index ccd8f84b8..000000000 --- a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/mach_excServer.c +++ /dev/null @@ -1,536 +0,0 @@ -/* - * IDENTIFICATION: - * stub generated Sun Jan 29 19:05:29 2017 - * with a MiG generated by bootstrap_cmds-96.20.2 - * OPTIONS: - */ - -/* Module mach_exc */ - -#define __MIG_check__Request__mach_exc_subsystem__ 1 - -#import "mach_excServer.h" -#if TARGET_OS_OSX || TARGET_OS_IOS - -#ifndef mig_internal -#define mig_internal static __inline__ -#endif /* mig_internal */ - -#ifndef mig_external -#define mig_external -#endif /* mig_external */ - -#if !defined(__MigTypeCheck) && defined(TypeCheck) -#define __MigTypeCheck TypeCheck /* Legacy setting */ -#endif /* !defined(__MigTypeCheck) */ - -#if !defined(__MigKernelSpecificCode) && defined(_MIG_KERNEL_SPECIFIC_CODE_) -#define __MigKernelSpecificCode _MIG_KERNEL_SPECIFIC_CODE_ /* Legacy setting */ -#endif /* !defined(__MigKernelSpecificCode) */ - -#ifndef LimitCheck -#define LimitCheck 0 -#endif /* LimitCheck */ - -#ifndef min -#define min(a,b) ( ((a) < (b))? (a): (b) ) -#endif /* min */ - -#if !defined(_WALIGN_) -#define _WALIGN_(x) (((x) + 3) & ~3) -#endif /* !defined(_WALIGN_) */ - -#if !defined(_WALIGNSZ_) -#define _WALIGNSZ_(x) _WALIGN_(sizeof(x)) -#endif /* !defined(_WALIGNSZ_) */ - -#ifndef UseStaticTemplates -#define UseStaticTemplates 0 -#endif /* UseStaticTemplates */ - -#ifndef __DeclareRcvRpc -#define __DeclareRcvRpc(_NUM_, _NAME_) -#endif /* __DeclareRcvRpc */ - -#ifndef __BeforeRcvRpc -#define __BeforeRcvRpc(_NUM_, _NAME_) -#endif /* __BeforeRcvRpc */ - -#ifndef __AfterRcvRpc -#define __AfterRcvRpc(_NUM_, _NAME_) -#endif /* __AfterRcvRpc */ - -#ifndef __DeclareRcvSimple -#define __DeclareRcvSimple(_NUM_, _NAME_) -#endif /* __DeclareRcvSimple */ - -#ifndef __BeforeRcvSimple -#define __BeforeRcvSimple(_NUM_, _NAME_) -#endif /* __BeforeRcvSimple */ - -#ifndef __AfterRcvSimple -#define __AfterRcvSimple(_NUM_, _NAME_) -#endif /* __AfterRcvSimple */ - -#define novalue void - -#define msgh_request_port msgh_local_port -#define MACH_MSGH_BITS_REQUEST(bits) MACH_MSGH_BITS_LOCAL(bits) -#define msgh_reply_port msgh_remote_port -#define MACH_MSGH_BITS_REPLY(bits) MACH_MSGH_BITS_REMOTE(bits) - -#define MIG_RETURN_ERROR(X, code) {\ - ((mig_reply_error_t *)X)->RetCode = code;\ - ((mig_reply_error_t *)X)->NDR = NDR_record;\ - return;\ - } - -/* Forward Declarations */ - - -mig_internal novalue _Xmach_exception_raise - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP); - -mig_internal novalue _Xmach_exception_raise_state - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP); - -mig_internal novalue _Xmach_exception_raise_state_identity - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP); - - -#if ( __MigTypeCheck ) -#if __MIG_check__Request__mach_exc_subsystem__ -#if !defined(__MIG_check__Request__mach_exception_raise_t__defined) -#define __MIG_check__Request__mach_exception_raise_t__defined - -mig_internal kern_return_t __MIG_check__Request__mach_exception_raise_t(__attribute__((__unused__)) __Request__mach_exception_raise_t *In0P) -{ - - typedef __Request__mach_exception_raise_t __Request; -#if __MigTypeCheck - unsigned int msgh_size; -#endif /* __MigTypeCheck */ - -#if __MigTypeCheck - msgh_size = In0P->Head.msgh_size; - if (!(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || - (In0P->msgh_body.msgh_descriptor_count != 2) || - (msgh_size < (mach_msg_size_t)(sizeof(__Request) - 16)) || (msgh_size > (mach_msg_size_t)sizeof(__Request))) - return MIG_BAD_ARGUMENTS; -#endif /* __MigTypeCheck */ - -#if __MigTypeCheck - if (In0P->thread.type != MACH_MSG_PORT_DESCRIPTOR || - In0P->thread.disposition != 17) - return MIG_TYPE_ERROR; -#endif /* __MigTypeCheck */ - -#if __MigTypeCheck - if (In0P->task.type != MACH_MSG_PORT_DESCRIPTOR || - In0P->task.disposition != 17) - return MIG_TYPE_ERROR; -#endif /* __MigTypeCheck */ - -#if defined(__NDR_convert__int_rep__Request__mach_exception_raise_t__codeCnt__defined) - if (In0P->NDR.int_rep != NDR_record.int_rep) - __NDR_convert__int_rep__Request__mach_exception_raise_t__codeCnt(&In0P->codeCnt, In0P->NDR.int_rep); -#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_t__codeCnt__defined */ -#if __MigTypeCheck - if ( In0P->codeCnt > 2 ) - return MIG_BAD_ARGUMENTS; - if (((msgh_size - (mach_msg_size_t)(sizeof(__Request) - 16)) / 8 < In0P->codeCnt) || - (msgh_size != (mach_msg_size_t)(sizeof(__Request) - 16) + (8 * In0P->codeCnt))) - return MIG_BAD_ARGUMENTS; -#endif /* __MigTypeCheck */ - - return MACH_MSG_SUCCESS; -} -#endif /* !defined(__MIG_check__Request__mach_exception_raise_t__defined) */ -#endif /* __MIG_check__Request__mach_exc_subsystem__ */ -#endif /* ( __MigTypeCheck ) */ - - -/* Routine mach_exception_raise */ -mig_internal novalue _Xmach_exception_raise - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - -#ifdef __MigPackStructs -#pragma pack(4) -#endif - typedef struct { - mach_msg_header_t Head; - /* start of the kernel processed data */ - mach_msg_body_t msgh_body; - mach_msg_port_descriptor_t thread; - mach_msg_port_descriptor_t task; - /* end of the kernel processed data */ - NDR_record_t NDR; - exception_type_t exception; - mach_msg_type_number_t codeCnt; - int64_t code[2]; - mach_msg_trailer_t trailer; - } Request __attribute__((unused)); -#ifdef __MigPackStructs -#pragma pack() -#endif - typedef __Request__mach_exception_raise_t __Request; - typedef __Reply__mach_exception_raise_t Reply __attribute__((unused)); - - /* - * typedef struct { - * mach_msg_header_t Head; - * NDR_record_t NDR; - * kern_return_t RetCode; - * } mig_reply_error_t; - */ - - Request *In0P = (Request *) InHeadP; - Reply *OutP = (Reply *) OutHeadP; -#ifdef __MIG_check__Request__mach_exception_raise_t__defined - kern_return_t check_result; -#endif /* __MIG_check__Request__mach_exception_raise_t__defined */ - - __DeclareRcvRpc(2405, "mach_exception_raise") - __BeforeRcvRpc(2405, "mach_exception_raise") - -#if defined(__MIG_check__Request__mach_exception_raise_t__defined) - check_result = __MIG_check__Request__mach_exception_raise_t((__Request *)In0P); - if (check_result != MACH_MSG_SUCCESS) - { MIG_RETURN_ERROR(OutP, check_result); } -#endif /* defined(__MIG_check__Request__mach_exception_raise_t__defined) */ - - OutP->RetCode = catch_mach_exception_raise(In0P->Head.msgh_request_port, In0P->thread.name, In0P->task.name, In0P->exception, In0P->code, In0P->codeCnt); - - OutP->NDR = NDR_record; - - - __AfterRcvRpc(2405, "mach_exception_raise") -} - -#if ( __MigTypeCheck ) -#if __MIG_check__Request__mach_exc_subsystem__ -#if !defined(__MIG_check__Request__mach_exception_raise_state_t__defined) -#define __MIG_check__Request__mach_exception_raise_state_t__defined - -mig_internal kern_return_t __MIG_check__Request__mach_exception_raise_state_t(__attribute__((__unused__)) __Request__mach_exception_raise_state_t *In0P, __attribute__((__unused__)) __Request__mach_exception_raise_state_t **In1PP) -{ - - typedef __Request__mach_exception_raise_state_t __Request; - __Request *In1P; -#if __MigTypeCheck - unsigned int msgh_size; -#endif /* __MigTypeCheck */ - unsigned int msgh_size_delta; - -#if __MigTypeCheck - msgh_size = In0P->Head.msgh_size; - if ((In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || - (msgh_size < (mach_msg_size_t)(sizeof(__Request) - 912)) || (msgh_size > (mach_msg_size_t)sizeof(__Request))) - return MIG_BAD_ARGUMENTS; -#endif /* __MigTypeCheck */ - -#if defined(__NDR_convert__int_rep__Request__mach_exception_raise_state_t__codeCnt__defined) - if (In0P->NDR.int_rep != NDR_record.int_rep) - __NDR_convert__int_rep__Request__mach_exception_raise_state_t__codeCnt(&In0P->codeCnt, In0P->NDR.int_rep); -#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_state_t__codeCnt__defined */ - msgh_size_delta = (8 * In0P->codeCnt); -#if __MigTypeCheck - if ( In0P->codeCnt > 2 ) - return MIG_BAD_ARGUMENTS; - if (((msgh_size - (mach_msg_size_t)(sizeof(__Request) - 912)) / 8 < In0P->codeCnt) || - (msgh_size < (mach_msg_size_t)(sizeof(__Request) - 912) + (8 * In0P->codeCnt))) - return MIG_BAD_ARGUMENTS; - msgh_size -= msgh_size_delta; -#endif /* __MigTypeCheck */ - - *In1PP = In1P = (__Request *) ((pointer_t) In0P + msgh_size_delta - 16); - -#if defined(__NDR_convert__int_rep__Request__mach_exception_raise_state_t__old_stateCnt__defined) - if (In0P->NDR.int_rep != NDR_record.int_rep) - __NDR_convert__int_rep__Request__mach_exception_raise_state_t__old_stateCnt(&In1P->old_stateCnt, In1P->NDR.int_rep); -#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_state_t__old_stateCnt__defined */ -#if __MigTypeCheck - if ( In1P->old_stateCnt > 224 ) - return MIG_BAD_ARGUMENTS; - if (((msgh_size - (mach_msg_size_t)(sizeof(__Request) - 912)) / 4 < In1P->old_stateCnt) || - (msgh_size != (mach_msg_size_t)(sizeof(__Request) - 912) + (4 * In1P->old_stateCnt))) - return MIG_BAD_ARGUMENTS; -#endif /* __MigTypeCheck */ - - return MACH_MSG_SUCCESS; -} -#endif /* !defined(__MIG_check__Request__mach_exception_raise_state_t__defined) */ -#endif /* __MIG_check__Request__mach_exc_subsystem__ */ -#endif /* ( __MigTypeCheck ) */ - - -/* Routine mach_exception_raise_state */ -mig_internal novalue _Xmach_exception_raise_state - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - -#ifdef __MigPackStructs -#pragma pack(4) -#endif - typedef struct { - mach_msg_header_t Head; - NDR_record_t NDR; - exception_type_t exception; - mach_msg_type_number_t codeCnt; - int64_t code[2]; - int flavor; - mach_msg_type_number_t old_stateCnt; - natural_t old_state[224]; - mach_msg_trailer_t trailer; - } Request __attribute__((unused)); -#ifdef __MigPackStructs -#pragma pack() -#endif - typedef __Request__mach_exception_raise_state_t __Request; - typedef __Reply__mach_exception_raise_state_t Reply __attribute__((unused)); - - /* - * typedef struct { - * mach_msg_header_t Head; - * NDR_record_t NDR; - * kern_return_t RetCode; - * } mig_reply_error_t; - */ - - Request *In0P = (Request *) InHeadP; - Request *In1P; - Reply *OutP = (Reply *) OutHeadP; -#ifdef __MIG_check__Request__mach_exception_raise_state_t__defined - kern_return_t check_result; -#endif /* __MIG_check__Request__mach_exception_raise_state_t__defined */ - - __DeclareRcvRpc(2406, "mach_exception_raise_state") - __BeforeRcvRpc(2406, "mach_exception_raise_state") - -#if defined(__MIG_check__Request__mach_exception_raise_state_t__defined) - check_result = __MIG_check__Request__mach_exception_raise_state_t((__Request *)In0P, (__Request **)&In1P); - if (check_result != MACH_MSG_SUCCESS) - { MIG_RETURN_ERROR(OutP, check_result); } -#endif /* defined(__MIG_check__Request__mach_exception_raise_state_t__defined) */ - - OutP->new_stateCnt = 224; - - OutP->RetCode = catch_mach_exception_raise_state(In0P->Head.msgh_request_port, In0P->exception, In0P->code, In0P->codeCnt, &In1P->flavor, In1P->old_state, In1P->old_stateCnt, OutP->new_state, &OutP->new_stateCnt); - if (OutP->RetCode != KERN_SUCCESS) { - MIG_RETURN_ERROR(OutP, OutP->RetCode); - } - - OutP->NDR = NDR_record; - - - OutP->flavor = In1P->flavor; - OutP->Head.msgh_size = (mach_msg_size_t)(sizeof(Reply) - 896) + (((4 * OutP->new_stateCnt))); - - __AfterRcvRpc(2406, "mach_exception_raise_state") -} - -#if ( __MigTypeCheck ) -#if __MIG_check__Request__mach_exc_subsystem__ -#if !defined(__MIG_check__Request__mach_exception_raise_state_identity_t__defined) -#define __MIG_check__Request__mach_exception_raise_state_identity_t__defined - -mig_internal kern_return_t __MIG_check__Request__mach_exception_raise_state_identity_t(__attribute__((__unused__)) __Request__mach_exception_raise_state_identity_t *In0P, __attribute__((__unused__)) __Request__mach_exception_raise_state_identity_t **In1PP) -{ - - typedef __Request__mach_exception_raise_state_identity_t __Request; - __Request *In1P; -#if __MigTypeCheck - unsigned int msgh_size; -#endif /* __MigTypeCheck */ - unsigned int msgh_size_delta; - -#if __MigTypeCheck - msgh_size = In0P->Head.msgh_size; - if (!(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || - (In0P->msgh_body.msgh_descriptor_count != 2) || - (msgh_size < (mach_msg_size_t)(sizeof(__Request) - 912)) || (msgh_size > (mach_msg_size_t)sizeof(__Request))) - return MIG_BAD_ARGUMENTS; -#endif /* __MigTypeCheck */ - -#if __MigTypeCheck - if (In0P->thread.type != MACH_MSG_PORT_DESCRIPTOR || - In0P->thread.disposition != 17) - return MIG_TYPE_ERROR; -#endif /* __MigTypeCheck */ - -#if __MigTypeCheck - if (In0P->task.type != MACH_MSG_PORT_DESCRIPTOR || - In0P->task.disposition != 17) - return MIG_TYPE_ERROR; -#endif /* __MigTypeCheck */ - -#if defined(__NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__codeCnt__defined) - if (In0P->NDR.int_rep != NDR_record.int_rep) - __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__codeCnt(&In0P->codeCnt, In0P->NDR.int_rep); -#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__codeCnt__defined */ - msgh_size_delta = (8 * In0P->codeCnt); -#if __MigTypeCheck - if ( In0P->codeCnt > 2 ) - return MIG_BAD_ARGUMENTS; - if (((msgh_size - (mach_msg_size_t)(sizeof(__Request) - 912)) / 8 < In0P->codeCnt) || - (msgh_size < (mach_msg_size_t)(sizeof(__Request) - 912) + (8 * In0P->codeCnt))) - return MIG_BAD_ARGUMENTS; - msgh_size -= msgh_size_delta; -#endif /* __MigTypeCheck */ - - *In1PP = In1P = (__Request *) ((pointer_t) In0P + msgh_size_delta - 16); - -#if defined(__NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__old_stateCnt__defined) - if (In0P->NDR.int_rep != NDR_record.int_rep) - __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__old_stateCnt(&In1P->old_stateCnt, In1P->NDR.int_rep); -#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__old_stateCnt__defined */ -#if __MigTypeCheck - if ( In1P->old_stateCnt > 224 ) - return MIG_BAD_ARGUMENTS; - if (((msgh_size - (mach_msg_size_t)(sizeof(__Request) - 912)) / 4 < In1P->old_stateCnt) || - (msgh_size != (mach_msg_size_t)(sizeof(__Request) - 912) + (4 * In1P->old_stateCnt))) - return MIG_BAD_ARGUMENTS; -#endif /* __MigTypeCheck */ - - return MACH_MSG_SUCCESS; -} -#endif /* !defined(__MIG_check__Request__mach_exception_raise_state_identity_t__defined) */ -#endif /* __MIG_check__Request__mach_exc_subsystem__ */ -#endif /* ( __MigTypeCheck ) */ - - -/* Routine mach_exception_raise_state_identity */ -mig_internal novalue _Xmach_exception_raise_state_identity - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - -#ifdef __MigPackStructs -#pragma pack(4) -#endif - typedef struct { - mach_msg_header_t Head; - /* start of the kernel processed data */ - mach_msg_body_t msgh_body; - mach_msg_port_descriptor_t thread; - mach_msg_port_descriptor_t task; - /* end of the kernel processed data */ - NDR_record_t NDR; - exception_type_t exception; - mach_msg_type_number_t codeCnt; - int64_t code[2]; - int flavor; - mach_msg_type_number_t old_stateCnt; - natural_t old_state[224]; - mach_msg_trailer_t trailer; - } Request __attribute__((unused)); -#ifdef __MigPackStructs -#pragma pack() -#endif - typedef __Request__mach_exception_raise_state_identity_t __Request; - typedef __Reply__mach_exception_raise_state_identity_t Reply __attribute__((unused)); - - /* - * typedef struct { - * mach_msg_header_t Head; - * NDR_record_t NDR; - * kern_return_t RetCode; - * } mig_reply_error_t; - */ - - Request *In0P = (Request *) InHeadP; - Request *In1P; - Reply *OutP = (Reply *) OutHeadP; -#ifdef __MIG_check__Request__mach_exception_raise_state_identity_t__defined - kern_return_t check_result; -#endif /* __MIG_check__Request__mach_exception_raise_state_identity_t__defined */ - - __DeclareRcvRpc(2407, "mach_exception_raise_state_identity") - __BeforeRcvRpc(2407, "mach_exception_raise_state_identity") - -#if defined(__MIG_check__Request__mach_exception_raise_state_identity_t__defined) - check_result = __MIG_check__Request__mach_exception_raise_state_identity_t((__Request *)In0P, (__Request **)&In1P); - if (check_result != MACH_MSG_SUCCESS) - { MIG_RETURN_ERROR(OutP, check_result); } -#endif /* defined(__MIG_check__Request__mach_exception_raise_state_identity_t__defined) */ - - OutP->new_stateCnt = 224; - - OutP->RetCode = catch_mach_exception_raise_state_identity(In0P->Head.msgh_request_port, In0P->thread.name, In0P->task.name, In0P->exception, In0P->code, In0P->codeCnt, &In1P->flavor, In1P->old_state, In1P->old_stateCnt, OutP->new_state, &OutP->new_stateCnt); - if (OutP->RetCode != KERN_SUCCESS) { - MIG_RETURN_ERROR(OutP, OutP->RetCode); - } - - OutP->NDR = NDR_record; - - - OutP->flavor = In1P->flavor; - OutP->Head.msgh_size = (mach_msg_size_t)(sizeof(Reply) - 896) + (((4 * OutP->new_stateCnt))); - - __AfterRcvRpc(2407, "mach_exception_raise_state_identity") -} - - - -/* Description of this subsystem, for use in direct RPC */ -const struct catch_mach_exc_subsystem catch_mach_exc_subsystem = { - mach_exc_server_routine, - 2405, - 2408, - (mach_msg_size_t)sizeof(union __ReplyUnion__catch_mach_exc_subsystem), - (vm_address_t)0, - { - { (mig_impl_routine_t) 0, - (mig_stub_routine_t) _Xmach_exception_raise, 6, 0, (routine_arg_descriptor_t)0, (mach_msg_size_t)sizeof(__Reply__mach_exception_raise_t)}, - { (mig_impl_routine_t) 0, - (mig_stub_routine_t) _Xmach_exception_raise_state, 9, 0, (routine_arg_descriptor_t)0, (mach_msg_size_t)sizeof(__Reply__mach_exception_raise_state_t)}, - { (mig_impl_routine_t) 0, - (mig_stub_routine_t) _Xmach_exception_raise_state_identity, 11, 0, (routine_arg_descriptor_t)0, (mach_msg_size_t)sizeof(__Reply__mach_exception_raise_state_identity_t)}, - } -}; - -mig_external boolean_t mach_exc_server - (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) -{ - /* - * typedef struct { - * mach_msg_header_t Head; - * NDR_record_t NDR; - * kern_return_t RetCode; - * } mig_reply_error_t; - */ - - register mig_routine_t routine; - - OutHeadP->msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REPLY(InHeadP->msgh_bits), 0); - OutHeadP->msgh_remote_port = InHeadP->msgh_reply_port; - /* Minimal size: routine() will update it if different */ - OutHeadP->msgh_size = (mach_msg_size_t)sizeof(mig_reply_error_t); - OutHeadP->msgh_local_port = MACH_PORT_NULL; - OutHeadP->msgh_id = InHeadP->msgh_id + 100; - OutHeadP->msgh_reserved = 0; - - if ((InHeadP->msgh_id > 2407) || (InHeadP->msgh_id < 2405) || - ((routine = catch_mach_exc_subsystem.routine[InHeadP->msgh_id - 2405].stub_routine) == 0)) { - ((mig_reply_error_t *)OutHeadP)->NDR = NDR_record; - ((mig_reply_error_t *)OutHeadP)->RetCode = MIG_BAD_ID; - return FALSE; - } - (*routine) (InHeadP, OutHeadP); - return TRUE; -} - -mig_external mig_routine_t mach_exc_server_routine - (mach_msg_header_t *InHeadP) -{ - register int msgh_id; - - msgh_id = InHeadP->msgh_id - 2405; - - if ((msgh_id > 2) || (msgh_id < 0)) - return 0; - - return catch_mach_exc_subsystem.routine[msgh_id].stub_routine; -} - -#endif /* TARGET_OS_OSX || TARGET_OS_IOS */ diff --git a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/mach_excServer.h b/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/mach_excServer.h deleted file mode 100644 index 1f03d66c6..000000000 --- a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/mach_excServer.h +++ /dev/null @@ -1,329 +0,0 @@ -#ifdef __APPLE__ -#import "TargetConditionals.h" -#if TARGET_OS_OSX || TARGET_OS_IOS - -#ifndef _mach_exc_server_ -#define _mach_exc_server_ - -/* Module mach_exc */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -/* BEGIN VOUCHER CODE */ - -#ifndef KERNEL -#if defined(__has_include) -#if __has_include() -#ifndef USING_VOUCHERS -#define USING_VOUCHERS -#endif -#ifndef __VOUCHER_FORWARD_TYPE_DECLS__ -#define __VOUCHER_FORWARD_TYPE_DECLS__ -#ifdef __cplusplus -extern "C" { -#endif - extern boolean_t voucher_mach_msg_set(mach_msg_header_t *msg) __attribute__((weak_import)); -#ifdef __cplusplus -} -#endif -#endif // __VOUCHER_FORWARD_TYPE_DECLS__ -#endif // __has_include() -#endif // __has_include -#endif // !KERNEL - -/* END VOUCHER CODE */ - - -/* BEGIN MIG_STRNCPY_ZEROFILL CODE */ - -#if defined(__has_include) -#if __has_include() -#ifndef USING_MIG_STRNCPY_ZEROFILL -#define USING_MIG_STRNCPY_ZEROFILL -#endif -#ifndef __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ -#define __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ -#ifdef __cplusplus -extern "C" { -#endif - extern int mig_strncpy_zerofill(char *dest, const char *src, int len) __attribute__((weak_import)); -#ifdef __cplusplus -} -#endif -#endif /* __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ */ -#endif /* __has_include() */ -#endif /* __has_include */ - -/* END MIG_STRNCPY_ZEROFILL CODE */ - - -#ifdef AUTOTEST -#ifndef FUNCTION_PTR_T -#define FUNCTION_PTR_T -typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t); -typedef struct { - char *name; - function_ptr_t function; -} function_table_entry; -typedef function_table_entry *function_table_t; -#endif /* FUNCTION_PTR_T */ -#endif /* AUTOTEST */ - -#ifndef mach_exc_MSG_COUNT -#define mach_exc_MSG_COUNT 3 -#endif /* mach_exc_MSG_COUNT */ - -#include -#include -#include -#include - -#ifdef __BeforeMigServerHeader -__BeforeMigServerHeader -#endif /* __BeforeMigServerHeader */ - - -/* Routine mach_exception_raise */ -#ifdef mig_external -mig_external -#else -extern -#endif /* mig_external */ -kern_return_t catch_mach_exception_raise -( - mach_port_t exception_port, - mach_port_t thread, - mach_port_t task, - exception_type_t exception, - mach_exception_data_t code, - mach_msg_type_number_t codeCnt -); - -/* Routine mach_exception_raise_state */ -#ifdef mig_external -mig_external -#else -extern -#endif /* mig_external */ -kern_return_t catch_mach_exception_raise_state -( - mach_port_t exception_port, - exception_type_t exception, - const mach_exception_data_t code, - mach_msg_type_number_t codeCnt, - int *flavor, - const thread_state_t old_state, - mach_msg_type_number_t old_stateCnt, - thread_state_t new_state, - mach_msg_type_number_t *new_stateCnt -); - -/* Routine mach_exception_raise_state_identity */ -#ifdef mig_external -mig_external -#else -extern -#endif /* mig_external */ -kern_return_t catch_mach_exception_raise_state_identity -( - mach_port_t exception_port, - mach_port_t thread, - mach_port_t task, - exception_type_t exception, - mach_exception_data_t code, - mach_msg_type_number_t codeCnt, - int *flavor, - thread_state_t old_state, - mach_msg_type_number_t old_stateCnt, - thread_state_t new_state, - mach_msg_type_number_t *new_stateCnt -); - -#ifdef mig_external -mig_external -#else -extern -#endif /* mig_external */ -boolean_t mach_exc_server( - mach_msg_header_t *InHeadP, - mach_msg_header_t *OutHeadP); - -#ifdef mig_external -mig_external -#else -extern -#endif /* mig_external */ -mig_routine_t mach_exc_server_routine( - mach_msg_header_t *InHeadP); - - -/* Description of this subsystem, for use in direct RPC */ -extern const struct catch_mach_exc_subsystem { - mig_server_routine_t server; /* Server routine */ - mach_msg_id_t start; /* Min routine number */ - mach_msg_id_t end; /* Max routine number + 1 */ - unsigned int maxsize; /* Max msg size */ - vm_address_t reserved; /* Reserved */ - struct routine_descriptor /*Array of routine descriptors */ - routine[3]; -} catch_mach_exc_subsystem; - -/* typedefs for all requests */ - -#ifndef __Request__mach_exc_subsystem__defined -#define __Request__mach_exc_subsystem__defined - -#ifdef __MigPackStructs -#pragma pack(4) -#endif - typedef struct { - mach_msg_header_t Head; - /* start of the kernel processed data */ - mach_msg_body_t msgh_body; - mach_msg_port_descriptor_t thread; - mach_msg_port_descriptor_t task; - /* end of the kernel processed data */ - NDR_record_t NDR; - exception_type_t exception; - mach_msg_type_number_t codeCnt; - int64_t code[2]; - } __Request__mach_exception_raise_t __attribute__((unused)); -#ifdef __MigPackStructs -#pragma pack() -#endif - -#ifdef __MigPackStructs -#pragma pack(4) -#endif - typedef struct { - mach_msg_header_t Head; - NDR_record_t NDR; - exception_type_t exception; - mach_msg_type_number_t codeCnt; - int64_t code[2]; - int flavor; - mach_msg_type_number_t old_stateCnt; - natural_t old_state[224]; - } __Request__mach_exception_raise_state_t __attribute__((unused)); -#ifdef __MigPackStructs -#pragma pack() -#endif - -#ifdef __MigPackStructs -#pragma pack(4) -#endif - typedef struct { - mach_msg_header_t Head; - /* start of the kernel processed data */ - mach_msg_body_t msgh_body; - mach_msg_port_descriptor_t thread; - mach_msg_port_descriptor_t task; - /* end of the kernel processed data */ - NDR_record_t NDR; - exception_type_t exception; - mach_msg_type_number_t codeCnt; - int64_t code[2]; - int flavor; - mach_msg_type_number_t old_stateCnt; - natural_t old_state[224]; - } __Request__mach_exception_raise_state_identity_t __attribute__((unused)); -#ifdef __MigPackStructs -#pragma pack() -#endif -#endif /* !__Request__mach_exc_subsystem__defined */ - - -/* union of all requests */ - -#ifndef __RequestUnion__catch_mach_exc_subsystem__defined -#define __RequestUnion__catch_mach_exc_subsystem__defined -union __RequestUnion__catch_mach_exc_subsystem { - __Request__mach_exception_raise_t Request_mach_exception_raise; - __Request__mach_exception_raise_state_t Request_mach_exception_raise_state; - __Request__mach_exception_raise_state_identity_t Request_mach_exception_raise_state_identity; -}; -#endif /* __RequestUnion__catch_mach_exc_subsystem__defined */ -/* typedefs for all replies */ - -#ifndef __Reply__mach_exc_subsystem__defined -#define __Reply__mach_exc_subsystem__defined - -#ifdef __MigPackStructs -#pragma pack(4) -#endif - typedef struct { - mach_msg_header_t Head; - NDR_record_t NDR; - kern_return_t RetCode; - } __Reply__mach_exception_raise_t __attribute__((unused)); -#ifdef __MigPackStructs -#pragma pack() -#endif - -#ifdef __MigPackStructs -#pragma pack(4) -#endif - typedef struct { - mach_msg_header_t Head; - NDR_record_t NDR; - kern_return_t RetCode; - int flavor; - mach_msg_type_number_t new_stateCnt; - natural_t new_state[224]; - } __Reply__mach_exception_raise_state_t __attribute__((unused)); -#ifdef __MigPackStructs -#pragma pack() -#endif - -#ifdef __MigPackStructs -#pragma pack(4) -#endif - typedef struct { - mach_msg_header_t Head; - NDR_record_t NDR; - kern_return_t RetCode; - int flavor; - mach_msg_type_number_t new_stateCnt; - natural_t new_state[224]; - } __Reply__mach_exception_raise_state_identity_t __attribute__((unused)); -#ifdef __MigPackStructs -#pragma pack() -#endif -#endif /* !__Reply__mach_exc_subsystem__defined */ - - -/* union of all replies */ - -#ifndef __ReplyUnion__catch_mach_exc_subsystem__defined -#define __ReplyUnion__catch_mach_exc_subsystem__defined -union __ReplyUnion__catch_mach_exc_subsystem { - __Reply__mach_exception_raise_t Reply_mach_exception_raise; - __Reply__mach_exception_raise_state_t Reply_mach_exception_raise_state; - __Reply__mach_exception_raise_state_identity_t Reply_mach_exception_raise_state_identity; -}; -#endif /* __RequestUnion__catch_mach_exc_subsystem__defined */ - -#ifndef subsystem_to_name_map_mach_exc -#define subsystem_to_name_map_mach_exc \ - { "mach_exception_raise", 2405 },\ - { "mach_exception_raise_state", 2406 },\ - { "mach_exception_raise_state_identity", 2407 } -#endif - -#ifdef __AfterMigServerHeader -__AfterMigServerHeader -#endif /* __AfterMigServerHeader */ - -#endif /* _mach_exc_server_ */ - -#endif /* TARGET_OS_OSX || TARGET_OS_IOS */ -#endif /* __APPLE__ */ diff --git a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPosixPreconditionTesting/CwlCatchBadInstructionPosix.swift b/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPosixPreconditionTesting/CwlCatchBadInstructionPosix.swift deleted file mode 100644 index 0ee63e569..000000000 --- a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPosixPreconditionTesting/CwlCatchBadInstructionPosix.swift +++ /dev/null @@ -1,119 +0,0 @@ -// -// CwlCatchBadInstructionPosix.swift -// CwlPreconditionTesting -// -// Created by Matt Gallagher on 8/02/2016. -// Copyright © 2016 Matt Gallagher ( https://www.cocoawithlove.com ). All rights reserved. -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY -// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR -// IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// - -#if arch(x86_64) || arch(arm64) - -import Foundation - -// This file is an alternative implementation to CwlCatchBadInstruction.swift that uses a SIGILL signal action and setenv/longjmp instead of a Mach exception handler and Objective-C exception raising. -// -// WARNING: -// This code is quick and dirty. It's a proof of concept for using a SIGILL handler and setjmp/longjmp where Mach exceptions and the Obj-C runtime aren't available. I ran the automated tests when I first wrote this code but I don't personally use it at all so by the time you're reading this comment, it probably broke and I didn't notice. -// Obvious limitations: -// * It doesn't work when debugging with lldb. -// * It doesn't scope correctly to the thread (it's global) -// * In violation of rules for signal handlers, it writes to the "red zone" on the stack -// * It isn't re-entrant -// * Plus all of the same caveats as the Mach exceptions version (doesn't play well with other handlers, probably leaks ARC memory, etc) -// Treat it like a loaded shotgun. Don't point it at your face. - -// This function is called from the signal handler to shut down the thread and return 1 (indicating a SIGILL was received). -let callThreadExit = { - pthread_exit(UnsafeMutableRawPointer(bitPattern: 1)) -} as @convention(c) () -> Void - -// When called, this signal handler simulates a function call to `callThreadExit` -private func sigIllHandler(code: Int32, info: UnsafeMutablePointer<__siginfo>?, uap: UnsafeMutableRawPointer?) -> Void { - guard let context = uap?.bindMemory(to: ucontext64_t.self, capacity: 1) else { return } - - #if arch(x86_64) - // 1. Decrement the stack pointer - context.pointee.uc_mcontext64.pointee.__ss.__rsp -= UInt64(MemoryLayout.size) - - // 2. Save the old Instruction Pointer to the stack. - let rsp = context.pointee.uc_mcontext64.pointee.__ss.__rsp - if let ump = UnsafeMutablePointer(bitPattern: UInt(rsp)) { - ump.pointee = rsp - } - - // 3. Set the Instruction Pointer to the new function's address - context.pointee.uc_mcontext64.pointee.__ss.__rip = unsafeBitCast(callThreadExit, to: UInt64.self) - #elseif arch(arm64) - // 1. Set the link register to the current address. - context.pointee.uc_mcontext64.pointee.__ss.__lr = context.pointee.uc_mcontext64.pointee.__ss.__pc - - // 2. Set the Instruction Pointer to the new function's address. - context.pointee.uc_mcontext64.pointee.__ss.__pc = unsafeBitCast(callThreadExit, to: UInt64.self) - #endif -} - -/// Without Mach exceptions or the Objective-C runtime, there's nothing to put in the exception object. It's really just a boolean – either a SIGILL was caught or not. -public class BadInstructionException { -} - -#if arch(x86_64) -public let nativeSignal = SIGILL -#elseif arch(arm64) -public let nativeSignal = SIGTRAP -#endif - -/// Run the provided block. If a POSIX SIGILL is received, handle it and return a BadInstructionException (which is just an empty object in this POSIX signal version). Otherwise return nil. -/// NOTE: This function is only intended for use in test harnesses – use in a distributed build is almost certainly a bad choice. If a SIGILL is received, the block will be interrupted using a C `longjmp`. The risks associated with abrupt jumps apply here: most Swift functions are *not* interrupt-safe. Memory may be leaked and the program will not necessarily be left in a safe state. -/// - parameter block: a function without parameters that will be run -/// - returns: if an SIGILL is raised during the execution of `block` then a BadInstructionException will be returned, otherwise `nil`. -public func catchBadInstruction(block: @escaping () -> Void) -> BadInstructionException? { - // Construct the signal action - var sigActionPrev = sigaction() - let action = __sigaction_u(__sa_sigaction: sigIllHandler) - var sigActionNew = sigaction(__sigaction_u: action, sa_mask: sigset_t(), sa_flags: SA_SIGINFO) - - // Install the signal action - if sigaction(nativeSignal, &sigActionNew, &sigActionPrev) != 0 { - fatalError("Sigaction error: \(errno)") - } - - defer { - // Restore the previous signal action - if sigaction(nativeSignal, &sigActionPrev, nil) != 0 { - fatalError("Sigaction error: \(errno)") - } - } - - var b = block - let caught: Bool = withUnsafeMutablePointer(to: &b) { blockPtr in - // Run the block on its own thread - var handlerThread: pthread_t? = nil - let e = pthread_create(&handlerThread, nil, { arg in - arg.bindMemory(to: (() -> Void).self, capacity: 1).pointee() - return nil - }, blockPtr) - precondition(e == 0, "Unable to create thread") - - // Wait for completion and get the result. It will be either `nil` or bitPattern 1 - var rawResult: UnsafeMutableRawPointer? = nil - let e2 = pthread_join(handlerThread!, &rawResult) - precondition(e2 == 0, "Thread join failed") - return Int(bitPattern: rawResult) != 0 - } - - return caught ? BadInstructionException() : nil -} - -#endif diff --git a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlBadInstructionException.swift b/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlBadInstructionException.swift deleted file mode 100644 index 9ec85da8a..000000000 --- a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlBadInstructionException.swift +++ /dev/null @@ -1,92 +0,0 @@ -// -// CwlBadInstructionException.swift -// CwlPreconditionTesting -// -// Created by Matt Gallagher on 2016/01/10. -// Copyright © 2016 Matt Gallagher ( https://www.cocoawithlove.com ). All rights reserved. -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY -// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR -// IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// - -#if (os(macOS) || os(iOS)) && (arch(x86_64) || arch(arm64)) - -import Foundation - -#if SWIFT_PACKAGE - import CwlMachBadInstructionHandler -#endif - -var raiseBadInstructionException = { - BadInstructionException().raise() -} as @convention(c) () -> Void - -/// A simple NSException subclass. It's not required to subclass NSException (since the exception type is represented in the name) but this helps for identifying the exception through runtime type. -@objc(BadInstructionException) -public class BadInstructionException: NSException { - static var name: String = "com.cocoawithlove.BadInstruction" - - init() { - super.init(name: NSExceptionName(rawValue: BadInstructionException.name), reason: nil, userInfo: nil) - } - - required public init?(coder aDecoder: NSCoder) { - super.init(coder: aDecoder) - } - - /// An Objective-C callable function, invoked from the `mach_exc_server` callback function `catch_mach_exception_raise_state` to push the `raiseBadInstructionException` function onto the stack. - @objc(receiveReply:) - public class func receiveReply(_ reply: bad_instruction_exception_reply_t) -> CInt { - let old_state = UnsafeRawPointer(reply.old_state!).bindMemory(to: NativeThreadState.self, capacity: 1) - let old_stateCnt: mach_msg_type_number_t = reply.old_stateCnt - let new_state = UnsafeMutableRawPointer(reply.new_state!).bindMemory(to: NativeThreadState.self, capacity: 1) - let new_stateCnt: UnsafeMutablePointer = reply.new_stateCnt! - - // Make sure we've been given enough memory - guard - old_stateCnt == nativeThreadStateCount, - new_stateCnt.pointee >= nativeThreadStateCount - else { - return KERN_INVALID_ARGUMENT - } - - // 0. Copy over the state. - new_state.pointee = old_state.pointee - -#if arch(x86_64) - // 1. Decrement the stack pointer - new_state.pointee.__rsp -= UInt64(MemoryLayout.size) - - // 2. Save the old Instruction Pointer to the stack. - guard let pointer = UnsafeMutablePointer(bitPattern: UInt(new_state.pointee.__rsp)) else { - return KERN_INVALID_ARGUMENT - } - pointer.pointee = old_state.pointee.__rip - - // 3. Set the Instruction Pointer to the new function's address - new_state.pointee.__rip = unsafeBitCast(raiseBadInstructionException, to: UInt64.self) - -#elseif arch(arm64) - // 1. Set the link register to the current address. - new_state.pointee.__lr = old_state.pointee.__pc - - // 2. Set the Instruction Pointer to the new function's address. - new_state.pointee.__pc = unsafeBitCast(raiseBadInstructionException, to: UInt64.self) -#endif - - new_stateCnt.pointee = nativeThreadStateCount - - return KERN_SUCCESS - } -} - -#endif diff --git a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlCatchBadInstruction.swift b/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlCatchBadInstruction.swift deleted file mode 100644 index 7232c24dd..000000000 --- a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlCatchBadInstruction.swift +++ /dev/null @@ -1,209 +0,0 @@ -// -// CwlCatchBadInstruction.swift -// CwlPreconditionTesting -// -// Created by Matt Gallagher on 2016/01/10. -// Copyright © 2016 Matt Gallagher ( https://www.cocoawithlove.com ). All rights reserved. -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY -// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR -// IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// - -#if (os(macOS) || os(iOS)) && (arch(x86_64) || arch(arm64)) - -import Foundation -import Swift - -#if SWIFT_PACKAGE - import CwlMachBadInstructionHandler -#endif - -private enum PthreadError: Error { case code(Int32) } -private enum MachExcServer: Error { case code(kern_return_t) } - -/// A quick function for converting Mach error results into Swift errors -private func kernCheck(_ f: () -> Int32) throws { - let r = f() - guard r == KERN_SUCCESS else { - throw NSError(domain: NSMachErrorDomain, code: Int(r), userInfo: nil) - } -} - -extension request_mach_exception_raise_t { - mutating func withMsgHeaderPointer(in block: (UnsafeMutablePointer) -> R) -> R { - return withUnsafeMutablePointer(to: &self) { p -> R in - return p.withMemoryRebound(to: mach_msg_header_t.self, capacity: 1) { ptr -> R in - return block(ptr) - } - } - } -} - -extension reply_mach_exception_raise_state_t { - mutating func withMsgHeaderPointer(in block: (UnsafeMutablePointer) -> R) -> R { - return withUnsafeMutablePointer(to: &self) { p -> R in - return p.withMemoryRebound(to: mach_msg_header_t.self, capacity: 1) { ptr -> R in - return block(ptr) - } - } - } -} - -/// A structure used to store context associated with the Mach message port -private struct MachContext { - var masks = execTypesCountTuple() - var count: mach_msg_type_number_t = 0 - var ports = execTypesCountTuple() - var behaviors = execTypesCountTuple() - var flavors = execTypesCountTuple() - var currentExceptionPort: mach_port_t = 0 - var handlerThread: pthread_t? = nil - - static func internalMutablePointers(_ m: UnsafeMutablePointer>, _ c: UnsafeMutablePointer, _ p: UnsafeMutablePointer>, _ b: UnsafeMutablePointer>, _ f: UnsafeMutablePointer>, _ block: (UnsafeMutablePointer, UnsafeMutablePointer, UnsafeMutablePointer, UnsafeMutablePointer, UnsafeMutablePointer) -> R) -> R { - return m.withMemoryRebound(to: exception_mask_t.self, capacity: 1) { masksPtr in - return c.withMemoryRebound(to: mach_msg_type_number_t.self, capacity: 1) { countPtr in - return p.withMemoryRebound(to: mach_port_t.self, capacity: 1) { portsPtr in - return b.withMemoryRebound(to: exception_behavior_t.self, capacity: 1) { behaviorsPtr in - return f.withMemoryRebound(to: thread_state_flavor_t.self, capacity: 1) { flavorsPtr in - return block(masksPtr, countPtr, portsPtr, behaviorsPtr, flavorsPtr) - } - } - } - } - } - } - - mutating func withUnsafeMutablePointers(in block: @escaping (UnsafeMutablePointer, UnsafeMutablePointer, UnsafeMutablePointer, UnsafeMutablePointer, UnsafeMutablePointer) -> R) -> R { - return MachContext.internalMutablePointers(&masks, &count, &ports, &behaviors, &flavors, block) - } -} - -/// A function for receiving mach messages and parsing the first with mach_exc_server (and if any others are received, throwing them away). -private func machMessageHandler(_ arg: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer? { - let context = arg.assumingMemoryBound(to: MachContext.self).pointee - var request = request_mach_exception_raise_t() - var reply = reply_mach_exception_raise_state_t() - - var handledfirstException = false - repeat { do { - // Request the next mach message from the port - request.Head.msgh_local_port = context.currentExceptionPort - request.Head.msgh_size = UInt32(MemoryLayout.size) - let requestSize = request.Head.msgh_size - try kernCheck { request.withMsgHeaderPointer { requestPtr in - mach_msg(requestPtr, MACH_RCV_MSG | MACH_RCV_INTERRUPT, 0, requestSize, context.currentExceptionPort, 0, UInt32(MACH_PORT_NULL)) - } } - - // Prepare the reply structure - reply.Head.msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REMOTE(request.Head.msgh_bits), 0) - reply.Head.msgh_local_port = UInt32(MACH_PORT_NULL) - reply.Head.msgh_remote_port = request.Head.msgh_remote_port - reply.Head.msgh_size = UInt32(MemoryLayout.size) - reply.NDR = mach_ndr_record() - - if !handledfirstException { - // Use the MiG generated server to invoke our handler for the request and fill in the rest of the reply structure - guard request.withMsgHeaderPointer(in: { requestPtr in reply.withMsgHeaderPointer { replyPtr in - mach_exc_server(requestPtr, replyPtr) - } }) != 0 else { throw MachExcServer.code(reply.RetCode) } - - handledfirstException = true - } else { - // If multiple fatal errors occur, don't handle subsquent errors (let the program crash) - reply.RetCode = KERN_FAILURE - } - - // Send the reply - let replySize = reply.Head.msgh_size - try kernCheck { reply.withMsgHeaderPointer { replyPtr in - mach_msg(replyPtr, MACH_SEND_MSG, replySize, 0, UInt32(MACH_PORT_NULL), 0, UInt32(MACH_PORT_NULL)) - } } - } catch let error as NSError where (error.domain == NSMachErrorDomain && (error.code == Int(MACH_RCV_PORT_CHANGED) || error.code == Int(MACH_RCV_INVALID_NAME))) { - // Port was already closed before we started or closed while we were listening. - // This means the controlling thread shut down. - return nil - } catch { - // Should never be reached but this is testing code, don't try to recover, just abort - fatalError("Mach message error: \(error)") - } } while true -} - -/// Run the provided block. If a mach "BAD_INSTRUCTION" exception is raised, catch it and return a BadInstructionException (which captures stack information about the throw site, if desired). Otherwise return nil. -/// NOTE: This function is only intended for use in test harnesses – use in a distributed build is almost certainly a bad choice. If a "BAD_INSTRUCTION" exception is raised, the block will be exited before completion via Objective-C exception. The risks associated with an Objective-C exception apply here: most Swift/Objective-C functions are *not* exception-safe. Memory may be leaked and the program will not necessarily be left in a safe state. -/// - parameter block: a function without parameters that will be run -/// - returns: if an EXC_BAD_INSTRUCTION is raised during the execution of `block` then a BadInstructionException will be returned, otherwise `nil`. -public func catchBadInstruction(in block: @escaping () -> Void) -> BadInstructionException? { - // Suppress Swift runtime's direct triggering of the debugger and exclusivity checking which crashes when we throw past it - let previousExclusivity = _swift_disableExclusivityChecking - let previousReporting = _swift_reportFatalErrorsToDebugger - _swift_disableExclusivityChecking = true - _swift_reportFatalErrorsToDebugger = false - defer { - _swift_reportFatalErrorsToDebugger = previousReporting - _swift_disableExclusivityChecking = previousExclusivity - } - - var context = MachContext() - var result: BadInstructionException? = nil - do { - var handlerThread: pthread_t? = nil - defer { - // 8. Wait for the thread to terminate *if* we actually made it to the creation point - // The mach port should be destroyed *before* calling pthread_join to avoid a deadlock. - if handlerThread != nil { - pthread_join(handlerThread!, nil) - } - } - - try kernCheck { - // 1. Create the mach port - mach_port_allocate(mach_task_self_, MACH_PORT_RIGHT_RECEIVE, &context.currentExceptionPort) - } - defer { - // 7. Cleanup the mach port - mach_port_destroy(mach_task_self_, context.currentExceptionPort) - } - - try kernCheck { - // 2. Configure the mach port - mach_port_insert_right(mach_task_self_, context.currentExceptionPort, context.currentExceptionPort, MACH_MSG_TYPE_MAKE_SEND) - } - - let currentExceptionPtr = context.currentExceptionPort - try kernCheck { context.withUnsafeMutablePointers { masksPtr, countPtr, portsPtr, behaviorsPtr, flavorsPtr in - // 3. Apply the mach port as the handler for this thread - thread_swap_exception_ports(mach_thread_self(), nativeMachExceptionMask, currentExceptionPtr, Int32(bitPattern: UInt32(EXCEPTION_STATE) | MACH_EXCEPTION_CODES), nativeThreadState, masksPtr, countPtr, portsPtr, behaviorsPtr, flavorsPtr) - } } - - defer { context.withUnsafeMutablePointers { masksPtr, countPtr, portsPtr, behaviorsPtr, flavorsPtr in - // 6. Unapply the mach port - _ = thread_swap_exception_ports(mach_thread_self(), nativeMachExceptionMask, 0, EXCEPTION_DEFAULT, THREAD_STATE_NONE, masksPtr, countPtr, portsPtr, behaviorsPtr, flavorsPtr) - } } - - try withUnsafeMutablePointer(to: &context) { c throws in - // 4. Create the thread - let e = pthread_create(&handlerThread, nil, machMessageHandler, c) - guard e == 0 else { throw PthreadError.code(e) } - - // 5. Run the block - result = BadInstructionException.catchException(in: block) - } - } catch { - // Should never be reached but this is testing code, don't try to recover, just abort - fatalError("Mach port error: \(error)") - } - - return result -} - -#endif - diff --git a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlDarwinDefinitions.swift b/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlDarwinDefinitions.swift deleted file mode 100644 index ccce5c59d..000000000 --- a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlDarwinDefinitions.swift +++ /dev/null @@ -1,64 +0,0 @@ -// -// CwlDarwinDefinitions.swift -// CwlPreconditionTesting -// -// Created by Matt Gallagher on 2016/01/10. -// Copyright © 2016 Matt Gallagher ( https://www.cocoawithlove.com ). All rights reserved. -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY -// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR -// IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -// - -#if (os(macOS) || os(iOS)) && (arch(x86_64) || arch(arm64)) - -import Darwin - -// From /usr/include/mach/message.h -// #define MACH_MSG_TYPE_MAKE_SEND 20 /* Must hold receive right */ -// #define MACH_MSGH_BITS_REMOTE(bits) \ -// ((bits) & MACH_MSGH_BITS_REMOTE_MASK) -// #define MACH_MSGH_BITS(remote, local) /* legacy */ \ -// ((remote) | ((local) << 8)) -public let MACH_MSG_TYPE_MAKE_SEND: UInt32 = 20 -public func MACH_MSGH_BITS_REMOTE(_ bits: UInt32) -> UInt32 { return bits & UInt32(MACH_MSGH_BITS_REMOTE_MASK) } -public func MACH_MSGH_BITS(_ remote: UInt32, _ local: UInt32) -> UInt32 { return ((remote) | ((local) << 8)) } - -// From /usr/include/mach/exception_types.h -// #define EXC_BAD_INSTRUCTION 2 /* Instruction failed */ -// #define EXC_MASK_BAD_INSTRUCTION (1 << EXC_BAD_INSTRUCTION) -//public let EXC_MASK_BAD_INSTRUCTION: UInt32 = 1 << EXC_BAD_INSTRUCTION - -#if arch(x86_64) -// From /usr/include/mach/i386/thread_status.h -// #define x86_threadStateCount ((mach_msg_type_number_t) \ -// ( sizeof (x86_NativeThreadState) / sizeof (int) )) -public let nativeThreadState = x86_THREAD_STATE64 -public let nativeThreadStateCount = UInt32(MemoryLayout.size / MemoryLayout.size) -typealias NativeThreadState = x86_thread_state64_t -public let nativeMachExceptionMask = exception_mask_t(EXC_MASK_BAD_INSTRUCTION) -#elseif arch(arm64) -public let nativeThreadState = ARM_THREAD_STATE64 -public let nativeThreadStateCount = UInt32(MemoryLayout.size / MemoryLayout.size) -typealias NativeThreadState = arm_thread_state64_t -public let nativeMachExceptionMask = exception_mask_t(EXC_MASK_BREAKPOINT) -#endif - -public let EXC_TYPES_COUNT = 14 -public struct execTypesCountTuple { - // From /usr/include/mach/i386/exception.h - // #define EXC_TYPES_COUNT 14 /* incl. illegal exception 0 */ - public var value: (T, T, T, T, T, T, T, T, T, T, T, T, T, T) = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) - public init() { - } -} - -#endif diff --git a/Nimble.podspec b/Nimble.podspec index 3bc2a4972..800bf72c8 100644 --- a/Nimble.podspec +++ b/Nimble.podspec @@ -17,37 +17,10 @@ Pod::Spec.new do |s| s.source_files = [ "Sources/**/*.{swift,h,m,c}", - "Carthage/Checkouts/CwlCatchException/Sources/**/*.{swift,h,m,c}", - "Carthage/Checkouts/CwlPreconditionTesting/Sources/**/*.{swift,h,m,c}", ] s.header_dir = "Nimble" - s.osx.exclude_files = [ - "Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPosixPreconditionTesting/CwlCatchBadInstructionPosix.swift", - ] - s.ios.exclude_files = [ - "Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPosixPreconditionTesting/CwlCatchBadInstructionPosix.swift", - ] - s.tvos.exclude_files = [ - "Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/include/CwlMachBadInstructionHandler.h", - "Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlCatchBadInstruction.swift", - "Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlBadInstructionException.swift", - "Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlDarwinDefinitions.swift", - "Carthage/Checkouts/CwlCatchException/Sources/CwlCatchException/CwlCatchException.swift", - "Carthage/Checkouts/CwlCatchException/Sources/CwlCatchExceptionSupport/CwlCatchException.m", - "Carthage/Checkouts/CwlCatchException/Sources/CwlCatchExceptionSupport/include/CwlCatchException.h", - ] - s.watchos.exclude_files = [ - "Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/include/CwlMachBadInstructionHandler.h", - "Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlCatchBadInstruction.swift", - "Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlBadInstructionException.swift", - "Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlDarwinDefinitions.swift", - "Carthage/Checkouts/CwlCatchException/Sources/CwlCatchException/CwlCatchException.swift", - "Carthage/Checkouts/CwlCatchException/Sources/CwlCatchExceptionSupport/CwlCatchException.m", - "Carthage/Checkouts/CwlCatchException/Sources/CwlCatchExceptionSupport/include/CwlCatchException.h", - ] - s.exclude_files = "Sources/Nimble/Adapters/NonObjectiveC/*.swift" s.weak_framework = "XCTest" s.requires_arc = true @@ -61,6 +34,10 @@ Pod::Spec.new do |s| 'OTHER_SWIFT_FLAGS' => '$(inherited) -suppress-warnings', } + + s.dependency 'CwlPreconditionTesting', '~> 2.1.0' + s.dependency 'CwlCatchException', '~> 2.1.0' + s.cocoapods_version = '>= 1.4.0' if s.respond_to?(:swift_versions) then s.swift_versions = ['5.0'] diff --git a/Nimble.xcodeproj/project.pbxproj b/Nimble.xcodeproj/project.pbxproj index 9c387bc9d..13e6b49fc 100644 --- a/Nimble.xcodeproj/project.pbxproj +++ b/Nimble.xcodeproj/project.pbxproj @@ -132,9 +132,11 @@ 898F28B025D9F4C30052B8D0 /* AlwaysFailMatcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 898F28AF25D9F4C30052B8D0 /* AlwaysFailMatcher.swift */; }; 899441EF2902EE4B00C1FAF9 /* AsyncAwaitTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 899441EE2902EE4B00C1FAF9 /* AsyncAwaitTest.swift */; }; 899441F82902EF2500C1FAF9 /* DSL+AsyncAwait.swift in Sources */ = {isa = PBXBuildFile; fileRef = 899441F32902EF0900C1FAF9 /* DSL+AsyncAwait.swift */; }; - 89AD7E102ACB16E50076FAAF /* CwlCatchBadInstructionPosix.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD3D9A78232647BC00802581 /* CwlCatchBadInstructionPosix.swift */; platformFilters = (tvos, watchos, ); }; 89C297CC2A911CDA002A143F /* AsyncTimerSequenceTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89C297CB2A911CDA002A143F /* AsyncTimerSequenceTest.swift */; }; 89C297CE2A92AB34002A143F /* AsyncPromiseTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89C297CD2A92AB34002A143F /* AsyncPromiseTest.swift */; }; + 89D8AC852B3211C600410644 /* CwlCatchException in Frameworks */ = {isa = PBXBuildFile; productRef = 89D8AC842B3211C600410644 /* CwlCatchException */; }; + 89D8AC872B3211EA00410644 /* CwlPosixPreconditionTesting in Frameworks */ = {isa = PBXBuildFile; platformFilters = (tvos, watchos, ); productRef = 89D8AC862B3211EA00410644 /* CwlPosixPreconditionTesting */; }; + 89D8AC892B3211EA00410644 /* CwlPreconditionTesting in Frameworks */ = {isa = PBXBuildFile; platformFilters = (driverkit, ios, maccatalyst, macos, ); productRef = 89D8AC882B3211EA00410644 /* CwlPreconditionTesting */; }; 89EEF5A52A03293100988224 /* AsyncMatcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89EEF5A42A03293100988224 /* AsyncMatcher.swift */; }; 89EEF5B72A032C3200988224 /* AsyncPredicateTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89EEF5B22A032C2500988224 /* AsyncPredicateTest.swift */; }; 89EEF5C02A06211C00988224 /* AsyncHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89EEF5BB2A06210D00988224 /* AsyncHelpers.swift */; }; @@ -165,15 +167,6 @@ CDC157912511957100EAA480 /* DSLTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDC157902511957100EAA480 /* DSLTest.swift */; }; CDD80B831F2030790002CD65 /* MatcherProtocols.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FD8CD1D1968AB07008ED995 /* MatcherProtocols.swift */; }; CDF5C57B2647B89B0036532C /* Equal+Tuple.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDF5C57A2647B89B0036532C /* Equal+Tuple.swift */; }; - CDFB6A231F7E07C700AD8CC7 /* CwlCatchException.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDFB6A1E1F7E07C600AD8CC7 /* CwlCatchException.swift */; platformFilters = (driverkit, ios, maccatalyst, macos, ); }; - CDFB6A251F7E07C700AD8CC7 /* CwlCatchException.m in Sources */ = {isa = PBXBuildFile; fileRef = CDFB6A201F7E07C600AD8CC7 /* CwlCatchException.m */; platformFilters = (driverkit, ios, maccatalyst, macos, ); }; - CDFB6A271F7E07C700AD8CC7 /* CwlCatchException.h in Headers */ = {isa = PBXBuildFile; fileRef = CDFB6A221F7E07C600AD8CC7 /* CwlCatchException.h */; platformFilters = (driverkit, ios, maccatalyst, macos, ); settings = {ATTRIBUTES = (Public, ); }; }; - CDFB6A391F7E082500AD8CC7 /* CwlBadInstructionException.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDFB6A2A1F7E082400AD8CC7 /* CwlBadInstructionException.swift */; platformFilters = (driverkit, ios, maccatalyst, macos, ); }; - CDFB6A3B1F7E082500AD8CC7 /* CwlCatchBadInstruction.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDFB6A2B1F7E082400AD8CC7 /* CwlCatchBadInstruction.swift */; platformFilters = (driverkit, ios, maccatalyst, macos, ); }; - CDFB6A3F1F7E082500AD8CC7 /* CwlDarwinDefinitions.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDFB6A2D1F7E082400AD8CC7 /* CwlDarwinDefinitions.swift */; platformFilters = (driverkit, ios, maccatalyst, macos, ); }; - CDFB6A471F7E082500AD8CC7 /* CwlMachBadInstructionHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = CDFB6A341F7E082400AD8CC7 /* CwlMachBadInstructionHandler.m */; }; - CDFB6A491F7E082500AD8CC7 /* CwlMachBadInstructionHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = CDFB6A361F7E082400AD8CC7 /* CwlMachBadInstructionHandler.h */; platformFilters = (driverkit, ios, maccatalyst, macos, ); settings = {ATTRIBUTES = (Public, ); }; }; - CDFB6A4B1F7E082500AD8CC7 /* mach_excServer.c in Sources */ = {isa = PBXBuildFile; fileRef = CDFB6A371F7E082400AD8CC7 /* mach_excServer.c */; platformFilters = (driverkit, ios, maccatalyst, macos, ); }; DA9E8C831A414BB9002633C2 /* DSL+Wait.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA9E8C811A414BB9002633C2 /* DSL+Wait.swift */; }; DD72EC651A93874A002F7651 /* AllPassTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD72EC631A93874A002F7651 /* AllPassTest.swift */; }; DD9A9A9019CF43AD00706F49 /* BeIdenticalToObjectTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD9A9A8D19CF413800706F49 /* BeIdenticalToObjectTest.swift */; }; @@ -341,20 +334,9 @@ B20058C020E92C7500C1264D /* ElementsEqual.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ElementsEqual.swift; sourceTree = ""; }; B20058C420E92CE400C1264D /* ElementsEqualTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ElementsEqualTest.swift; sourceTree = ""; }; C576224C2A61D3AE00BD6A8C /* Equal+TupleArray.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Equal+TupleArray.swift"; sourceTree = ""; }; - CD3D9A78232647BC00802581 /* CwlCatchBadInstructionPosix.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CwlCatchBadInstructionPosix.swift; sourceTree = ""; }; CDBC39B82462EA7D00069677 /* PredicateTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PredicateTest.swift; sourceTree = ""; }; CDC157902511957100EAA480 /* DSLTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DSLTest.swift; sourceTree = ""; }; CDF5C57A2647B89B0036532C /* Equal+Tuple.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Equal+Tuple.swift"; sourceTree = ""; }; - CDFB6A1E1F7E07C600AD8CC7 /* CwlCatchException.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CwlCatchException.swift; sourceTree = ""; }; - CDFB6A201F7E07C600AD8CC7 /* CwlCatchException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CwlCatchException.m; sourceTree = ""; }; - CDFB6A221F7E07C600AD8CC7 /* CwlCatchException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CwlCatchException.h; sourceTree = ""; }; - CDFB6A2A1F7E082400AD8CC7 /* CwlBadInstructionException.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CwlBadInstructionException.swift; sourceTree = ""; }; - CDFB6A2B1F7E082400AD8CC7 /* CwlCatchBadInstruction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CwlCatchBadInstruction.swift; sourceTree = ""; }; - CDFB6A2D1F7E082400AD8CC7 /* CwlDarwinDefinitions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CwlDarwinDefinitions.swift; sourceTree = ""; }; - CDFB6A341F7E082400AD8CC7 /* CwlMachBadInstructionHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CwlMachBadInstructionHandler.m; sourceTree = ""; }; - CDFB6A361F7E082400AD8CC7 /* CwlMachBadInstructionHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CwlMachBadInstructionHandler.h; sourceTree = ""; }; - CDFB6A371F7E082400AD8CC7 /* mach_excServer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mach_excServer.c; sourceTree = ""; }; - CDFB6A381F7E082400AD8CC7 /* mach_excServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mach_excServer.h; sourceTree = ""; }; DA9E8C811A414BB9002633C2 /* DSL+Wait.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "DSL+Wait.swift"; sourceTree = ""; }; DD72EC631A93874A002F7651 /* AllPassTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AllPassTest.swift; sourceTree = ""; }; DD9A9A8D19CF413800706F49 /* BeIdenticalToObjectTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BeIdenticalToObjectTest.swift; sourceTree = ""; }; @@ -370,6 +352,9 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 89D8AC872B3211EA00410644 /* CwlPosixPreconditionTesting in Frameworks */, + 89D8AC852B3211C600410644 /* CwlCatchException in Frameworks */, + 89D8AC892B3211EA00410644 /* CwlPreconditionTesting in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -423,9 +408,9 @@ 1F1871B91CA89E1B00A34BF2 /* NimbleObjectiveC */, 1F1A74381940169200FFFC47 /* NimbleTests */, 1FFD729A1963FC8200CD29A2 /* NimbleObjectiveCTests */, - CDFB69521F7E06E600AD8CC7 /* Carthage-Checkouts */, 8913628529E6687500AD535E /* NimbleSharedTestHelpers */, 1F1A742A1940169200FFFC47 /* Products */, + 89D8AC832B3211C600410644 /* Frameworks */, ); indentWidth = 4; sourceTree = ""; @@ -668,97 +653,11 @@ path = include; sourceTree = ""; }; - CD3D9A77232647BC00802581 /* CwlPosixPreconditionTesting */ = { + 89D8AC832B3211C600410644 /* Frameworks */ = { isa = PBXGroup; children = ( - CD3D9A78232647BC00802581 /* CwlCatchBadInstructionPosix.swift */, ); - path = CwlPosixPreconditionTesting; - sourceTree = ""; - }; - CDFB69521F7E06E600AD8CC7 /* Carthage-Checkouts */ = { - isa = PBXGroup; - children = ( - CDFB69551F7E076F00AD8CC7 /* CwlCatchException */, - CDFB69741F7E076F00AD8CC7 /* CwlPreconditionTesting */, - ); - name = "Carthage-Checkouts"; - path = Carthage/Checkouts; - sourceTree = ""; - }; - CDFB69551F7E076F00AD8CC7 /* CwlCatchException */ = { - isa = PBXGroup; - children = ( - CDFB6A1D1F7E07C600AD8CC7 /* CwlCatchException */, - CDFB6A1F1F7E07C600AD8CC7 /* CwlCatchExceptionSupport */, - ); - name = CwlCatchException; - path = CwlCatchException/Sources; - sourceTree = ""; - }; - CDFB69741F7E076F00AD8CC7 /* CwlPreconditionTesting */ = { - isa = PBXGroup; - children = ( - CDFB6A331F7E082400AD8CC7 /* CwlMachBadInstructionHandler */, - CDFB6A291F7E082400AD8CC7 /* CwlPreconditionTesting */, - CD3D9A77232647BC00802581 /* CwlPosixPreconditionTesting */, - ); - name = CwlPreconditionTesting; - path = CwlPreconditionTesting/Sources; - sourceTree = ""; - }; - CDFB6A1D1F7E07C600AD8CC7 /* CwlCatchException */ = { - isa = PBXGroup; - children = ( - CDFB6A1E1F7E07C600AD8CC7 /* CwlCatchException.swift */, - ); - path = CwlCatchException; - sourceTree = ""; - }; - CDFB6A1F1F7E07C600AD8CC7 /* CwlCatchExceptionSupport */ = { - isa = PBXGroup; - children = ( - CDFB6A201F7E07C600AD8CC7 /* CwlCatchException.m */, - CDFB6A211F7E07C600AD8CC7 /* include */, - ); - path = CwlCatchExceptionSupport; - sourceTree = ""; - }; - CDFB6A211F7E07C600AD8CC7 /* include */ = { - isa = PBXGroup; - children = ( - CDFB6A221F7E07C600AD8CC7 /* CwlCatchException.h */, - ); - path = include; - sourceTree = ""; - }; - CDFB6A291F7E082400AD8CC7 /* CwlPreconditionTesting */ = { - isa = PBXGroup; - children = ( - CDFB6A2A1F7E082400AD8CC7 /* CwlBadInstructionException.swift */, - CDFB6A2B1F7E082400AD8CC7 /* CwlCatchBadInstruction.swift */, - CDFB6A2D1F7E082400AD8CC7 /* CwlDarwinDefinitions.swift */, - ); - path = CwlPreconditionTesting; - sourceTree = ""; - }; - CDFB6A331F7E082400AD8CC7 /* CwlMachBadInstructionHandler */ = { - isa = PBXGroup; - children = ( - CDFB6A341F7E082400AD8CC7 /* CwlMachBadInstructionHandler.m */, - CDFB6A351F7E082400AD8CC7 /* include */, - CDFB6A371F7E082400AD8CC7 /* mach_excServer.c */, - CDFB6A381F7E082400AD8CC7 /* mach_excServer.h */, - ); - path = CwlMachBadInstructionHandler; - sourceTree = ""; - }; - CDFB6A351F7E082400AD8CC7 /* include */ = { - isa = PBXGroup; - children = ( - CDFB6A361F7E082400AD8CC7 /* CwlMachBadInstructionHandler.h */, - ); - path = include; + name = Frameworks; sourceTree = ""; }; /* End PBXGroup section */ @@ -768,8 +667,6 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - CDFB6A491F7E082500AD8CC7 /* CwlMachBadInstructionHandler.h in Headers */, - CDFB6A271F7E07C700AD8CC7 /* CwlCatchException.h in Headers */, 1F1871DF1CA89EF500A34BF2 /* NMBStringify.h in Headers */, 1F1871DD1CA89EF500A34BF2 /* DSL.h in Headers */, 1F1871DE1CA89EF500A34BF2 /* NMBExceptionCapture.h in Headers */, @@ -794,6 +691,11 @@ dependencies = ( ); name = Nimble; + packageProductDependencies = ( + 89D8AC842B3211C600410644 /* CwlCatchException */, + 89D8AC862B3211EA00410644 /* CwlPosixPreconditionTesting */, + 89D8AC882B3211EA00410644 /* CwlPreconditionTesting */, + ); productName = "Nimble-macOS"; productReference = 1F925EAD195C0D6300ED456B /* Nimble.framework */; productType = "com.apple.product-type.framework"; @@ -851,6 +753,10 @@ Base, ); mainGroup = 1F1A741F1940169200FFFC47; + packageReferences = ( + 89D8AC812B32119300410644 /* XCRemoteSwiftPackageReference "CwlCatchException" */, + 89D8AC822B3211A900410644 /* XCRemoteSwiftPackageReference "CwlPreconditionTesting" */, + ); productRefGroup = 1F1A742A1940169200FFFC47 /* Products */; projectDirPath = ""; projectRoot = ""; @@ -900,14 +806,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - CDFB6A3F1F7E082500AD8CC7 /* CwlDarwinDefinitions.swift in Sources */, - CDFB6A3B1F7E082500AD8CC7 /* CwlCatchBadInstruction.swift in Sources */, - CDFB6A231F7E07C700AD8CC7 /* CwlCatchException.swift in Sources */, - CDFB6A391F7E082500AD8CC7 /* CwlBadInstructionException.swift in Sources */, - CDFB6A251F7E07C700AD8CC7 /* CwlCatchException.m in Sources */, - CDFB6A4B1F7E082500AD8CC7 /* mach_excServer.c in Sources */, - 89AD7E102ACB16E50076FAAF /* CwlCatchBadInstructionPosix.swift in Sources */, - CDFB6A471F7E082500AD8CC7 /* CwlMachBadInstructionHandler.m in Sources */, 1FD8CD411968AB07008ED995 /* BeCloseTo.swift in Sources */, 1F1871D31CA89EEE00A34BF2 /* NMBExceptionCapture.m in Sources */, 106112BD2251DFE7000A5848 /* BeResult.swift in Sources */, @@ -1416,6 +1314,43 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ + +/* Begin XCRemoteSwiftPackageReference section */ + 89D8AC812B32119300410644 /* XCRemoteSwiftPackageReference "CwlCatchException" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/mattgallagher/CwlCatchException"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 2.1.2; + }; + }; + 89D8AC822B3211A900410644 /* XCRemoteSwiftPackageReference "CwlPreconditionTesting" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/mattgallagher/CwlPreconditionTesting"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 2.2.0; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 89D8AC842B3211C600410644 /* CwlCatchException */ = { + isa = XCSwiftPackageProductDependency; + package = 89D8AC812B32119300410644 /* XCRemoteSwiftPackageReference "CwlCatchException" */; + productName = CwlCatchException; + }; + 89D8AC862B3211EA00410644 /* CwlPosixPreconditionTesting */ = { + isa = XCSwiftPackageProductDependency; + package = 89D8AC822B3211A900410644 /* XCRemoteSwiftPackageReference "CwlPreconditionTesting" */; + productName = CwlPosixPreconditionTesting; + }; + 89D8AC882B3211EA00410644 /* CwlPreconditionTesting */ = { + isa = XCSwiftPackageProductDependency; + package = 89D8AC822B3211A900410644 /* XCRemoteSwiftPackageReference "CwlPreconditionTesting" */; + productName = CwlPreconditionTesting; + }; +/* End XCSwiftPackageProductDependency section */ }; rootObject = 1F1A74201940169200FFFC47 /* Project object */; } diff --git a/Nimble.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Nimble.xcodeproj/project.xcworkspace/contents.xcworkspacedata index a822b747f..919434a62 100644 --- a/Nimble.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/Nimble.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:"> diff --git a/Nimble.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Nimble.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 000000000..bf75cf0a2 --- /dev/null +++ b/Nimble.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,23 @@ +{ + "pins" : [ + { + "identity" : "cwlcatchexception", + "kind" : "remoteSourceControl", + "location" : "https://github.com/mattgallagher/CwlCatchException", + "state" : { + "revision" : "3b123999de19bf04905bc1dfdb76f817b0f2cc00", + "version" : "2.1.2" + } + }, + { + "identity" : "cwlpreconditiontesting", + "kind" : "remoteSourceControl", + "location" : "https://github.com/mattgallagher/CwlPreconditionTesting", + "state" : { + "revision" : "dc9af4781f2afdd1e68e90f80b8603be73ea7abc", + "version" : "2.2.0" + } + } + ], + "version" : 2 +} diff --git a/Sources/Nimble/Nimble.h b/Sources/Nimble/Nimble.h index dc68ded76..eab5ea131 100644 --- a/Sources/Nimble/Nimble.h +++ b/Sources/Nimble/Nimble.h @@ -4,8 +4,8 @@ #import #if TARGET_OS_OSX || TARGET_OS_IOS - #import - #import + #import + #import #endif FOUNDATION_EXPORT double NimbleVersionNumber; From ee9c5dc9d8278764572c7d943f4bbc88ec6c1345 Mon Sep 17 00:00:00 2001 From: Rachel Brindle Date: Wed, 20 Dec 2023 07:34:30 -0800 Subject: [PATCH 2/6] Avoid checking in the carthage directory --- .gitignore | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index fb74b4411..c9b8a8462 100644 --- a/.gitignore +++ b/.gitignore @@ -12,16 +12,7 @@ Nimble.xcframework.zip # # Add this line if you want to avoid checking in source code from Carthage dependencies. # Carthage/Checkouts -Carthage/Checkouts/**/*.* -Carthage/Checkouts/**/Cart* -Carthage/Checkouts/**/Tests -!Carthage/Checkouts/**/LICENSE.* -!Carthage/Checkouts/**/*.md -!Carthage/Checkouts/**/*.swift -!Carthage/Checkouts/**/*.h -!Carthage/Checkouts/**/*.m -!Carthage/Checkouts/**/*.c -Carthage/Build +Carthage # Swift Package Manager # From 74ef47181b6103828a533dcbdc897d59bb8e7bf4 Mon Sep 17 00:00:00 2001 From: Rachel Brindle Date: Wed, 20 Dec 2023 08:15:14 -0800 Subject: [PATCH 3/6] Fix podspec lint errors --- Nimble.podspec | 7 ++++--- Sources/Nimble/Matchers/ThrowAssertion.swift | 2 +- Sources/Nimble/Nimble.h | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Nimble.podspec b/Nimble.podspec index 800bf72c8..727ec4fc4 100644 --- a/Nimble.podspec +++ b/Nimble.podspec @@ -34,9 +34,10 @@ Pod::Spec.new do |s| 'OTHER_SWIFT_FLAGS' => '$(inherited) -suppress-warnings', } - - s.dependency 'CwlPreconditionTesting', '~> 2.1.0' - s.dependency 'CwlCatchException', '~> 2.1.0' + [s.osx, s.ios].each do |platform| + platform.dependency 'CwlMachBadInstructionHandler', '~> 2.1.0' + platform.dependency 'CwlCatchException', '~> 2.1.0' + end s.cocoapods_version = '>= 1.4.0' if s.respond_to?(:swift_versions) then diff --git a/Sources/Nimble/Matchers/ThrowAssertion.swift b/Sources/Nimble/Matchers/ThrowAssertion.swift index b64a06211..e26c7267e 100644 --- a/Sources/Nimble/Matchers/ThrowAssertion.swift +++ b/Sources/Nimble/Matchers/ThrowAssertion.swift @@ -83,7 +83,7 @@ public func catchBadInstruction(block: @escaping () -> Void) -> BadInstructionEx public func throwAssertion() -> Matcher { return Matcher { actualExpression in - #if (arch(x86_64) || arch(arm64)) && (canImport(Darwin) || canImport(Glibc)) + #if (arch(x86_64) || arch(arm64)) && (canImport(CwlPreconditionTesting) || canImport(CwlPosixPreconditionTesting) || canImport(Glibc)) let message = ExpectationMessage.expectedTo("throw an assertion") var actualError: Error? let caughtException: BadInstructionException? = catchBadInstruction { diff --git a/Sources/Nimble/Nimble.h b/Sources/Nimble/Nimble.h index eab5ea131..32d349845 100644 --- a/Sources/Nimble/Nimble.h +++ b/Sources/Nimble/Nimble.h @@ -4,8 +4,8 @@ #import #if TARGET_OS_OSX || TARGET_OS_IOS - #import - #import + #import "CwlMachBadInstructionHandler.h" + #import "CwlCatchException.h" #endif FOUNDATION_EXPORT double NimbleVersionNumber; From e82c89c6739fbba936fab31c7a68c76b8feaa9e4 Mon Sep 17 00:00:00 2001 From: Rachel Brindle Date: Wed, 20 Dec 2023 08:26:00 -0800 Subject: [PATCH 4/6] Add specific error messaging when trying to use throwAssertion on watchOS/tvOS and cocoapods --- Sources/Nimble/Matchers/ThrowAssertion.swift | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Sources/Nimble/Matchers/ThrowAssertion.swift b/Sources/Nimble/Matchers/ThrowAssertion.swift index e26c7267e..d35295dcf 100644 --- a/Sources/Nimble/Matchers/ThrowAssertion.swift +++ b/Sources/Nimble/Matchers/ThrowAssertion.swift @@ -83,7 +83,8 @@ public func catchBadInstruction(block: @escaping () -> Void) -> BadInstructionEx public func throwAssertion() -> Matcher { return Matcher { actualExpression in - #if (arch(x86_64) || arch(arm64)) && (canImport(CwlPreconditionTesting) || canImport(CwlPosixPreconditionTesting) || canImport(Glibc)) + #if (arch(x86_64) || arch(arm64)) + #if (canImport(CwlPreconditionTesting) || canImport(CwlPosixPreconditionTesting) || canImport(Glibc)) let message = ExpectationMessage.expectedTo("throw an assertion") var actualError: Error? let caughtException: BadInstructionException? = catchBadInstruction { @@ -133,6 +134,14 @@ public func throwAssertion() -> Matcher { } else { return MatcherResult(bool: caughtException != nil, message: message) } + #else + let message = """ + The throwAssertion Nimble matcher does not support your platform. + Note: throwAssertion no longer works on tvOS or watchOS platforms when you pull in Nimble with Cocoapods. + You will have to use Nimble with Swift Package Manager or Carthage. + """ + fatalError(message) + #endif #else let message = """ The throwAssertion Nimble matcher can only run on x86_64 and arm64 platforms. From 8837d59ca5c31f672f740503f48ffa6ee0630951 Mon Sep 17 00:00:00 2001 From: Rachel Brindle Date: Wed, 20 Dec 2023 08:30:56 -0800 Subject: [PATCH 5/6] Add github action to verify that carthage still builds --- .github/workflows/carthage.yml | 23 ++++++++++++++++++++ Sources/Nimble/Matchers/ThrowAssertion.swift | 4 ++-- test | 11 +++++++++- 3 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/carthage.yml diff --git a/.github/workflows/carthage.yml b/.github/workflows/carthage.yml new file mode 100644 index 000000000..4087097d6 --- /dev/null +++ b/.github/workflows/carthage.yml @@ -0,0 +1,23 @@ +name: Carthage + +on: + push: + branches: + - main + tags: + - "*" + pull_request: + branches: + - "*" + +jobs: + carthage: + name: Carthage Build + runs-on: macos-12 + steps: + - uses: actions/checkout@v4 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.7 + bundler-cache: true + - run: ./test carthage diff --git a/Sources/Nimble/Matchers/ThrowAssertion.swift b/Sources/Nimble/Matchers/ThrowAssertion.swift index d35295dcf..79b2a4e96 100644 --- a/Sources/Nimble/Matchers/ThrowAssertion.swift +++ b/Sources/Nimble/Matchers/ThrowAssertion.swift @@ -137,8 +137,8 @@ public func throwAssertion() -> Matcher { #else let message = """ The throwAssertion Nimble matcher does not support your platform. - Note: throwAssertion no longer works on tvOS or watchOS platforms when you pull in Nimble with Cocoapods. - You will have to use Nimble with Swift Package Manager or Carthage. + Note: throwAssertion no longer works on tvOS or watchOS platforms when you use Nimble with Cocoapods. + You will have to use Nimble with Swift Package Manager or Carthage. """ fatalError(message) #endif diff --git a/test b/test index 1a40ebe4e..50e09733a 100755 --- a/test +++ b/test @@ -121,7 +121,14 @@ function test_podspec { run bundle exec pod --version echo "Linting podspec..." # Note: remove `--allow-warnings` once old Matcher API has been removed - run bundle exec pod lib lint Nimble.podspec --allow-warnings --skip-import-validation --verbose + run bundle exec pod lib lint Nimble.podspec +} + +function test_carthage { + echo "Gathering Carthage installation information..." + run carthage version + echo "Verifying that Carthage artifacts build" + run carthage build archive --use-xcframeworks } function test_swiftpm { @@ -184,6 +191,7 @@ function help { echo " watchos - Runs the tests as an watchOS device" echo " watchos_xcodespm - Runs the tests as an watchOS device using the Swift Package Manager version of Xcode" echo " podspec - Runs pod lib lint against the podspec to detect breaking changes" + echo " carthage - Runs verifyies that the carthage artifacts build" echo " swiftpm - Runs the tests built by the Swift Package Manager" echo " swiftpm_docker - Runs the tests built by the Swift Package Manager in a docker linux container" echo @@ -205,6 +213,7 @@ function main { macos) test_macos ;; macos_xcodespm) test_xcode_spm_macos ;; podspec) test_podspec ;; + carthage) test_carthage ;; test) test ;; all) test ;; swiftpm) test_swiftpm ;; From 7c8bd2965fa9673689410767eb765ac4b3e5836f Mon Sep 17 00:00:00 2001 From: Rachel Brindle Date: Wed, 20 Dec 2023 09:00:37 -0800 Subject: [PATCH 6/6] (re)add verbose logging to podspec and carthage tests --- test | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test b/test index 50e09733a..ed5a0cf03 100755 --- a/test +++ b/test @@ -120,15 +120,14 @@ function test_podspec { echo "Gathering CocoaPods installation information..." run bundle exec pod --version echo "Linting podspec..." - # Note: remove `--allow-warnings` once old Matcher API has been removed - run bundle exec pod lib lint Nimble.podspec + run bundle exec pod lib lint Nimble.podspec --skip-import-validation --verbose } function test_carthage { echo "Gathering Carthage installation information..." run carthage version echo "Verifying that Carthage artifacts build" - run carthage build archive --use-xcframeworks + run carthage build archive --use-xcframeworks --verbose } function test_swiftpm {