Skip to content

Commit

Permalink
Fix Linux build
Browse files Browse the repository at this point in the history
Add necessary compile time checks for linux build and tests to succeed.
p4checo committed Jan 11, 2023
1 parent ec77158 commit f7c9949
Showing 6 changed files with 20 additions and 11 deletions.
13 changes: 8 additions & 5 deletions Sources/Dependencies/Internal/RuntimeWarnings.swift
Original file line number Diff line number Diff line change
@@ -11,11 +11,14 @@ func runtimeWarn(
let message = message()
let category = category ?? "Runtime Warning"
if _XCTIsTesting {
if let file = file, let line = line {
XCTFail(message, file: file, line: line)
} else {
XCTFail(message)
}
// `XCTExpectFailure` is not supported on Linux
#if !os(Linux)
if let file = file, let line = line {
XCTFail(message, file: file, line: line)
} else {
XCTFail(message)
}
#endif
} else {
#if canImport(os)
os_log(
3 changes: 2 additions & 1 deletion Tests/ComposableArchitectureTests/ForEachReducerTests.swift
Original file line number Diff line number Diff line change
@@ -35,7 +35,8 @@ final class ForEachReducerTests: XCTestCase {
await store.send(.buttonTapped)
}

#if DEBUG
// `XCTExpectFailure` is not supported on Linux
#if DEBUG && !os(Linux)
func testMissingElement() async {
let store = TestStore(
initialState: Elements.State(),
Original file line number Diff line number Diff line change
@@ -31,7 +31,8 @@ final class IfCaseLetReducerTests: XCTestCase {
}
}

#if DEBUG
// `XCTExpectFailure` is not supported on Linux
#if DEBUG && !os(Linux)
func testNilChild() async {
struct SomeError: Error, Equatable {}

3 changes: 2 additions & 1 deletion Tests/ComposableArchitectureTests/IfLetReducerTests.swift
Original file line number Diff line number Diff line change
@@ -3,7 +3,8 @@ import XCTest

@MainActor
final class IfLetReducerTests: XCTestCase {
#if DEBUG
// `XCTExpectFailure` is not supported on Linux
#if DEBUG && !os(Linux)
func testNilChild() async {
let store = TestStore(
initialState: Int?.none,
3 changes: 2 additions & 1 deletion Tests/ComposableArchitectureTests/ScopeTests.swift
Original file line number Diff line number Diff line change
@@ -40,7 +40,8 @@ final class ScopeTests: XCTestCase {
}
}

#if DEBUG
// `XCTExpectFailure` is not supported on Linux
#if DEBUG && !os(Linux)
func testNilChild() async {
let store = TestStore(
initialState: Child2.State.count(0),
6 changes: 4 additions & 2 deletions Tests/DependenciesTests/DependencyValuesTests.swift
Original file line number Diff line number Diff line change
@@ -93,7 +93,8 @@ final class DependencyValuesTests: XCTestCase {
XCTAssertEqual(reuseClient.count(), 42)

DependencyValues.withValue(\.context, .live) {
#if DEBUG
// `XCTExpectFailure` is not supported on Linux
#if DEBUG && !os(Linux)
XCTExpectFailure {
$0.compactDescription.contains(
"""
@@ -124,7 +125,8 @@ final class DependencyValuesTests: XCTestCase {
XCTAssertEqual($0.reuseClient.count(), 0)
XCTAssertEqual(reuseClient.count(), 0)
} operation: {
#if DEBUG
// `XCTExpectFailure` is not supported on Linux
#if DEBUG && !os(Linux)
XCTExpectFailure {
$0.compactDescription.contains(
"""

0 comments on commit f7c9949

Please sign in to comment.