Skip to content

Commit

Permalink
Attempt linux test
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmassicotte committed Sep 22, 2023
1 parent e457e1b commit 9bdb57b
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 2 deletions.
20 changes: 18 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ on:
paths-ignore:
- 'README.md'
- 'CODE_OF_CONDUCT.md'
- '.editorconfig'
- '.spi.yml'
pull_request:
branches:
- main


env:
DEVELOPER_DIR: /Applications/Xcode_15.0.app/Contents/Developer

Expand All @@ -27,5 +28,20 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Install XCBeautify
run: brew install xcbeautify
- name: Test platform ${{ matrix.destination }}
run: set -o pipefail && xcodebuild -scheme Queue -destination "${{ matrix.destination }}" test | xcpretty
run: set -o pipefail && xcodebuild -scheme Queue -destination "${{ matrix.destination }}" test | xcbeautify --renderer github-actions

linux_test:
name: Test Linux
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install swiftly
run: curl -L https://swift-server.github.io/swiftly/swiftly-install.sh | bash -s -- -y
- name: Install the latest Swift toolchain
run: swiftly install latest
- name: Test
run: swift test
38 changes: 38 additions & 0 deletions Tests/QueueTests/XCTest+Fulfillment.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// see https://github.com/apple/swift-corelibs-xctest/issues/436

import Foundation

#if os(Linux)
import XCTest

extension XCTestCase {
/// Wait on an array of expectations for up to the specified timeout, and optionally specify whether they
/// must be fulfilled in the given order. May return early based on fulfillment of the waited on expectations.
///
/// - Parameter expectations: The expectations to wait on.
/// - Parameter timeout: The maximum total time duration to wait on all expectations.
/// - Parameter enforceOrder: Specifies whether the expectations must be fulfilled in the order
/// they are specified in the `expectations` Array. Default is false.
/// - Parameter file: The file name to use in the error message if
/// expectations are not fulfilled before the given timeout. Default is the file
/// containing the call to this method. It is rare to provide this
/// parameter when calling this method.
/// - Parameter line: The line number to use in the error message if the
/// expectations are not fulfilled before the given timeout. Default is the line
/// number of the call to this method in the calling file. It is rare to
/// provide this parameter when calling this method.
///
/// - SeeAlso: XCTWaiter
func fulfillment(of expectations: [XCTestExpectation], timeout: TimeInterval, enforceOrder: Bool = false) async {
return await withCheckedContinuation { continuation in
// This function operates by blocking a background thread instead of one owned by libdispatch or by the
// Swift runtime (as used by Swift concurrency.) To ensure we use a thread owned by neither subsystem, use
// Foundation's Thread.detachNewThread(_:).
Thread.detachNewThread { [self] in
wait(for: expectations, timeout: timeout, enforceOrder: enforceOrder)
continuation.resume()
}
}
}
}
#endif

0 comments on commit 9bdb57b

Please sign in to comment.