Skip to content
Closed
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: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "antitypical/Result" ~> 0.4
github "antitypical/Result" ~> 0.5
4 changes: 2 additions & 2 deletions Cartfile.private
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
github "Quick/Quick" ~> 0.3
github "Quick/Nimble" ~> 0.4
github "Quick/Quick" ~> 0.4
github "Quick/Nimble" ~> 2
github "jspahrsummers/xcconfigs" ~> 0.8
9 changes: 4 additions & 5 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
github "robrix/Box" "1.2.1"
github "Quick/Nimble" "v0.4.2"
github "Quick/Quick" "v0.3.1"
github "jspahrsummers/xcconfigs" "0.8"
github "antitypical/Result" "0.4"
github "Quick/Nimble" "v2.0.0-rc.1"
github "Quick/Quick" "v0.4.0"
github "antitypical/Result" "0.5"
github "jspahrsummers/xcconfigs" "0.8.1"
2 changes: 1 addition & 1 deletion Carthage/Checkouts/Nimble
Submodule Nimble updated 57 files
+1 −0 .gitignore
+1 −1 Nimble.podspec
+27 −33 Nimble.xcodeproj/project.pbxproj
+2 −2 Nimble.xcodeproj/project.xcworkspace/xcshareddata/Nimble.xccheckout
+4 −1 Nimble.xcodeproj/xcshareddata/xcschemes/Nimble-OSX.xcscheme
+4 −1 Nimble.xcodeproj/xcshareddata/xcschemes/Nimble-iOS.xcscheme
+1 −1 Nimble/Adapters/AdapterProtocols.swift
+20 −0 Nimble/Adapters/AssertionDispatcher.swift
+51 −3 Nimble/Adapters/AssertionRecorder.swift
+18 −2 Nimble/Adapters/NimbleXCTestHandler.swift
+6 −5 Nimble/DSL+Wait.swift
+4 −4 Nimble/DSL.swift
+30 −17 Nimble/Expectation.swift
+46 −2 Nimble/Expression.swift
+32 −7 Nimble/FailureMessage.swift
+3 −14 Nimble/Matchers/AllPass.swift
+1 −1 Nimble/Matchers/BeAKindOf.swift
+1 −1 Nimble/Matchers/BeAnInstanceOf.swift
+6 −6 Nimble/Matchers/BeCloseTo.swift
+12 −1 Nimble/Matchers/BeEmpty.swift
+1 −1 Nimble/Matchers/BeGreaterThan.swift
+1 −1 Nimble/Matchers/BeGreaterThanOrEqualTo.swift
+1 −1 Nimble/Matchers/BeIdenticalTo.swift
+1 −1 Nimble/Matchers/BeLessThan.swift
+1 −1 Nimble/Matchers/BeLessThanOrEqual.swift
+38 −21 Nimble/Matchers/BeLogical.swift
+1 −1 Nimble/Matchers/BeNil.swift
+2 −2 Nimble/Matchers/BeginWith.swift
+5 −6 Nimble/Matchers/Contain.swift
+5 −5 Nimble/Matchers/EndWith.swift
+3 −3 Nimble/Matchers/Equal.swift
+1 −1 Nimble/Matchers/Match.swift
+2 −34 Nimble/Matchers/MatcherProtocols.swift
+119 −177 Nimble/Matchers/RaisesException.swift
+79 −0 Nimble/ObjCExpectation.swift
+5 −5 Nimble/Utils/Poll.swift
+1 −1 Nimble/Utils/SourceLocation.swift
+3 −3 Nimble/Utils/Stringers.swift
+30 −54 Nimble/Wrappers/AsyncMatcherWrapper.swift
+0 −28 Nimble/Wrappers/BasicMatcherWrapper.swift
+0 −18 Nimble/Wrappers/FullMatcherWrapper.swift
+56 −16 Nimble/Wrappers/MatcherFunc.swift
+0 −56 Nimble/Wrappers/NonNilMatcherWrapper.swift
+12 −88 Nimble/Wrappers/ObjCMatcher.swift
+4 −4 Nimble/objc/DSL.h
+10 −2 Nimble/objc/DSL.m
+1 −1 NimbleTests/AsynchronousTest.swift
+44 −21 NimbleTests/Helpers/utils.swift
+7 −7 NimbleTests/Matchers/AllPassTest.swift
+6 −6 NimbleTests/Matchers/BeEmptyTest.swift
+23 −1 NimbleTests/Matchers/BeLogicalTest.swift
+92 −39 NimbleTests/Matchers/RaisesExceptionTest.swift
+4 −0 NimbleTests/objc/NimbleSpecHelper.h
+102 −27 NimbleTests/objc/ObjCRaiseExceptionTest.m
+16 −21 README.md
+42 −0 circle.yml
+5 −5 test
1 change: 1 addition & 0 deletions Carthage/Checkouts/Result
Submodule Result added at 665c17
2 changes: 1 addition & 1 deletion Carthage/Checkouts/xcconfigs
19 changes: 16 additions & 3 deletions Commandant.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
D00CCE2B1A20748500109F8C /* Errors.swift in Sources */ = {isa = PBXBuildFile; fileRef = D00CCE2A1A20748500109F8C /* Errors.swift */; };
D00CCE2D1A2075ED00109F8C /* ArgumentParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = D00CCE2C1A2075ED00109F8C /* ArgumentParser.swift */; };
D00CCE2F1A2075F700109F8C /* Option.swift in Sources */ = {isa = PBXBuildFile; fileRef = D00CCE2E1A2075F700109F8C /* Option.swift */; };
D02130991AF87D6E00B9EC20 /* Box.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D02130971AF87D6E00B9EC20 /* Box.framework */; };
D021309A1AF87D6E00B9EC20 /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D02130981AF87D6E00B9EC20 /* Result.framework */; };
D0BF14FB1A4C8957003147BC /* HelpCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0BF14FA1A4C8957003147BC /* HelpCommand.swift */; };
D8169D871ACB942D00923FB0 /* Switch.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8169D861ACB942D00923FB0 /* Switch.swift */; };
Expand Down Expand Up @@ -74,7 +73,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
D02130991AF87D6E00B9EC20 /* Box.framework in Frameworks */,
D021309A1AF87D6E00B9EC20 /* Result.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -294,7 +292,8 @@
D00CCDD01A20717400109F8C /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0610;
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0700;
ORGANIZATIONNAME = Carthage;
TargetAttributes = {
D00CCDD81A20717400109F8C = {
Expand Down Expand Up @@ -378,7 +377,10 @@
baseConfigurationReference = D00CCDFA1A20719500109F8C /* Debug.xcconfig */;
buildSettings = {
CURRENT_PROJECT_VERSION = 1;
ENABLE_TESTABILITY = YES;
GCC_NO_COMMON_BLOCKS = YES;
MACOSX_DEPLOYMENT_TARGET = 10.9;
ONLY_ACTIVE_ARCH = YES;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand All @@ -389,6 +391,7 @@
baseConfigurationReference = D00CCDFC1A20719500109F8C /* Release.xcconfig */;
buildSettings = {
CURRENT_PROJECT_VERSION = 1;
GCC_NO_COMMON_BLOCKS = YES;
MACOSX_DEPLOYMENT_TARGET = 10.9;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand All @@ -406,6 +409,7 @@
FRAMEWORK_VERSION = A;
INFOPLIST_FILE = Commandant/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "org.carthage.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
Expand All @@ -422,6 +426,7 @@
FRAMEWORK_VERSION = A;
INFOPLIST_FILE = Commandant/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "org.carthage.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
Expand All @@ -435,6 +440,7 @@
"$(inherited)",
);
INFOPLIST_FILE = CommandantTests/Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = "org.carthage.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
Expand All @@ -448,6 +454,7 @@
"$(inherited)",
);
INFOPLIST_FILE = CommandantTests/Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = "org.carthage.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
Expand All @@ -457,6 +464,7 @@
baseConfigurationReference = D00CCDFB1A20719500109F8C /* Profile.xcconfig */;
buildSettings = {
CURRENT_PROJECT_VERSION = 1;
GCC_NO_COMMON_BLOCKS = YES;
MACOSX_DEPLOYMENT_TARGET = 10.9;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand All @@ -474,6 +482,7 @@
FRAMEWORK_VERSION = A;
INFOPLIST_FILE = Commandant/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "org.carthage.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Profile;
Expand All @@ -487,6 +496,7 @@
"$(inherited)",
);
INFOPLIST_FILE = CommandantTests/Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = "org.carthage.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Profile;
Expand All @@ -496,6 +506,7 @@
baseConfigurationReference = D00CCDFD1A20719500109F8C /* Test.xcconfig */;
buildSettings = {
CURRENT_PROJECT_VERSION = 1;
GCC_NO_COMMON_BLOCKS = YES;
MACOSX_DEPLOYMENT_TARGET = 10.9;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand All @@ -513,6 +524,7 @@
FRAMEWORK_VERSION = A;
INFOPLIST_FILE = Commandant/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "org.carthage.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
Expand All @@ -527,6 +539,7 @@
"$(inherited)",
);
INFOPLIST_FILE = CommandantTests/Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = "org.carthage.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Test;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0610"
LastUpgradeVersion = "0700"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -62,6 +62,8 @@
ReferencedContainer = "container:Commandant.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
Expand All @@ -71,6 +73,7 @@
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
Expand Down
3 changes: 0 additions & 3 deletions Commandant.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Commandant/ArgumentParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private func ==(lhs: RawArgument, rhs: RawArgument) -> Bool {
}
}

