Skip to content

Commit 67b09ec

Browse files
committed
Add compatibility with Swift 3.0
1 parent 8d4b176 commit 67b09ec

34 files changed

+151
-255
lines changed

.gitignore

+12-15
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
/.build/
2-
Example/example
3-
tests.swift
4-
Tests/Integration/Failing
5-
Tests/Integration/Failing-dot-output.txt
6-
Tests/Integration/Failing-output.txt
7-
Tests/Integration/Failing-tap-output.txt
8-
Tests/Integration/Passing
9-
Tests/Integration/Passing-dot-output.txt
10-
Tests/Integration/Passing-output.txt
11-
Tests/Integration/Passing-tap-output.txt
12-
Tests/Integration/Disabled
13-
Tests/Integration/Disabled-dot-output.txt
14-
Tests/Integration/Disabled-output.txt
15-
Tests/Integration/Disabled-tap-output.txt
1+
.build/
2+
Packages/
3+
*.xcodeproj
4+
IntegrationTests/Failing-dot-output.txt
5+
IntegrationTests/Failing-output.txt
6+
IntegrationTests/Failing-tap-output.txt
7+
IntegrationTests/Passing-dot-output.txt
8+
IntegrationTests/Passing-output.txt
9+
IntegrationTests/Passing-tap-output.txt
10+
IntegrationTests/Disabled-dot-output.txt
11+
IntegrationTests/Disabled-output.txt
12+
IntegrationTests/Disabled-tap-output.txt

.swift-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.0-GM-CANDIDATE

.travis.yml

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
language: objective-c
2-
osx_image: xcode7.3
3-
env:
4-
- SWIFT_VERSION=2.2
5-
- SWIFT_VERSION=3.0-preview-1-SNAPSHOT-2016-05-31-a
1+
language: generic
2+
sudo: required
3+
dist: trusty
64
install:
75
- eval "$(curl -sL https://gist.githubusercontent.com/kylef/5c0475ff02b7c7671d2a/raw/9f442512a46d7a2af7b850d65a7e9bd31edfb09b/swiftenv-install.sh)"
8-
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then sudo python -m ensurepip; fi
9-
- sudo pip install swim
106
script:
11-
- swim test
7+
- swift test
8+
- cd IntegrationTests && swift build && ./run.sh Failing Passing Disabled

Example/example.swift

-25
This file was deleted.

Tests/Integration/Failing-expected-dot-output.txt IntegrationTests/Failing-expected-dot-output.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
F
22

33
a person named kyle is Kyle
4-
Tests/Integration/Failing.swift:10 Katie is not equal to Kyle
4+
Sources/Failing/main.swift:10 Katie is not equal to Kyle
55

66
```
77
try expect(person) == "Kyle"

Tests/Integration/Failing-expected-output.txt IntegrationTests/Failing-expected-output.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
a person named kyle is Kyle
7-
Tests/Integration/Failing.swift:10 Katie is not equal to Kyle
7+
Sources/Failing/main.swift:10 Katie is not equal to Kyle
88

99
```
1010
try expect(person) == "Kyle"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
not ok 1 - a person named kyle is Kyle
2+
# Katie is not equal to Kyle from Sources/Failing/main.swift:10
3+
1..1

IntegrationTests/Package.swift

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import PackageDescription
2+
3+
4+
let package = Package(
5+
name: "SpectreIntegration",
6+
targets: [
7+
Target(name: "Passing", dependencies: ["Spectre"]),
8+
Target(name: "Disabled", dependencies: ["Spectre"]),
9+
Target(name: "Failing", dependencies: ["Spectre"]),
10+
]
11+
)
File renamed without changes.
File renamed without changes.
File renamed without changes.

IntegrationTests/Sources/Spectre

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../Sources/

Tests/Integration/run.sh IntegrationTests/run.sh

+11-9
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,35 @@ for var in "$@"; do
66
echo "-> '$var'"
77
rm $var-output.txt $var-dot-output.txt $var-tap-output.txt 2>/dev/null
88

