Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci-xcode.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,6 +25,7 @@ jobs:
- run: ./test macos
- run: ./test ios
- run: ./test tvos
- run: ./test watchos

xcode_spm:
name: Xcode ${{ matrix.xcode }} (Swift Package)
Expand All@@ -40,3 +41,4 @@ jobs:
- run: ./test macos_xcodespm
- run: ./test ios_xcodespm
- run: ./test tvos_xcodespm
- run: ./test watchos_xcodespm
10 changes: 10 additions & 0 deletions Nimble.podspec
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,6 +11,7 @@ Pod::Spec.new do |s|
s.ios.deployment_target = "9.0"
s.osx.deployment_target = "10.10"
s.tvos.deployment_target = "9.0"
s.watchos.deployment_target = "5.0"
s.source = { :git => "https://github.com/Quick/Nimble.git",
:tag => "v#{s.version}" }

Expand All@@ -37,6 +38,15 @@ Pod::Spec.new do |s|
"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"
Expand Down
496 changes: 495 additions & 1 deletion Nimble.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

77 changes: 77 additions & 0 deletions Nimble.xcodeproj/xcshareddata/xcschemes/Nimble-watchOS.xcscheme
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1250"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D95F890B267EA13E004B1B4D"
BuildableName = "Nimble.framework"
BlueprintName = "Nimble-watchOS"
ReferencedContainer = "container:Nimble.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = ""
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D95F8913267EA13E004B1B4D"
BuildableName = "NimbleTests.xctest"
BlueprintName = "Nimble-watchOSTests"
ReferencedContainer = "container:Nimble.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D95F890B267EA13E004B1B4D"
BuildableName = "Nimble.framework"
BlueprintName = "Nimble-watchOS"
ReferencedContainer = "container:Nimble.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
4 changes: 2 additions & 2 deletions Package.swift
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ import PackageDescription
let package = Package(
name: "Nimble",
platforms: [
.macOS(.v10_10), .iOS(.v9), .tvOS(.v9)
.macOS(.v10_10), .iOS(.v9), .tvOS(.v9), .watchOS(.v5)
],
products: [
.library(name: "Nimble", targets: ["Nimble"]),
Expand All@@ -19,7 +19,7 @@ let package = Package(
.product(name: "CwlPreconditionTesting", package: "CwlPreconditionTesting",
condition: .when(platforms: [.macOS, .iOS])),
.product(name: "CwlPosixPreconditionTesting", package: "CwlPreconditionTesting",
condition: .when(platforms: [.tvOS]))
condition: .when(platforms: [.tvOS, .watchOS]))
],
exclude: ["Info.plist"]
),
Expand Down
1 change: 1 addition & 0 deletions Sources/Nimble/Adapters/NimbleEnvironment.swift
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,6 +35,7 @@ internal class NimbleEnvironment: NSObject {
}

var suppressTVOSAssertionWarning: Bool = false
var suppressWatchOSAssertionWarning: Bool = false
#if !os(WASI)
var awaiter: Awaiter
#endif
Expand Down
19 changes: 16 additions & 3 deletions Sources/Nimble/Matchers/ThrowAssertion.swift
Original file line numberDiff line numberDiff line change
Expand Up@@ -84,9 +84,7 @@ public func catchBadInstruction(block: @escaping () -> Void) -> BadInstructionEx