extension RawArgument: Printable {
extension RawArgument: CustomStringConvertible {
private var description: String {
switch self {
case let .Key(key):
Expand Down Expand Up @@ -68,8 +68,8 @@ public final class ArgumentParser {
rawArguments.extend(options.map { arg in
if arg.hasPrefix("-") {
// Do we have `--{key}` or `-{flags}`.
var opt = dropFirst(arg)
return opt.hasPrefix("-") ? .Key(dropFirst(opt)) : .Flag(Set(opt))
let opt = dropFirst(arg.characters)
return String(opt).hasPrefix("-") ? .Key(String(dropFirst(opt))) : .Flag(Set(opt))
} else {
return .Value(arg)
}
Expand All @@ -78,7 +78,7 @@ public final class ArgumentParser {
// Remaining arguments are all positional parameters.
if params.count == 2 {
let positional = params.last!
rawArguments.extend(positional.map { .Value($0) })
rawArguments.extend(Array(positional.map { .Value($0) }))
}
}

Expand Down Expand Up @@ -169,7 +169,7 @@ public final class ArgumentParser {
/// Returns whether the given flag was specified and removes it from the
/// list of arguments remaining.
internal func consumeBooleanFlag(flag: Character) -> Bool {
for (index, arg) in enumerate(rawArguments) {
for (index, arg) in rawArguments.enumerate() {
switch arg {
case var .Flag(flags) where flags.contains(flag):
flags.remove(flag)
Expand Down
8 changes: 4 additions & 4 deletions Commandant/Command.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public final class CommandRegistry<ClientError> {

/// All available commands.
public var commands: [CommandOf<ClientError>] {
return sorted(commandsByVerb.values) { return $0.verb < $1.verb }
return commandsByVerb.values.sort { return $0.verb < $1.verb }
}

public init() {}
Expand Down Expand Up @@ -101,7 +101,7 @@ extension CommandRegistry {
/// If a matching command could not be found or a usage error occurred,
/// a helpful error message will be written to `stderr`, then the process
/// will exit with a failure error code.
@noreturn public func main(#defaultVerb: String, errorHandler: ClientError -> ()) {
@noreturn public func main(defaultVerb defaultVerb: String, errorHandler: ClientError -> ()) {
var arguments = Process.arguments
assert(arguments.count >= 1)

Expand All @@ -120,12 +120,12 @@ extension CommandRegistry {
exit(EXIT_SUCCESS)

case let .Some(.Failure(error)):
switch error.value {
switch error {
case let .UsageError(description):
fputs(description + "\n", stderr)

case let .CommandError(error):
errorHandler(error.value)
errorHandler(error)
}

exit(EXIT_FAILURE)
Expand Down
19 changes: 9 additions & 10 deletions Commandant/Errors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//

import Foundation
import Box
import Result

/// Possible errors that can originate from Commandant.
Expand All @@ -19,17 +18,17 @@ public enum CommandantError<ClientError> {
case UsageError(description: String)

/// An error occurred while running a command.
case CommandError(Box<ClientError>)
case CommandError(ClientError)
}

extension CommandantError: Printable {
extension CommandantError: CustomStringConvertible {
public var description: String {
switch self {
case let .UsageError(description):
return description

case let .CommandError(error):
return toString(error)
return String(error)
}
}
}
Expand All @@ -49,7 +48,7 @@ internal func missingArgumentError<ClientError>(argumentName: String) -> Command
internal func informativeUsageError<ClientError>(keyValueExample: String, usage: String) -> CommandantError<ClientError> {
let lines = usage.componentsSeparatedByCharactersInSet(NSCharacterSet.newlineCharacterSet())

return .UsageError(description: reduce(lines, keyValueExample) { previous, value in
return .UsageError(description: lines.reduce(keyValueExample) { previous, value in
return previous + "\n\t" + value
})
}
Expand All @@ -58,9 +57,9 @@ internal func informativeUsageError<ClientError>(keyValueExample: String, usage:
/// example of key (and value, if applicable) usage.
internal func informativeUsageError<T, ClientError>(keyValueExample: String, option: Option<T>) -> CommandantError<ClientError> {
if option.defaultValue != nil {
return informativeUsageError("[\(keyValueExample)]", option.usage)
return informativeUsageError("[\(keyValueExample)]", usage: option.usage)
} else {
return informativeUsageError(keyValueExample, option.usage)
return informativeUsageError(keyValueExample, usage: option.usage)
}
}

Expand All @@ -83,7 +82,7 @@ internal func informativeUsageError<T: ArgumentType, ClientError>(option: Option
example += valueExample
}

return informativeUsageError(example, option)
return informativeUsageError(example, option: option)
}

/// Constructs an error that describes how to use the given boolean option.
Expand All @@ -93,9 +92,9 @@ internal func informativeUsageError<ClientError>(option: Option<Bool>) -> Comman
let key = option.key!

if let defaultValue = option.defaultValue {
return informativeUsageError((defaultValue ? "--no-\(key)" : "--\(key)"), option)
return informativeUsageError((defaultValue ? "--no-\(key)" : "--\(key)"), option: option)
} else {
return informativeUsageError("--(no-)\(key)", option)
return informativeUsageError("--(no-)\(key)", option: option)
}
}

Expand Down
11 changes: 5 additions & 6 deletions Commandant/HelpCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,24 @@ public struct HelpCommand<ClientError>: CommandType {
.flatMap { options in
if let verb = options.verb {
if let command = self.registry[verb] {
println(command.function)
println()
print(command.function + "\n")
return command.run(.Usage)
} else {
fputs("Unrecognized command: '\(verb)'\n", stderr)
}
}

println("Available commands:\n")
print("Available commands:\n")

let maxVerbLength = maxElement(self.registry.commands.map { count($0.verb) })
let maxVerbLength = self.registry.commands.map { $0.verb.characters.count }.maxElement() ?? 0

for command in self.registry.commands {
let padding = Repeat<Character>(count: maxVerbLength - count(command.verb), repeatedValue: " ")
let padding = Repeat<Character>(count: maxVerbLength - command.verb.characters.count, repeatedValue: " ")

var formattedVerb = command.verb
formattedVerb.extend(padding)

println(" \(formattedVerb) \(command.function)")
print(" \(formattedVerb) \(command.function)")
}

return .success(())
Expand Down
2 changes: 1 addition & 1 deletion Commandant/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>org.carthage.$(PRODUCT_NAME:rfc1034identifier)</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
Loading