9-
./$var > $var-output.txt
9+
./.build/debug/$var > $var-output.txt
1010
if [ $? != 0 ]; then
11-
if [ $var != "Tests/Integration/Failing" ]; then
11+
if [ $var != "Failing" ]; then
1212
echo " - Integration Failed"
1313
EXIT_CODE=1
1414
fi
15-
elif [ $var = "Tests/Integration/Failing" ]; then
15+
elif [ $var = "Failing" ]; then
1616
echo " - Failing Integration Succeeded"
1717
EXIT_CODE=1
1818
fi
19-
./$var -t > $var-dot-output.txt
19+
20+
./.build/debug/$var -t > $var-dot-output.txt
2021
if [ $? != 0 ]; then
21-
if [ $var != "Tests/Integration/Failing" ]; then
22+
if [ $var != "Failing" ]; then
2223
echo " - Dot Integration Failed"
2324
EXIT_CODE=1
2425
fi
25-
elif [ $var = "Tests/Integration/Failing" ]; then
26+
elif [ $var = "Failing" ]; then
2627
echo " - Failing Dot Integration Succeeded"
2728
EXIT_CODE=1
2829
fi
29-
./$var --tap > $var-tap-output.txt
30+
31+
./.build/debug/$var --tap > $var-tap-output.txt
3032
if [ $? != 0 ]; then
31-
if [ $var != "Tests/Integration/Failing" ]; then
33+
if [ $var != "Failing" ]; then
3234
echo " - Tap Integration Failed"
3335
EXIT_CODE=1
3436
fi
35-
elif [ $var = "Tests/Integration/Failing" ]; then
37+
elif [ $var = "Failing" ]; then
3638
echo " - Failing Tap Integration Succeeded"
3739
EXIT_CODE=1
3840
fi

Makefile

-37
This file was deleted.

Sources/Case.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ class Case : CaseType {
88
let disabled: Bool
99
let closure:() throws -> ()
1010

11-
init(name:String, disabled: Bool = false, closure:() throws -> ()) {
11+
init(name: String, disabled: Bool = false, closure: @escaping () throws -> ()) {
1212
self.name = name
1313
self.disabled = disabled
1414
self.closure = closure
1515
}
1616

17-
func run(reporter:ContextReporter) {
17+
func run(reporter: ContextReporter) {
1818
if disabled {
1919
reporter.addDisabled(name)
2020
return

Sources/Compatibility.swift

-36
This file was deleted.

Sources/Context.swift

+9-14
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@ public protocol ContextType {
1111
/// Creates a new disabled sub-context
1212
func xdescribe(_ name: String, closure: (ContextType) -> Void)
1313

14-
func before(closure: () -> Void)
15-
func after(closure: () -> Void)
14+
func before(_ closure: @escaping () -> Void)
15+
func after(_ closure: @escaping () -> Void)
1616

1717
/// Adds a new test case
18-
func it(_ name: String, closure: () throws -> Void)
18+
func it(_ name: String, closure: @escaping () throws -> Void)
1919

2020
/// Adds a disabled test case
21-
func xit(_ name: String, closure: () throws -> Void)
21+
func xit(_ name: String, closure: @escaping () throws -> Void)
2222
}
2323

2424
class Context : ContextType, CaseType {
2525
let name: String
2626
let disabled: Bool
27-
private weak var parent: Context?
27+
fileprivate weak var parent: Context?
2828
var cases = [CaseType]()
2929

3030
typealias Before = (() -> Void)
@@ -63,19 +63,19 @@ class Context : ContextType, CaseType {
6363
cases.append(context)
6464
}
6565

66-
func before(closure: () -> Void) {
66+
func before(_ closure: @escaping () -> Void) {
6767
befores.append(closure)
6868
}
6969

70-
func after(closure: () -> Void) {
70+
func after(_ closure: @escaping () -> Void) {
7171
afters.append(closure)
7272
}
7373

74-
func it(_ name: String, closure: () throws -> Void) {
74+
func it(_ name: String, closure: @escaping () throws -> Void) {
7575
cases.append(Case(name: name, closure: closure))
7676
}
7777

78-
func xit(_ name: String, closure: () throws -> Void) {
78+
func xit(_ name: String, closure: @escaping () throws -> Void) {
7979
cases.append(Case(name: name, disabled: true, closure: closure))
8080
}
8181

@@ -98,14 +98,9 @@ class Context : ContextType, CaseType {
9898
reporter.report(name) { reporter in
9999
cases.forEach {
100100
runBefores()
101-
#if swift(>=3.0)
102101
$0.run(reporter: reporter)
103-
#else
104-
$0.run(reporter)
105-
#endif
106102
runAfters()
107103
}
108104
}
109105
}
110106
}
111-

0 commit comments

Comments
 (0)