Skip to content

Add .Always and .Never cases to StdlibUnittest's TestPredicate #1133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 29, 2016
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
14 changes: 14 additions & 0 deletions stdlib/private/StdlibUnittest/StdlibUnittest.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -1124,6 +1124,9 @@ func _getRunningOSVersion() -> OSVersion {
public enum TestRunPredicate : CustomStringConvertible {
case Custom(() -> Bool, reason: String)

case Always(/*reason:*/ String)
case Never

case OSXAny(/*reason:*/ String)
case OSXMajor(Int, reason: String)
case OSXMinor(Int, Int, reason: String)
Expand Down Expand Up @@ -1166,6 +1169,12 @@ public enum TestRunPredicate : CustomStringConvertible {
switch self {
case Custom(_, let reason):
return "Custom(reason: \(reason))"

case Always(let reason):
return "Always(reason: \(reason))"
case Never:
return ""

case OSXAny(let reason):
return "OSX(*, reason: \(reason))"
case OSXMajor(let major, let reason):
Expand Down Expand Up @@ -1240,6 +1249,11 @@ public enum TestRunPredicate : CustomStringConvertible {
case Custom(let predicate, _):
return predicate()

case Always:
return true
case Never:
return false

case OSXAny:
switch _getRunningOSVersion() {
case .OSX:
Expand Down
24 changes: 24 additions & 0 deletions validation-test/stdlib/StdlibUnittest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ XFailsAndSkips.test("fails") {
expectEqual(1, 2)
}

// CHECK: [ XFAIL ] XFailsAndSkips.fails-always{{$}}
XFailsAndSkips.test("fails-always")
.xfail(.Always("must always fail")).code {
expectEqual(1, 2)
}

// CHECK: [ OK ] XFailsAndSkips.fails-never{{$}}
XFailsAndSkips.test("fails-never")
.xfail(.Never).code {
expectEqual(1, 1)
}

// CHECK: [ XFAIL ] XFailsAndSkips.xfail 10.9.3 passes{{$}}
XFailsAndSkips.test("xfail 10.9.3 passes")
.xfail(.OSXBugFix(10, 9, 3, reason: "")).code {
Expand All @@ -82,6 +94,18 @@ XFailsAndSkips.test("xfail 10.9.3 fails")
expectEqual(1, 2)
}

// CHECK: [ SKIP ] XFailsAndSkips.skipAlways (skip: [Always(reason: skip)]){{$}}
XFailsAndSkips.test("skipAlways")
.skip(.Always("skip")).code {
fatalError("should not happen")
}

// CHECK: [ OK ] XFailsAndSkips.skipNever{{$}}
XFailsAndSkips.test("skipNever")
.skip(.Never).code {
expectEqual(1, 1)
}

// CHECK: [ FAIL ] XFailsAndSkips.skip 10.9.2 passes{{$}}
XFailsAndSkips.test("skip 10.9.2 passes")
.skip(.OSXBugFix(10, 9, 2, reason: "")).code {
Expand Down