public func throwAssertion<Out>() -> Predicate<Out> {
return Predicate { actualExpression in
#if os(watchOS)
fatalError("Nimble currently doesn't support watchOS.")
#elseif (arch(x86_64) || arch(arm64)) && (canImport(Darwin) || canImport(Glibc))
#if (arch(x86_64) || arch(arm64)) && (canImport(Darwin) || canImport(Glibc))
let message = ExpectationMessage.expectedTo("throw an assertion")
var actualError: Error?
let caughtException: BadInstructionException? = catchBadInstruction {
Expand All@@ -105,6 +103,21 @@ public func throwAssertion<Out>() -> Predicate<Out> {
print()
NimbleEnvironment.activeInstance.suppressTVOSAssertionWarning = true
}
#elseif os(watchOS)
if !NimbleEnvironment.activeInstance.suppressWatchOSAssertionWarning {
print()
print("[Nimble Warning]: If you're getting stuck on a debugger breakpoint for a " +
"fatal error while using throwAssertion(), please disable 'Debug Executable' " +
"in your scheme. Go to 'Edit Scheme > Test > Info' and uncheck " +
"'Debug Executable'. If you've already done that, suppress this warning " +
"by setting `NimbleEnvironment.activeInstance.suppressWatchOSAssertionWarning = true`. " +
"This is required because the standard methods of catching assertions " +
"(mach APIs) are unavailable for watchOS. Instead, the same mechanism the " +
"debugger uses is the fallback method for watchOS."
)
print()
NimbleEnvironment.activeInstance.suppressWatchOSAssertionWarning = true
}
#endif
do {
_ = try actualExpression.evaluate()
Expand Down
2 changes: 0 additions & 2 deletions Tests/NimbleTests/Matchers/ThrowAssertionTest.swift
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,6 @@ import Nimble

private let error: Error = NSError(domain: "test", code: 0, userInfo: nil)

#if !os(watchOS)
final class ThrowAssertionTest: XCTestCase {
func testPositiveMatch() {
#if arch(x86_64) || arch(arm64)
Expand DownExpand Up@@ -76,4 +75,3 @@ final class ThrowAssertionTest: XCTestCase {
#endif
}
}
#endif
55 changes: 42 additions & 13 deletions test
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,11 +10,15 @@ if which xcodebuild > /dev/null; then
LATEST_IOS_VERSION=`xcrun simctl list | grep ^iOS | ruby -e 'puts /\(([0-9.]+).*\)/.match(STDIN.read.chomp.split("\n").last).to_a[1]'`
LATEST_TVOS_SDK_VERSION=`xcodebuild -showsdks | grep appletvsimulator | cut -d ' ' -f 4 | ruby -e 'puts STDIN.read.chomp.split("\n").last'`
LATEST_TVOS_VERSION=`xcrun simctl list | grep ^tvOS | ruby -e 'puts /\(([0-9.]+).*\)/.match(STDIN.read.chomp.split("\n").last).to_a[1]'`
LATEST_WATCHOS_SDK_VERSION=`xcodebuild -showsdks | grep watchos | cut -d ' ' -f 2 | ruby -e 'puts STDIN.read.chomp.split("\n").last'`
LATEST_WATCHOS_VERSION=`xcrun simctl list | grep ^watchOS | ruby -e 'puts /\(([0-9.]+).*\)/.match(STDIN.read.chomp.split("\n").last).to_a[1]'`
LATEST_MACOS_SDK_VERSION=`xcodebuild -showsdks | grep 'macosx' | cut -d ' ' -f 2 | ruby -e 'puts STDIN.read.chomp.split("\n").last'`
BUILD_IOS_SDK_VERSION=${NIMBLE_BUILD_IOS_SDK_VERSION:-$LATEST_IOS_SDK_VERSION}
RUNTIME_IOS_VERSION=${NIMBLE_RUNTIME_IOS_VERSION:-$LATEST_IOS_VERSION}
BUILD_TVOS_SDK_VERSION=${NIMBLE_BUILD_TVOS_SDK_VERSION:-$LATEST_TVOS_SDK_VERSION}
RUNTIME_TVOS_VERSION=${NIMBLE_RUNTIME_TVOS_VERSION:-$LATEST_TVOS_VERSION}
BUILD_WATCHOS_SDK_VERSION=${NIMBLE_BUILD_WATCHOS_SDK_VERSION:-$LATEST_WATCHOS_SDK_VERSION}
RUNTIME_WATCHOS_VERSION=${NIMBLE_RUNTIME_WATCHOS_VERSION:-$LATEST_WATCHOS_VERSION}
BUILD_MACOS_SDK_VERSION=${NIMBLE_BUILD_MACOS_SDK_VERSION:-$LATEST_MACOS_SDK_VERSION}
fi

Expand DownExpand Up@@ -42,6 +46,11 @@ function print_env {
echo " Building with tvOS SDK: `color_if_overridden $BUILD_TVOS_SDK_VERSION $NIMBLE_BUILD_TVOS_SDK_VERSION`"
echo " Running with tvOS: `color_if_overridden $RUNTIME_TVOS_VERSION $NIMBLE_RUNTIME_TVOS_VERSION`"
echo
echo " watchOS:"
echo " Latest watchOS SDK: $LATEST_WATCHOS_SDK_VERSION"
echo " Building with watchOS SDK: `color_if_overridden $BUILD_WATCHOS_SDK_VERSION $NIMBLE_BUILD_WATCHOS_SDK_VERSION`"
echo " Running with watchOS: `color_if_overridden $RUNTIME_WATCHOS_VERSION $NIMBLE_RUNTIME_WATCHOS_VERSION`"
echo
echo " macOS:"
echo " Latest macOS SDK: $LATEST_MACOS_SDK_VERSION"
echo " Building with macOS SDK: `color_if_overridden $BUILD_MACOS_SDK_VERSION $NIMBLE_BUILD_MACOS_SDK_VERSION`"
Expand DownExpand Up@@ -69,12 +78,19 @@ function test_tvos {
run set -o pipefail && xcodebuild -project Nimble.xcodeproj -scheme "Nimble-tvOS" -configuration "Debug" -sdk "appletvsimulator$BUILD_TVOS_SDK_VERSION" -destination "name=Apple TV,OS=$RUNTIME_TVOS_VERSION" OTHER_SWIFT_FLAGS='$(inherited) -suppress-warnings' build-for-testing test-without-building | xcpretty
}

function test_watchos {
run set -o pipefail && xcodebuild -project Nimble.xcodeproj -scheme "Nimble-watchOS" -configuration "Debug" -destination "generic/platform=watchOS" OTHER_SWIFT_FLAGS='$(inherited) -suppress-warnings' build | xcpretty

run osascript -e 'tell app "Simulator" to quit'
run set -o pipefail && xcodebuild -project Nimble.xcodeproj -scheme "Nimble-watchOS" -configuration "Debug" -sdk "watchsimulator$BUILD_WATCHOS_SDK_VERSION" -destination "name=Apple Watch Series 6 - 40mm,OS=$RUNTIME_WATCHOS_VERSION" OTHER_SWIFT_FLAGS='$(inherited) -suppress-warnings' build-for-testing test-without-building | xcpretty
}

function test_macos {
run set -o pipefail && xcodebuild -project Nimble.xcodeproj -scheme "Nimble-macOS" -configuration "Debug" -sdk "macosx$BUILD_MACOS_SDK_VERSION" OTHER_SWIFT_FLAGS='$(inherited) -suppress-warnings' build-for-testing test-without-building | xcpretty
}

function test_xcode_spm_macos {
mv Nimble.xcodeproj Nimble.xcodeproj.bak
mv Nimble.xcodeproj Nimble.xcodeproj.bak
trap 'mv Nimble.xcodeproj.bak Nimble.xcodeproj' EXIT
run set -o pipefail && xcodebuild -scheme "Nimble" -configuration "Debug" -sdk "macosx$BUILD_MACOS_SDK_VERSION" -destination "platform=macOS" OTHER_SWIFT_FLAGS='$(inherited) -suppress-warnings' build-for-testing test-without-building | xcpretty
}
Expand All@@ -93,6 +109,13 @@ function test_xcode_spm_tvos {
run set -o pipefail && xcodebuild -scheme "Nimble" -configuration "Debug" -sdk "appletvsimulator$BUILD_TVOS_SDK_VERSION" -destination "name=Apple TV,OS=$RUNTIME_TVOS_VERSION" OTHER_SWIFT_FLAGS='$(inherited) -suppress-warnings' build-for-testing test-without-building | xcpretty
}

function test_xcode_spm_watchos {
run osascript -e 'tell app "Simulator" to quit'
mv Nimble.xcodeproj Nimble.xcodeproj.bak
trap 'mv Nimble.xcodeproj.bak Nimble.xcodeproj' EXIT
run set -o pipefail && xcodebuild -scheme "Nimble" -configuration "Debug" -sdk "watchsimulator$BUILD_WATCHOS_SDK_VERSION" -destination "name=Apple Watch Series 6 - 40mm,OS=$RUNTIME_WATCHOS_VERSION" OTHER_SWIFT_FLAGS='$(inherited) -suppress-warnings' build-for-testing test-without-building | xcpretty
}

function test_podspec {
echo "Gathering CocoaPods installation information..."
run bundle exec pod --version
Expand All@@ -117,11 +140,13 @@ function test() {
test_macos
test_ios
test_tvos
test_watchos

if xcodebuild --help 2>&1 | grep xcframework > /dev/null; then
test_xcode_spm_macos
test_xcode_spm_ios
test_xcode_spm_tvos
test_xcode_spm_watchos
else
echo "Not testing with Swift Package Manager version of Xcode because it requires at least Xcode 11"
fi
Expand All@@ -147,18 +172,20 @@ function help {
echo "Usage: $0 COMMANDS"
echo
echo "COMMANDS:"
echo " all - Runs the all tests of macos, ios and tvos"
echo " clean - Cleans the derived data directory of Xcode. Assumes default location"
echo " help - Displays this help"
echo " macos - Runs the tests on macOS 10.10 (Yosemite and newer only)"
echo " macos_xcodespm - Runs the tests on macOS using the Swift Package Manager version of Xcode"
echo " ios - Runs the tests as an iOS device"
echo " ios_xcodespm - Runs the tests as an iOS device using the Swift Package Manager version of Xcode"
echo " tvos - Runs the tests as an tvOS device"
echo " tvos_xcodespm - Runs the tests as an tvOS device using the Swift Package Manager version of Xcode"
echo " podspec - Runs pod lib lint against the podspec to detect breaking changes"
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 " all - Runs the all tests of macos, ios and tvos"
echo " clean - Cleans the derived data directory of Xcode. Assumes default location"
echo " help - Displays this help"
echo " macos - Runs the tests on macOS 10.10 (Yosemite and newer only)"
echo " macos_xcodespm - Runs the tests on macOS using the Swift Package Manager version of Xcode"
echo " ios - Runs the tests as an iOS device"
echo " ios_xcodespm - Runs the tests as an iOS device using the Swift Package Manager version of Xcode"
echo " tvos - Runs the tests as an tvOS device"
echo " tvos_xcodespm - Runs the tests as an tvOS device using the Swift Package Manager version of Xcode"
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 " 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
exit 1
}
Expand All@@ -173,6 +200,8 @@ function main {
ios_xcodespm) test_xcode_spm_ios ;;
tvos) test_tvos ;;
tvos_xcodespm) test_xcode_spm_tvos ;;
watchos) test_watchos ;;
watchos_xcodespm) test_xcode_spm_watchos ;;
macos) test_macos ;;
macos_xcodespm) test_xcode_spm_macos ;;
podspec) test_podspec ;;
Expand Down