Skip to content

Commit

Permalink
Update Android CI
Browse files Browse the repository at this point in the history
  • Loading branch information
marcprux committed Jan 5, 2025
1 parent 700dafc commit 6d067d7
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 38 deletions.
6 changes: 3 additions & 3 deletions Tests/A+/2.1.2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ class Test212: XCTestCase {
func test() {
describe("2.1.2.1: When fulfilled, a promise: must not transition to any other state.") {
testFulfilled { promise, expectation, _ in
promise.test(onFulfilled: { expectation.fulfill() }, onRejected: { XCTFail() })
promise.test(onFulfilled: expectation.fulfill, onRejected: { XCTFail() })
}

specify("trying to fulfill then immediately reject") { d, expectation in
d.promise.test(onFulfilled: { expectation.fulfill() }, onRejected: { XCTFail() })
d.promise.test(onFulfilled: expectation.fulfill, onRejected: { XCTFail() })
d.fulfill()
d.reject(Error.dummy)
}

specify("trying to fulfill then reject, delayed") { d, expectation in
d.promise.test(onFulfilled: { expectation.fulfill() }, onRejected: { XCTFail() })
d.promise.test(onFulfilled: expectation.fulfill, onRejected: { XCTFail() })
after(ticks: 1) {
d.fulfill()
d.reject(Error.dummy)
Expand Down
8 changes: 4 additions & 4 deletions Tests/A+/2.1.3.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ class Test213: XCTestCase {
func test() {
describe("2.1.3.1: When rejected, a promise: must not transition to any other state.") {
testRejected { promise, expectation, _ in
promise.test(onFulfilled: { XCTFail() }, onRejected: { expectation.fulfill() })
promise.test(onFulfilled: { XCTFail() }, onRejected: expectation.fulfill)
}

specify("trying to reject then immediately fulfill") { d, expectation in
d.promise.test(onFulfilled: { XCTFail() }, onRejected: { expectation.fulfill() })
d.promise.test(onFulfilled: { XCTFail() }, onRejected: expectation.fulfill)
d.reject(Error.dummy)
d.fulfill()
}

specify("trying to reject then fulfill, delayed") { d, expectation in
d.promise.test(onFulfilled: { XCTFail() }, onRejected: { expectation.fulfill() })
d.promise.test(onFulfilled: { XCTFail() }, onRejected: expectation.fulfill)
after(ticks: 1) {
d.reject(Error.dummy)
d.fulfill()
}
}

specify("trying to reject immediately then fulfill delayed") { d, expectation in
d.promise.test(onFulfilled: { XCTFail() }, onRejected: { expectation.fulfill() })
d.promise.test(onFulfilled: { XCTFail() }, onRejected: expectation.fulfill)
d.reject(Error.dummy)
after(ticks: 1) {
d.fulfill()
Expand Down
20 changes: 10 additions & 10 deletions Tests/A+/2.2.2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Test222: XCTestCase {
}
specify("never fulfilled") { d, expectation in
d.promise.done{ XCTFail() }.silenceWarning()
after(ticks: 1000, execute: { expectation.fulfill() })
after(ticks: 1000, execute: expectation.fulfill)
}
}

Expand All @@ -42,37 +42,37 @@ class Test222: XCTestCase {
}
}
specify("trying to fulfill a pending promise more than once, immediately") { d, expectation in
d.promise.done({ expectation.fulfill() }).silenceWarning()
d.promise.done(expectation.fulfill).silenceWarning()
d.fulfill()
d.fulfill()
}
specify("trying to fulfill a pending promise more than once, delayed") { d, expectation in
d.promise.done({ expectation.fulfill() }).silenceWarning()
d.promise.done(expectation.fulfill).silenceWarning()
after(ticks: 5) {
d.fulfill()
d.fulfill()
}
}
specify("trying to fulfill a pending promise more than once, immediately then delayed") { d, expectation in
let ex = (expectation, mkex())
d.promise.done({ ex.0.fulfill() }).silenceWarning()
d.promise.done(ex.0.fulfill).silenceWarning()
d.fulfill()
after(ticks: 5) {
d.fulfill()
}
after(ticks: 10, execute: { ex.1.fulfill() })
after(ticks: 10, execute: ex.1.fulfill)
}
specify("when multiple `then` calls are made, spaced apart in time") { d, expectation in
let ex = (expectation, self.expectation(description: ""), self.expectation(description: ""), self.expectation(description: ""))

do {
d.promise.done({ ex.0.fulfill() }).silenceWarning()
d.promise.done(ex.0.fulfill).silenceWarning()
}
after(ticks: 5) {
d.promise.done({ ex.1.fulfill() }).silenceWarning()
d.promise.done(ex.1.fulfill).silenceWarning()
}
after(ticks: 10) {
d.promise.done({ ex.2.fulfill() }).silenceWarning()
d.promise.done(ex.2.fulfill).silenceWarning()
}
after(ticks: 15) {
d.fulfill()
Expand All @@ -82,9 +82,9 @@ class Test222: XCTestCase {
specify("when `then` is interleaved with fulfillment") { d, expectation in
let ex = (expectation, self.expectation(description: ""), self)

d.promise.done({ ex.0.fulfill() }).silenceWarning()
d.promise.done(ex.0.fulfill).silenceWarning()
d.fulfill()
d.promise.done({ ex.1.fulfill() }).silenceWarning()
d.promise.done(ex.1.fulfill).silenceWarning()
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/A+/2.2.3.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Test223: XCTestCase {
}
specify("never rejected") { d, expectation in
d.promise.catch { _ in XCTFail() }
after(ticks: 1, execute: { expectation.fulfill() })
after(ticks: 1, execute: expectation.fulfill)
}
}
describe("2.2.3.3: it must not be called more than once.") {
Expand Down
8 changes: 8 additions & 0 deletions Tests/A+/XCTestManifests.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
#if !canImport(ObjectiveC)
import XCTest

#if os(Linux) || os(Android)
extension XCTestExpectation {
func fulfill() {
fulfill(#file, line: #line)
}
}
#endif

extension Test212 {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
Expand Down
12 changes: 6 additions & 6 deletions Tests/CorePromise/AfterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import XCTest
class AfterTests: XCTestCase {
func testZero() {
let ex2 = expectation(description: "")
after(seconds: 0).done({ ex2.fulfill() })
after(seconds: 0).done(ex2.fulfill)
waitForExpectations(timeout: 2, handler: nil)

let ex3 = expectation(description: "")
after(.seconds(0)).done({ ex3.fulfill() })
after(.seconds(0)).done(ex3.fulfill)
waitForExpectations(timeout: 2, handler: nil)

#if !SWIFT_PACKAGE
Expand All @@ -20,11 +20,11 @@ class AfterTests: XCTestCase {

func testNegative() {
let ex2 = expectation(description: "")
after(seconds: -1).done({ ex2.fulfill() })
after(seconds: -1).done(ex2.fulfill)
waitForExpectations(timeout: 2, handler: nil)

let ex3 = expectation(description: "")
after(.seconds(-1)).done({ ex3.fulfill() })
after(.seconds(-1)).done(ex3.fulfill)
waitForExpectations(timeout: 2, handler: nil)

#if !SWIFT_PACKAGE
Expand All @@ -36,11 +36,11 @@ class AfterTests: XCTestCase {

func testPositive() {
let ex2 = expectation(description: "")
after(seconds: 1).done({ ex2.fulfill() })
after(seconds: 1).done(ex2.fulfill)
waitForExpectations(timeout: 2, handler: nil)

let ex3 = expectation(description: "")
after(.seconds(1)).done({ ex3.fulfill() })
after(.seconds(1)).done(ex3.fulfill)
waitForExpectations(timeout: 2, handler: nil)

#if !SWIFT_PACKAGE
Expand Down
6 changes: 3 additions & 3 deletions Tests/CorePromise/CatchableTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ extension CatchableTests {

func helper(error: Swift.Error) {
let ex = expectation(description: "")
Promise<Void>(error: error).recover { _ in }.done({ ex.fulfill() })
Promise<Void>(error: error).recover { _ in }.done(ex.fulfill)
wait(for: [ex], timeout: 10)
}

Expand All @@ -65,7 +65,7 @@ extension CatchableTests {

func test__void_specialized_full_recover__fulfilled_path() {
let ex = expectation(description: "")
Promise().recover { _ in XCTFail() }.done({ ex.fulfill() })
Promise().recover { _ in XCTFail() }.done(ex.fulfill)
wait(for: [ex], timeout: 10)
}

Expand All @@ -76,7 +76,7 @@ extension CatchableTests {
Promise<Void>(error: error).recover(policy: policy) { err in
guard x < 1 else { throw err }
x += 1
}.done({ ex.fulfill() }).silenceWarning()
}.done(ex.fulfill).silenceWarning()
wait(for: [ex], timeout: 10)
}

Expand Down
11 changes: 5 additions & 6 deletions Tests/CorePromise/ResolverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,13 @@ class WrapTests: XCTestCase {
let ex1 = expectation(description: "")
let kf1 = KittenFetcher(value: nil, error: nil)
Promise { seal in
kf1.fetchWithCompletionBlock4(block: { seal.resolve($0) })
}.done({ ex1.fulfill() }).silenceWarning()
kf1.fetchWithCompletionBlock4(block: seal.resolve)
}.done(ex1.fulfill).silenceWarning()

let ex2 = expectation(description: "")
let kf2 = KittenFetcher(value: nil, error: Error.test)
Promise { seal in
kf2.fetchWithCompletionBlock4(block: { seal.resolve($0) })
kf2.fetchWithCompletionBlock4(block: seal.resolve)
}.catch { _ in ex2.fulfill() }

wait(for: [ex1, ex2], timeout: 1)
Expand Down Expand Up @@ -182,8 +182,8 @@ class WrapTests: XCTestCase {
XCTAssertFalse(Promise<Int>(error: Error.test).result?.isFulfilled ?? true)
}

func testPendingPromiseDeallocated() throws {
#if !os(Android)
func testPendingPromiseDeallocated() {

// NOTE this doesn't seem to register the `deinit` as covered :(
// BUT putting a breakpoint in the deinit CLEARLY shows it getting covered…

Expand All @@ -203,7 +203,6 @@ class WrapTests: XCTestCase {
foo.ex = ex
}
wait(for: [ex], timeout: 10)
#endif
}

func testVoidResolverFulfillAmbiguity() {
Expand Down
2 changes: 1 addition & 1 deletion Tests/CorePromise/StressTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,5 @@ private func stressDataRace<T: Equatable>(expectation e1: XCTestExpectation, ite
}
}

group.notify(queue: queue, execute: { e1.fulfill() })
group.notify(queue: queue, execute: e1.fulfill)
}
2 changes: 1 addition & 1 deletion Tests/CorePromise/Utilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ extension Promise {
func silenceWarning() {}
}

#if os(Linux)
#if os(Linux) || os(Android)
import func CoreFoundation._CFIsMainThread

extension Thread {
Expand Down
6 changes: 3 additions & 3 deletions Tests/CorePromise/WhenTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class WhenTests: XCTestCase {
let p3 = Promise.value(3).done { _ in }
let p4 = Promise.value(4).done { _ in }

when(fulfilled: p1, p2, p3, p4).done({ e1.fulfill() }).silenceWarning()
when(fulfilled: p1, p2, p3, p4).done(e1.fulfill).silenceWarning()

waitForExpectations(timeout: 1, handler: nil)
}
Expand Down Expand Up @@ -244,8 +244,8 @@ class WhenTests: XCTestCase {
ex1.fulfill()
}

p2.ensure { after(.milliseconds(100)).done({ ex2.fulfill() }) }.silenceWarning()
p3.ensure { after(.milliseconds(100)).done({ ex3.fulfill() }) }.silenceWarning()
p2.ensure { after(.milliseconds(100)).done(ex2.fulfill) }.silenceWarning()
p3.ensure { after(.milliseconds(100)).done(ex3.fulfill) }.silenceWarning()

waitForExpectations(timeout: 1, handler: nil)
}
Expand Down

0 comments on commit 6d067d7

Please sign in to comment.