Skip to content

Commit e325c92

Browse files
authored
Android support and CI (#115)
* Android fix and CI * Add spcial-case measure function for Android to work around large standard deviation on emulator (swiftlang/swift-corelibs-xctest#506)
1 parent ef21abe commit e325c92

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

.github/workflows/test.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,17 @@ jobs:
1616
image: swift:latest
1717
steps:
1818
- uses: actions/checkout@v1
19-
- name: Test
19+
- name: Test Linux
2020
run: swift test
2121

22+
android:
23+
name: Android
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v1
27+
- name: Test Android
28+
uses: skiptools/swift-android-action@v2
29+
2230
macos:
2331
name: macOS, iOS, tvOS, Mac Catalyst (Xcode)
2432
runs-on: macos-latest

Sources/CBOR.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,6 @@ extension CBOR.Tag {
174174
public static let selfDescribeCBOR = CBOR.Tag(rawValue: 55799)
175175
}
176176

177-
#if os(Linux) || os(Windows)
177+
#if os(Linux) || os(Windows) || os(Android)
178178
let NSEC_PER_SEC: UInt64 = 1_000_000_000
179179
#endif

Tests/CBORDecoderTests.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,20 @@ class CBORDecoderTests: XCTestCase {
202202
}
203203
}
204204
}
205+
206+
#if os(Android)
207+
208+
extension XCTestCase {
209+
/// XCTestCase.measure on Android is problematic because
210+
/// the emulator on a virtualized runner can be quite slow
211+
/// but there is no way to set the standard deviation threshold
212+
/// for failure, so we override it to simply run the block
213+
/// and not perform any measurement.
214+
///
215+
/// See: https://github.com/swiftlang/swift-corelibs-xctest/pull/506
216+
func measure(_ count: Int = 0, _ block: () -> ()) {
217+
block()
218+
}
219+
}
220+
#endif
221+

0 commit comments

Comments
 (0)