From fc3cd1adf6961a3541679342d64fbbfd7a9f4ca7 Mon Sep 17 00:00:00 2001 From: Sho Ikeda Date: Sat, 14 Sep 2019 16:27:18 +0900 Subject: [PATCH] Update CwlPreconditionTesting to 2.0.0-beta.1 --- Cartfile.private | 3 +- Cartfile.resolved | 3 +- .../CwlCatchException/LICENSE.txt | 0 .../CwlCatchException/Package.swift | 2 +- .../Checkouts/CwlCatchException/README.md | 18 ++++++ .../CwlCatchException/CwlCatchException.swift | 0 .../CwlCatchException.m | 0 .../include/CwlCatchException.h | 6 -- .../Dependencies/CwlCatchException/README.md | 46 --------------- .../CwlPreconditionTesting/Package.swift | 17 +++--- .../CwlPreconditionTesting/README.md | 58 ++++++++----------- .../CwlCatchBadInstructionPosix.swift | 2 +- .../include/CwlPreconditionTesting.h | 35 ----------- Nimble.podspec | 13 ++--- Nimble.xcodeproj/project.pbxproj | 26 ++++----- Package.resolved | 8 +-- Package.swift | 4 +- Sources/Nimble/Matchers/ThrowAssertion.swift | 4 +- Sources/Nimble/Nimble.h | 5 +- 19 files changed, 84 insertions(+), 166 deletions(-) rename Carthage/Checkouts/{CwlPreconditionTesting/Dependencies => }/CwlCatchException/LICENSE.txt (100%) rename Carthage/Checkouts/{CwlPreconditionTesting/Dependencies => }/CwlCatchException/Package.swift (94%) create mode 100644 Carthage/Checkouts/CwlCatchException/README.md rename Carthage/Checkouts/{CwlPreconditionTesting/Dependencies => }/CwlCatchException/Sources/CwlCatchException/CwlCatchException.swift (100%) rename Carthage/Checkouts/{CwlPreconditionTesting/Dependencies => }/CwlCatchException/Sources/CwlCatchExceptionSupport/CwlCatchException.m (100%) rename Carthage/Checkouts/{CwlPreconditionTesting/Dependencies => }/CwlCatchException/Sources/CwlCatchExceptionSupport/include/CwlCatchException.h (82%) delete mode 100644 Carthage/Checkouts/CwlPreconditionTesting/Dependencies/CwlCatchException/README.md rename Carthage/Checkouts/CwlPreconditionTesting/Sources/{CwlPreconditionTesting => CwlPosixPreconditionTesting}/CwlCatchBadInstructionPosix.swift (99%) delete mode 100644 Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/include/CwlPreconditionTesting.h diff --git a/Cartfile.private b/Cartfile.private index b5ed77ee1..479fdf892 100644 --- a/Cartfile.private +++ b/Cartfile.private @@ -1 +1,2 @@ -github "mattgallagher/CwlPreconditionTesting" == 1.2.0 +github "mattgallagher/CwlCatchException" == 2.0.0-beta.1 +github "mattgallagher/CwlPreconditionTesting" == 2.0.0-beta.1 diff --git a/Cartfile.resolved b/Cartfile.resolved index fbe69497d..3e4ee34e7 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1 +1,2 @@ -github "mattgallagher/CwlPreconditionTesting" "1.2.0" +github "mattgallagher/CwlCatchException" "2.0.0-beta.1" +github "mattgallagher/CwlPreconditionTesting" "2.0.0-beta.1" diff --git a/Carthage/Checkouts/CwlPreconditionTesting/Dependencies/CwlCatchException/LICENSE.txt b/Carthage/Checkouts/CwlCatchException/LICENSE.txt similarity index 100% rename from Carthage/Checkouts/CwlPreconditionTesting/Dependencies/CwlCatchException/LICENSE.txt rename to Carthage/Checkouts/CwlCatchException/LICENSE.txt diff --git a/Carthage/Checkouts/CwlPreconditionTesting/Dependencies/CwlCatchException/Package.swift b/Carthage/Checkouts/CwlCatchException/Package.swift similarity index 94% rename from Carthage/Checkouts/CwlPreconditionTesting/Dependencies/CwlCatchException/Package.swift rename to Carthage/Checkouts/CwlCatchException/Package.swift index 33689a22c..acee3952a 100644 --- a/Carthage/Checkouts/CwlPreconditionTesting/Dependencies/CwlCatchException/Package.swift +++ b/Carthage/Checkouts/CwlCatchException/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:4.2 +// swift-tools-version:5.0 import PackageDescription let package = Package( diff --git a/Carthage/Checkouts/CwlCatchException/README.md b/Carthage/Checkouts/CwlCatchException/README.md new file mode 100644 index 000000000..1e8a6ec56 --- /dev/null +++ b/Carthage/Checkouts/CwlCatchException/README.md @@ -0,0 +1,18 @@ +# 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/CwlPreconditionTesting/Dependencies/CwlCatchException/Sources/CwlCatchException/CwlCatchException.swift b/Carthage/Checkouts/CwlCatchException/Sources/CwlCatchException/CwlCatchException.swift similarity index 100% rename from Carthage/Checkouts/CwlPreconditionTesting/Dependencies/CwlCatchException/Sources/CwlCatchException/CwlCatchException.swift rename to Carthage/Checkouts/CwlCatchException/Sources/CwlCatchException/CwlCatchException.swift diff --git a/Carthage/Checkouts/CwlPreconditionTesting/Dependencies/CwlCatchException/Sources/CwlCatchExceptionSupport/CwlCatchException.m b/Carthage/Checkouts/CwlCatchException/Sources/CwlCatchExceptionSupport/CwlCatchException.m similarity index 100% rename from Carthage/Checkouts/CwlPreconditionTesting/Dependencies/CwlCatchException/Sources/CwlCatchExceptionSupport/CwlCatchException.m rename to Carthage/Checkouts/CwlCatchException/Sources/CwlCatchExceptionSupport/CwlCatchException.m diff --git a/Carthage/Checkouts/CwlPreconditionTesting/Dependencies/CwlCatchException/Sources/CwlCatchExceptionSupport/include/CwlCatchException.h b/Carthage/Checkouts/CwlCatchException/Sources/CwlCatchExceptionSupport/include/CwlCatchException.h similarity index 82% rename from Carthage/Checkouts/CwlPreconditionTesting/Dependencies/CwlCatchException/Sources/CwlCatchExceptionSupport/include/CwlCatchException.h rename to Carthage/Checkouts/CwlCatchException/Sources/CwlCatchExceptionSupport/include/CwlCatchException.h index 47b06bf2b..eb42378f5 100644 --- a/Carthage/Checkouts/CwlPreconditionTesting/Dependencies/CwlCatchException/Sources/CwlCatchExceptionSupport/include/CwlCatchException.h +++ b/Carthage/Checkouts/CwlCatchException/Sources/CwlCatchExceptionSupport/include/CwlCatchException.h @@ -20,10 +20,4 @@ #import -//! Project version number for CwlCatchException. -FOUNDATION_EXPORT double CwlCatchExceptionVersionNumber; - -//! Project version string for CwlCatchException. -FOUNDATION_EXPORT const unsigned char CwlCatchExceptionVersionString[]; - NSException* __nullable catchExceptionOfKind(Class __nonnull type, void (^ __nonnull inBlock)(void)); diff --git a/Carthage/Checkouts/CwlPreconditionTesting/Dependencies/CwlCatchException/README.md b/Carthage/Checkouts/CwlPreconditionTesting/Dependencies/CwlCatchException/README.md deleted file mode 100644 index 052d7c0e2..000000000 --- a/Carthage/Checkouts/CwlPreconditionTesting/Dependencies/CwlCatchException/README.md +++ /dev/null @@ -1,46 +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. - -## Adding to your project - -This project can be used by direct inclusion in your projects or through any of the Swift Package Manager, CocoaPods or Carthage. - -Minimum requirements are iOS 8 or macOS 10.9. - -### Manual inclusion - -1. In a subdirectory of your project's directory, run `git clone https://github.com/mattgallagher/CwlCatchException.git` -2. Drag the "CwlCatchException.xcodeproj" file from the Finder into your own project's file tree in Xcode -3. Add the "CwlCatchException.framework" from the "Products" folder of the CwlCatchException project's file tree to the "Copy Files (Frameworks)" build phases of any target that you want to include this module. - -That third step is a little tricky if you're unfamiliar with Xcode but it involves: - -a. click on your project in the file tree -b. click on the target to whih you want to add this module -c. select the "Build Phases" tab -d. if you don't already have a "Copy File" build phase with a "Destination: Frameworks", add one using the "+" button in the top left of the tab -e. click the "+" within the "Copy File (Frameworks)" phase and from the list that appears, select the "CwlCatchException.framework" (if there are multiple frameworks with the same name, look for the one that appears *above* the corresponding macOS or iOS CwlCatchException testing target). - -### Swift Package Manager - -Add the following to the `dependencies` array in your "Package.swift" file: - - .Package(url: "https://github.com/mattgallagher/CwlCatchException.git", majorVersion: 1), - -Or, if you're using the `swift-tools-version:4.0` package manager, add the following to the `dependencies` array in your "Package.swift" file: - - .package(url: "https://github.com/mattgallagher/CwlCatchException.git", majorVersion: 1) - -### CocoaPods - -Add the following to your target in your "Podfile": - - pod 'CwlCatchException', :git => 'https://github.com/mattgallagher/CwlCatchException.git' - -### Carthage - -Add the following line to your Cartfile: - - git "https://github.com/mattgallagher/CwlCatchException.git" "master" diff --git a/Carthage/Checkouts/CwlPreconditionTesting/Package.swift b/Carthage/Checkouts/CwlPreconditionTesting/Package.swift index 12b0c068d..09175fae6 100644 --- a/Carthage/Checkouts/CwlPreconditionTesting/Package.swift +++ b/Carthage/Checkouts/CwlPreconditionTesting/Package.swift @@ -1,13 +1,14 @@ -// swift-tools-version:4.0 +// swift-tools-version:5.0 import PackageDescription let package = Package( name: "CwlPreconditionTesting", products: [ - .library(name: "CwlPreconditionTesting", targets: ["CwlPreconditionTesting", "CwlMachBadInstructionHandler"]) + .library(name: "CwlPreconditionTesting", targets: ["CwlPreconditionTesting", "CwlMachBadInstructionHandler"]), + .library(name: "CwlPosixPreconditionTesting", targets: ["CwlPosixPreconditionTesting"]) ], dependencies: [ - .package(url: "https://github.com/mattgallagher/CwlCatchException.git", from: "1.2.0") + .package(url: "https://github.com/mattgallagher/CwlCatchException.git", from: Version(2, 0, 0, prereleaseIdentifiers: ["-beta.1"])) ], targets: [ .target( @@ -15,14 +16,12 @@ let package = Package( dependencies: [ .target(name: "CwlMachBadInstructionHandler"), .product(name: "CwlCatchException") - ], - exclude: [ - "./Mach/CwlPreconditionTesting.h", - "./Posix/CwlPreconditionTesting.h", - "./CwlCatchBadInstructionPosix.swift" ] ), + .target( + name: "CwlPosixPreconditionTesting" + ), .target(name: "CwlMachBadInstructionHandler"), - .testTarget(name: "CwlPreconditionTestingTests", dependencies: ["CwlPreconditionTesting"]) + .testTarget(name: "CwlPreconditionTestingTests", dependencies: ["CwlPreconditionTesting", "CwlPosixPreconditionTesting"]) ] ) diff --git a/Carthage/Checkouts/CwlPreconditionTesting/README.md b/Carthage/Checkouts/CwlPreconditionTesting/README.md index 259d1fe9c..9af31c79e 100644 --- a/Carthage/Checkouts/CwlPreconditionTesting/README.md +++ b/Carthage/Checkouts/CwlPreconditionTesting/README.md @@ -8,52 +8,40 @@ 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) -## Adding to your project - -This project can be used by manual inclusion in your projects or through any of the Swift Package Manager, CocoaPods or Carthage. - -Minimum requirements are iOS 8 (simulator-only) or macOS 10.9. The project includes tvOS 9 and POSIX targets but these aren't regularly tested. - -### Manual inclusion - -1. In a subdirectory of your project's directory, run `git clone https://github.com/mattgallagher/CwlPreconditionTesting.git` -2. Drag the "CwlPreconditionTesting.xcodeproj" file from the Finder into your own project's file tree in Xcode -3. Add the "CwlPreconditionTesting.framework" from the "Products" folder of the CwlPreconditionTesting project's file tree to the "Copy Files (Frameworks)" build phases of any targets that you want to include this module. -4. Drag the "CwlCatchException.framework" from the "Dependencies" group (within the CwlPreconditionTesting project's file tree) onto the same "Copy Files (Frameworks)" build phase +## Requirements -### Swift Package Manager +From version 2.0.0-beta.1, building CwlPreconditionTesting requires Swift 5 or newer and the Swift Package Manager. -Assuming you're using the `swift-tools-version:4.0` package manager, add the following to the `dependencies` array in your "Package.swift" file: +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). - .package(url: "https://github.com/mattgallagher/CwlPreconditionTesting.git", majorVersion: 1) - -> NOTE: even though this git repository includes its dependencies in the Dependencies folder, building via the Swift Package manager fetches and builds these dependencies independently. - -### CocoaPods - -Add the following lines to your target in your "Podfile": +## Adding to your project - pod 'CwlPreconditionTesting', :git => 'https://github.com/mattgallagher/CwlPreconditionTesting.git' - pod 'CwlCatchException', :git => 'https://github.com/mattgallagher/CwlCatchException.git' +Add the following to the `dependencies` array in your "Package.swift" file: -### Carthage + .package(url: "https://github.com/mattgallagher/CwlPreconditionTesting.git", from: Version("2.0.0-beta.1")) -Add the following line to your Cartfile: +Or by adding `https://github.com/mattgallagher/CwlPreconditionTesting.git`, version 2.0.0-beta.1 or later, to the list of Swift packages for any project in Xcode. - git "https://github.com/mattgallagher/CwlPreconditionTesting.git" "master" +## Usage -## Using POSIX signals and setjmp/longjmp +On macOS and iOS you can use the regular version: -For comparison or for anyone running this code on a platform without Mach exceptions or the Objective-C runtime, I've added a proof-of-concept implementation of `catchBadInstruction` that uses a POSIX SIGILL `sigaction` and `setjmp`/`longjmp` to perform the throw. +```swift +import CwlPreconditionTesting -In Xcode, you can simply select the CwlPreconditionTesting_POSIX target (instead of the OSX or iOS targets). If you're building without Xcode: all you need is the CwlCatchBadInstructionPOSIX.swift file (compared to the Mach exception handler, the code is tiny doesn't have any weird Objective-C/MiG file dependencies). +let e = catchBadInstruction { + precondition(false, "THIS PRECONDITION FAILURE IS EXPECTED") +} +``` -**Warning No. 1**: on OS X, this approach can't be used when lldb is attached since lldb's Mach exception handler blocks the SIGILL from ever occurring (I've disabled the "Debug Executable" setting for the tests in Xcode - re-enable it to witness the problem). +on tvOS, Linux and other platforms, you can use the POSIX version: -**Warning No. 2**: if you're switching between the CwlPreconditionTesting_OSX and CwlPreconditionTesting_POSIX targets, Xcode (as of Xcode 7.2.1) will not detect the change and will not remove the old framework correctly so you'll need to *clean your project* otherwise the old framework will hang around. +```swift +import CwlPosixPreconditionTesting -Additional problems in decreasing severity include: +let e = catchBadInstruction { + precondition(false, "THIS PRECONDITION FAILURE IS EXPECTED") +} +``` -* the signal handler is whole process (rather than correctly scoped to the thread where the "catch" occurs) -* the signal handler doesn't deal with re-entrancy whereas the mach exception handler remains deterministic in the face of multiple fatal errors -* the signal handler overwrites the "[red zone](https://en.wikipedia.org/wiki/Red_zone_(computing))" which is technically frowned upon in signal handlers (although unlikely to cause problems here) +**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). diff --git a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlCatchBadInstructionPosix.swift b/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPosixPreconditionTesting/CwlCatchBadInstructionPosix.swift similarity index 99% rename from Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlCatchBadInstructionPosix.swift rename to Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPosixPreconditionTesting/CwlCatchBadInstructionPosix.swift index 4fc99faad..d9f4b8b26 100644 --- a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlCatchBadInstructionPosix.swift +++ b/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPosixPreconditionTesting/CwlCatchBadInstructionPosix.swift @@ -18,7 +18,7 @@ // IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // -#if os(tvOS) && targetEnvironment(simulator) +#if arch(x86_64) import Foundation diff --git a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/include/CwlPreconditionTesting.h b/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/include/CwlPreconditionTesting.h deleted file mode 100644 index 93a0e610c..000000000 --- a/Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/include/CwlPreconditionTesting.h +++ /dev/null @@ -1,35 +0,0 @@ -// -// CwlPreconditionTesting.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 - -//! Project version number for CwlUtils. -FOUNDATION_EXPORT double CwlPreconditionTestingVersionNumber; - -//! Project version string for CwlUtils. -FOUNDATION_EXPORT const unsigned char CwlAssertingTestingVersionString[]; - -#import "CwlMachBadInstructionHandler.h" - -#if TARGET_OS_OSX || TARGET_OS_IOS - #import "CwlCatchException.h" -#elif !TARGET_OS_TV - #error Unsupported platform. -#endif diff --git a/Nimble.podspec b/Nimble.podspec index ccd63dfc5..6f04243ce 100644 --- a/Nimble.podspec +++ b/Nimble.podspec @@ -16,24 +16,23 @@ Pod::Spec.new do |s| s.source_files = [ "Sources/**/*.{swift,h,m,c}", - "Carthage/Checkouts/CwlPreconditionTesting/Dependencies/CwlCatchException/Sources/**/*.{swift,h,m,c}", + "Carthage/Checkouts/CwlCatchException/Sources/**/*.{swift,h,m,c}", "Carthage/Checkouts/CwlPreconditionTesting/Sources/**/*.{swift,h,m,c}", ] s.osx.exclude_files = [ - "Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlCatchBadInstructionPosix.swift", + "Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPosixPreconditionTesting/CwlCatchBadInstructionPosix.swift", ] s.ios.exclude_files = [ - "Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlCatchBadInstructionPosix.swift", + "Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPosixPreconditionTesting/CwlCatchBadInstructionPosix.swift", ] s.tvos.exclude_files = [ - "Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/Mach/CwlPreconditionTesting.h", "Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlCatchBadInstruction.swift", "Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlBadInstructionException.swift", "Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlDarwinDefinitions.swift", - "Carthage/Checkouts/CwlPreconditionTesting/Dependencies/CwlCatchException/Sources/CwlCatchException/CwlCatchException.swift", - "Carthage/Checkouts/CwlPreconditionTesting/Dependencies/CwlCatchException/Sources/CwlCatchExceptionSupport/CwlCatchException.m", - "Carthage/Checkouts/CwlPreconditionTesting/Dependencies/CwlCatchException/Sources/CwlCatchExceptionSupport/include/CwlCatchException.h", + "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" diff --git a/Nimble.xcodeproj/project.pbxproj b/Nimble.xcodeproj/project.pbxproj index dad271f6b..68a90e368 100644 --- a/Nimble.xcodeproj/project.pbxproj +++ b/Nimble.xcodeproj/project.pbxproj @@ -351,6 +351,8 @@ B20058C620E92CE400C1264D /* ElementsEqualTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = B20058C420E92CE400C1264D /* ElementsEqualTest.swift */; }; B20058C720E92CE400C1264D /* ElementsEqualTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = B20058C420E92CE400C1264D /* ElementsEqualTest.swift */; }; CD037213207DCC580047AF28 /* XCTestManifests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD037212207DCC580047AF28 /* XCTestManifests.swift */; }; + CD3D9A79232647BC00802581 /* CwlCatchBadInstructionPosix.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD3D9A78232647BC00802581 /* CwlCatchBadInstructionPosix.swift */; }; + CD3D9A7A232648E600802581 /* CwlCatchException.h in Headers */ = {isa = PBXBuildFile; fileRef = CDFB6A221F7E07C600AD8CC7 /* CwlCatchException.h */; settings = {ATTRIBUTES = (Public, ); }; }; CD79C99E1D2CC832004B6F9A /* ObjCAsyncTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F4A56651A3B305F009E1637 /* ObjCAsyncTest.m */; }; CD79C99F1D2CC835004B6F9A /* ObjCSyncTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F8A37AF1B7C5042001C8357 /* ObjCSyncTest.m */; }; CD79C9A01D2CC839004B6F9A /* ObjCBeAnInstanceOfTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F4A56691A3B3108009E1637 /* ObjCBeAnInstanceOfTest.m */; }; @@ -377,9 +379,6 @@ CD79C9B51D2CC848004B6F9A /* ObjCUserDescriptionTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 965B0D081B62B8ED0005AE66 /* ObjCUserDescriptionTest.m */; }; CD79C9B61D2CC848004B6F9A /* ObjCAllPassTest.m in Sources */ = {isa = PBXBuildFile; fileRef = DDEFAEB31A93CBE6005CA37A /* ObjCAllPassTest.m */; }; CD79C9B71D2CC848004B6F9A /* ObjCSatisfyAnyOfTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B5358C11C39155600A23FAA /* ObjCSatisfyAnyOfTest.m */; }; - CD8D21BD2322BFC300C3996F /* CwlPreconditionTesting.h in Headers */ = {isa = PBXBuildFile; fileRef = CD8D21BC2322BFC300C3996F /* CwlPreconditionTesting.h */; settings = {ATTRIBUTES = (Public, ); }; }; - CD8D21BE2322BFC300C3996F /* CwlPreconditionTesting.h in Headers */ = {isa = PBXBuildFile; fileRef = CD8D21BC2322BFC300C3996F /* CwlPreconditionTesting.h */; settings = {ATTRIBUTES = (Public, ); }; }; - CD8D21BF2322BFC300C3996F /* CwlPreconditionTesting.h in Headers */ = {isa = PBXBuildFile; fileRef = CD8D21BC2322BFC300C3996F /* CwlPreconditionTesting.h */; settings = {ATTRIBUTES = (Public, ); }; }; CDD80B831F2030790002CD65 /* MatcherProtocols.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FD8CD1D1968AB07008ED995 /* MatcherProtocols.swift */; }; CDD80B841F20307A0002CD65 /* MatcherProtocols.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FD8CD1D1968AB07008ED995 /* MatcherProtocols.swift */; }; CDD80B851F20307B0002CD65 /* MatcherProtocols.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FD8CD1D1968AB07008ED995 /* MatcherProtocols.swift */; }; @@ -403,7 +402,6 @@ CDFB6A4C1F7E082500AD8CC7 /* mach_excServer.c in Sources */ = {isa = PBXBuildFile; fileRef = CDFB6A371F7E082400AD8CC7 /* mach_excServer.c */; }; CDFB6A4F1F7E084600AD8CC7 /* CwlMachBadInstructionHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = CDFB6A341F7E082400AD8CC7 /* CwlMachBadInstructionHandler.m */; }; CDFB6A501F7E085600AD8CC7 /* CwlMachBadInstructionHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = CDFB6A361F7E082400AD8CC7 /* CwlMachBadInstructionHandler.h */; settings = {ATTRIBUTES = (Public, ); }; }; - CDFB6A511F7E087500AD8CC7 /* CwlCatchBadInstructionPosix.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDFB6A2C1F7E082400AD8CC7 /* CwlCatchBadInstructionPosix.swift */; }; DA9E8C821A414BB9002633C2 /* DSL+Wait.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA9E8C811A414BB9002633C2 /* DSL+Wait.swift */; }; DA9E8C831A414BB9002633C2 /* DSL+Wait.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA9E8C811A414BB9002633C2 /* DSL+Wait.swift */; }; DD72EC641A93874A002F7651 /* AllPassTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD72EC631A93874A002F7651 /* AllPassTest.swift */; }; @@ -618,13 +616,12 @@ B20058C020E92C7500C1264D /* ElementsEqual.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ElementsEqual.swift; sourceTree = ""; }; B20058C420E92CE400C1264D /* ElementsEqualTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ElementsEqualTest.swift; sourceTree = ""; }; CD037212207DCC580047AF28 /* XCTestManifests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XCTestManifests.swift; sourceTree = ""; }; - CD8D21BC2322BFC300C3996F /* CwlPreconditionTesting.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CwlPreconditionTesting.h; sourceTree = ""; }; + CD3D9A78232647BC00802581 /* CwlCatchBadInstructionPosix.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CwlCatchBadInstructionPosix.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 = ""; }; - CDFB6A2C1F7E082400AD8CC7 /* CwlCatchBadInstructionPosix.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CwlCatchBadInstructionPosix.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 = ""; }; @@ -934,12 +931,12 @@ path = objc; sourceTree = ""; }; - CD8D21BB2322BFC300C3996F /* include */ = { + CD3D9A77232647BC00802581 /* CwlPosixPreconditionTesting */ = { isa = PBXGroup; children = ( - CD8D21BC2322BFC300C3996F /* CwlPreconditionTesting.h */, + CD3D9A78232647BC00802581 /* CwlCatchBadInstructionPosix.swift */, ); - path = include; + path = CwlPosixPreconditionTesting; sourceTree = ""; }; CDFB69521F7E06E600AD8CC7 /* Carthage-Checkouts */ = { @@ -959,7 +956,7 @@ CDFB6A1F1F7E07C600AD8CC7 /* CwlCatchExceptionSupport */, ); name = CwlCatchException; - path = CwlPreconditionTesting/Dependencies/CwlCatchException/Sources; + path = CwlCatchException/Sources; sourceTree = ""; }; CDFB69741F7E076F00AD8CC7 /* CwlPreconditionTesting */ = { @@ -967,6 +964,7 @@ children = ( CDFB6A331F7E082400AD8CC7 /* CwlMachBadInstructionHandler */, CDFB6A291F7E082400AD8CC7 /* CwlPreconditionTesting */, + CD3D9A77232647BC00802581 /* CwlPosixPreconditionTesting */, ); name = CwlPreconditionTesting; path = CwlPreconditionTesting/Sources; @@ -1000,10 +998,8 @@ CDFB6A291F7E082400AD8CC7 /* CwlPreconditionTesting */ = { isa = PBXGroup; children = ( - CD8D21BB2322BFC300C3996F /* include */, CDFB6A2A1F7E082400AD8CC7 /* CwlBadInstructionException.swift */, CDFB6A2B1F7E082400AD8CC7 /* CwlCatchBadInstruction.swift */, - CDFB6A2C1F7E082400AD8CC7 /* CwlCatchBadInstructionPosix.swift */, CDFB6A2D1F7E082400AD8CC7 /* CwlDarwinDefinitions.swift */, ); path = CwlPreconditionTesting; @@ -1035,7 +1031,6 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - CD8D21BE2322BFC300C3996F /* CwlPreconditionTesting.h in Headers */, CDFB6A4A1F7E082500AD8CC7 /* CwlMachBadInstructionHandler.h in Headers */, CDFB6A281F7E07C700AD8CC7 /* CwlCatchException.h in Headers */, 1F1871C91CA89EDB00A34BF2 /* NMBStringify.h in Headers */, @@ -1050,7 +1045,7 @@ buildActionMask = 2147483647; files = ( 1F1871E21CA89EF600A34BF2 /* NMBStringify.h in Headers */, - CD8D21BF2322BFC300C3996F /* CwlPreconditionTesting.h in Headers */, + CD3D9A7A232648E600802581 /* CwlCatchException.h in Headers */, 1F1871E01CA89EF600A34BF2 /* DSL.h in Headers */, 1F1871E11CA89EF600A34BF2 /* NMBExceptionCapture.h in Headers */, CDFB6A501F7E085600AD8CC7 /* CwlMachBadInstructionHandler.h in Headers */, @@ -1062,7 +1057,6 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - CD8D21BD2322BFC300C3996F /* CwlPreconditionTesting.h in Headers */, CDFB6A491F7E082500AD8CC7 /* CwlMachBadInstructionHandler.h in Headers */, CDFB6A271F7E07C700AD8CC7 /* CwlCatchException.h in Headers */, 1F1871DF1CA89EF500A34BF2 /* NMBStringify.h in Headers */, @@ -1469,6 +1463,7 @@ 7A6AB2C61E7F628A00A2F694 /* ToSucceed.swift in Sources */, 1F5DF1751BDCA0F500C3A531 /* FailureMessage.swift in Sources */, A8A3B6EC2071487F00E25A08 /* SatisfyAllOf.swift in Sources */, + CD3D9A79232647BC00802581 /* CwlCatchBadInstructionPosix.swift in Sources */, 1F5DF1801BDCA0F500C3A531 /* BeLessThanOrEqual.swift in Sources */, 1F1871E81CA8A18400A34BF2 /* Async.swift in Sources */, 1F5DF18A1BDCA0F500C3A531 /* ThrowError.swift in Sources */, @@ -1503,7 +1498,6 @@ 1F5DF17E1BDCA0F500C3A531 /* BeIdenticalTo.swift in Sources */, 1F1871E91CA8A18700A34BF2 /* MatcherFunc.swift in Sources */, 1F5DF17A1BDCA0F500C3A531 /* BeEmpty.swift in Sources */, - CDFB6A511F7E087500AD8CC7 /* CwlCatchBadInstructionPosix.swift in Sources */, 1F5DF18C1BDCA0F500C3A531 /* Await.swift in Sources */, 1F1871D81CA89EEF00A34BF2 /* NMBStringify.m in Sources */, 1F5DF1821BDCA0F500C3A531 /* BeNil.swift in Sources */, diff --git a/Package.resolved b/Package.resolved index c024deb33..c6d87fe25 100644 --- a/Package.resolved +++ b/Package.resolved @@ -6,8 +6,8 @@ "repositoryURL": "https://github.com/mattgallagher/CwlCatchException.git", "state": { "branch": null, - "revision": "7cd2f8cacc4d22f21bc0b2309c3b18acf7957b66", - "version": "1.2.0" + "revision": "f809deb30dc5c9d9b78c872e553261a61177721a", + "version": "2.0.0-beta.1" } }, { @@ -15,8 +15,8 @@ "repositoryURL": "https://github.com/mattgallagher/CwlPreconditionTesting.git", "state": { "branch": null, - "revision": "c228db5d2ad1b01ebc84435e823e6cca4e3db98b", - "version": "1.2.0" + "revision": "ea422878db4e680069af320ac444183628360ab1", + "version": "2.0.0-beta.1" } } ] diff --git a/Package.swift b/Package.swift index 6e57cb8d4..b0795146d 100644 --- a/Package.swift +++ b/Package.swift @@ -10,14 +10,14 @@ let package = Package( .library(name: "Nimble", targets: ["Nimble"]), ], dependencies: [ - .package(url: "https://github.com/mattgallagher/CwlPreconditionTesting.git", .exact("1.2.0")), + .package(url: "https://github.com/mattgallagher/CwlPreconditionTesting.git", .exact("2.0.0-beta.1")), ], targets: [ .target( name: "Nimble", dependencies: { #if os(macOS) - return ["CwlPreconditionTesting"] + return ["CwlPreconditionTesting", "CwlPosixPreconditionTesting"] #else return [] #endif diff --git a/Sources/Nimble/Matchers/ThrowAssertion.swift b/Sources/Nimble/Matchers/ThrowAssertion.swift index e20f9eabe..5bb790a96 100644 --- a/Sources/Nimble/Matchers/ThrowAssertion.swift +++ b/Sources/Nimble/Matchers/ThrowAssertion.swift @@ -1,7 +1,9 @@ import Foundation -#if canImport(CwlPreconditionTesting) +#if canImport(CwlPreconditionTesting) && (os(macOS) || os(iOS)) import CwlPreconditionTesting +#elseif canImport(CwlPosixPreconditionTesting) +import CwlPosixPreconditionTesting #endif public func throwAssertion() -> Predicate { diff --git a/Sources/Nimble/Nimble.h b/Sources/Nimble/Nimble.h index bd45c5dde..93301e1fd 100644 --- a/Sources/Nimble/Nimble.h +++ b/Sources/Nimble/Nimble.h @@ -3,7 +3,10 @@ #import "NMBStringify.h" #import "DSL.h" -#import "CwlPreconditionTesting.h" +#import "CwlMachBadInstructionHandler.h" +#if TARGET_OS_OSX || TARGET_OS_IOS + #import "CwlCatchException.h" +#endif FOUNDATION_EXPORT double NimbleVersionNumber; FOUNDATION_EXPORT const unsigned char NimbleVersionString[];