Skip to content

Commit 862d3d3

Browse files
Merge pull request bannzai#120 from kishikawakatsumi/test-xcode8
Execute some tests on Xcode 8 in addition to Xcode 9
2 parents 21cf0cf + 542425c commit 862d3d3

File tree

5 files changed

+43
-5
lines changed

5 files changed

+43
-5
lines changed

.travis.yml

+23-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
language: objective-c
2-
osx_image: xcode9
32
cache:
43
directories:
54
- build
@@ -9,12 +8,14 @@ cache:
98
jobs:
109
include:
1110
- stage: build
11+
osx_image: xcode9
1212
install:
1313
- bundle install --path=vendor/bundle --binstubs=vendor/bin
1414
script:
1515
- bundle exec rake build-for-testing:simulator
1616
- &test
17-
stage: test
17+
stage: 'test (xcode9)'
18+
osx_image: xcode9
1819
script:
1920
- bundle exec rake test-without-building:simulator
2021
DESTINATIONS="['name=iPhone 4s,OS=9.3']"
@@ -68,7 +69,27 @@ jobs:
6869
script:
6970
- bundle exec rake test-without-building:simulator
7071
DESTINATIONS="['name=iPad 2,OS=9.3']" TESTCASE='SelectionTests'
72+
- stage: 'test (xcode8.3)'
73+
osx_image: xcode8.3
74+
script:
75+
- bundle exec rake test:simulator DESTINATIONS="['name=iPhone 4s,OS=9.3']"
76+
after_success:
77+
- bash <(curl -s https://codecov.io/bash) -f 'coverage.txt'
78+
- stage: 'test (xcode8.3)'
79+
osx_image: xcode8.3
80+
script:
81+
- bundle exec rake test:simulator DESTINATIONS="['name=iPhone 7,OS=10.3.1']"
82+
after_success:
83+
- bash <(curl -s https://codecov.io/bash) -f 'coverage.txt'
84+
- stage: carthage
85+
osx_image: xcode9
86+
install:
87+
- brew update
88+
- brew outdated carthage || brew upgrade carthage
89+
script:
90+
- carthage build --no-skip-current
7191
- stage: carthage
92+
osx_image: xcode8.3
7293
install:
7394
- brew update
7495
- brew outdated carthage || brew upgrade carthage

Framework/Tests/HelperFunctions.swift

+8
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ func showViewController(viewController: UIViewController) {
4444
func numberOfVisibleColumns(in view: SpreadsheetView, contentOffset: CGPoint = CGPoint.zero, parameters: Parameters) -> Int {
4545
let contentInset: UIEdgeInsets
4646
if #available(iOS 11.0, *) {
47+
#if swift(>=3.2)
4748
contentInset = view.adjustedContentInset
49+
#else
50+
fatalError("unreachable code")
51+
#endif
4852
} else {
4953
contentInset = view.contentInset
5054
}
@@ -70,7 +74,11 @@ func numberOfVisibleColumns(in view: SpreadsheetView, contentOffset: CGPoint = C
7074
func numberOfVisibleRows(in view: SpreadsheetView, contentOffset: CGPoint = CGPoint.zero, parameters: Parameters) -> Int {
7175
let contentInset: UIEdgeInsets
7276
if #available(iOS 11.0, *) {
77+
#if swift(>=3.2)
7378
contentInset = view.adjustedContentInset
79+
#else
80+
fatalError("unreachable code")
81+
#endif
7482
} else {
7583
contentInset = view.contentInset
7684
}

Framework/Tests/ViewTests.swift

+6
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,13 @@ class ViewTests: XCTestCase {
136136

137137
XCTAssertEqual(spreadsheetView.frame, spreadsheetView.window!.frame)
138138
if #available(iOS 11.0, *) {
139+
#if swift(>=3.2)
139140
XCTAssertEqual(spreadsheetView.adjustedContentInset.top,
140141
UIApplication.shared.statusBarFrame.height + viewController.navigationController!.navigationBar.frame.height)
141142
XCTAssertEqual(spreadsheetView.adjustedContentInset.left, 0)
142143
XCTAssertEqual(spreadsheetView.adjustedContentInset.right, 0)
143144
XCTAssertEqual(spreadsheetView.adjustedContentInset.bottom, 0)
145+
#endif
144146

145147
XCTAssertEqual(spreadsheetView.contentInset, .zero)
146148
} else {
@@ -173,11 +175,13 @@ class ViewTests: XCTestCase {
173175

174176
XCTAssertEqual(spreadsheetView.frame, spreadsheetView.window!.frame)
175177
if #available(iOS 11.0, *) {
178+
#if swift(>=3.2)
176179
XCTAssertEqual(spreadsheetView.adjustedContentInset.top,
177180
UIApplication.shared.statusBarFrame.height + viewController.navigationController!.navigationBar.frame.height)
178181
XCTAssertEqual(spreadsheetView.adjustedContentInset.left, 0)
179182
XCTAssertEqual(spreadsheetView.adjustedContentInset.right, 0)
180183
XCTAssertEqual(spreadsheetView.adjustedContentInset.bottom, viewController.tabBarController!.tabBar.frame.height)
184+
#endif
181185

182186
XCTAssertEqual(spreadsheetView.contentInset, .zero)
183187
} else {
@@ -208,9 +212,11 @@ class ViewTests: XCTestCase {
208212

209213
XCTAssertEqual(spreadsheetView.frame, spreadsheetView.window!.frame)
210214
XCTAssertEqual(spreadsheetView.contentInset, .zero)
215+
#if swift(>=3.2)
211216
if #available(iOS 11.0, *) {
212217
XCTAssertEqual(spreadsheetView.adjustedContentInset, .zero)
213218
}
219+
#endif
214220
}
215221

216222
func testReloading() {

Gemfile.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ DEPENDENCIES
1212
xcjobs
1313

1414
BUNDLED WITH
15-
1.15.0
15+
1.15.3

Rakefile

+5-2
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@ namespace :test do
1111
t.scheme = 'SpreadsheetView'
1212
t.sdk = 'iphonesimulator'
1313
t.configuration = configuration
14-
14+
1515
destinations.each { |destination| t.add_destination(destination) }
1616
t.add_only_testing("SpreadsheetViewTests/#{testcase}") if testcase
1717
t.add_build_option('-enableCodeCoverage', 'YES')
1818
t.add_build_setting('ENABLE_TESTABILITY', 'YES')
1919
t.add_build_setting('ONLY_ACTIVE_ARCH', 'NO')
2020
t.build_dir = 'build'
21+
t.after_action do
22+
build_coverage_reports()
23+
end
2124
end
2225

2326
desc 'test on device'
@@ -74,7 +77,7 @@ end
7477

7578
def build_coverage_reports()
7679
project_name = 'SpreadsheetView'
77-
profdata = Dir.glob(File.join('build', '/**/Coverage.profdata')).first
80+
profdata = Dir.glob(File.join('build', '/**/Coverage.profdata')).first
7881
Dir.glob(File.join('build', "/**/#{project_name}")) do |target|
7982
output = `xcrun llvm-cov report -instr-profile "#{profdata}" "#{target}" -arch=x86_64`
8083
if $?.success?

0 commit comments

Comments
 (0)