Skip to content

Commit 0c11fea

Browse files
authored
Merge pull request #252 from jrflat/release-mode-testing
Support testing in release mode
2 parents 2410aed + 9ec41a6 commit 0c11fea

File tree

5 files changed

+16
-2
lines changed

5 files changed

+16
-2
lines changed

Tests/SystemTests/FileOperationsTest.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import CSystem
2222

2323
@available(System 0.0.1, *)
2424
final class FileOperationsTest: XCTestCase {
25-
#if !os(WASI) // Would need to use _getConst funcs from CSystem
25+
#if ENABLE_MOCKING && !os(WASI) // Would need to use _getConst funcs from CSystem
2626
func testSyscalls() {
2727
let fd = FileDescriptor(rawValue: 1)
2828

@@ -91,7 +91,7 @@ final class FileOperationsTest: XCTestCase {
9191

9292
for test in syscallTestCases { test.runAllTests() }
9393
}
94-
#endif // !os(WASI)
94+
#endif // ENABLE_MOCKING && !os(WASI)
9595

9696
func testWriteFromEmptyBuffer() throws {
9797
#if os(Windows)
@@ -215,6 +215,7 @@ final class FileOperationsTest: XCTestCase {
215215
}
216216
}
217217

218+
#if ENABLE_MOCKING
218219
func testGithubIssues() {
219220
// https://github.com/apple/swift-system/issues/26
220221
#if os(WASI)
@@ -233,6 +234,7 @@ final class FileOperationsTest: XCTestCase {
233234
}
234235
issue26.runAllTests()
235236
}
237+
#endif // ENABLE_MOCKING
236238

237239
func testResizeFile() throws {
238240
try withTemporaryFilePath(basename: "testResizeFile") { path in

Tests/SystemTests/FilePathTests/FilePathParsingTest.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
See https://swift.org/LICENSE.txt for license information
88
*/
99

10+
#if ENABLE_MOCKING
1011
import XCTest
1112

1213
#if SYSTEM_PACKAGE
@@ -105,3 +106,4 @@ final class FilePathParsingTest: XCTestCase {
105106
}
106107
}
107108
}
109+
#endif // ENABLE_MOCKING

Tests/SystemTests/FilePathTests/FilePathSyntaxTest.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
See https://swift.org/LICENSE.txt for license information
88
*/
99

10+
#if ENABLE_MOCKING
1011
import XCTest
1112

1213
#if SYSTEM_PACKAGE
@@ -1238,3 +1239,4 @@ final class FilePathSyntaxTest: XCTestCase {
12381239
}
12391240

12401241
}
1242+
#endif // ENABLE_MOCKING

Tests/SystemTests/MockingTest.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
See https://swift.org/LICENSE.txt for license information
88
*/
99

10+
#if ENABLE_MOCKING
1011
import XCTest
1112

1213
#if SYSTEM_PACKAGE
@@ -48,3 +49,4 @@ final class MockingTest: XCTestCase {
4849
XCTAssertFalse(mockingEnabled)
4950
}
5051
}
52+
#endif // ENABLE_MOCKING

Tests/SystemTests/TestingInfrastructure.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import XCTest
1717

1818
internal struct Wildcard: Hashable {}
1919

20+
#if ENABLE_MOCKING
2021
extension Trace.Entry {
2122
/// This implements `==` with wildcard matching.
2223
/// (`Entry` cannot conform to `Equatable`/`Hashable` this way because
@@ -33,6 +34,7 @@ extension Trace.Entry {
3334
return true
3435
}
3536
}
37+
#endif // ENABLE_MOCKING
3638

3739
// To aid debugging, force failures to fatal error
3840
internal var forceFatalFailures = false
@@ -81,6 +83,7 @@ extension TestCase {
8183
fail(message)
8284
}
8385
}
86+
#if ENABLE_MOCKING
8487
func expectMatch(
8588
_ expected: Trace.Entry?, _ actual: Trace.Entry?,
8689
_ message: String? = nil
@@ -102,6 +105,7 @@ extension TestCase {
102105
fail(message)
103106
}
104107
}
108+
#endif // ENABLE_MOCKING
105109
func expectNil<T>(
106110
_ actual: T?,
107111
_ message: String? = nil
@@ -142,6 +146,7 @@ extension TestCase {
142146

143147
}
144148

149+
#if ENABLE_MOCKING
145150
internal struct MockTestCase: TestCase {
146151
var file: StaticString
147152
var line: UInt
@@ -241,6 +246,7 @@ internal struct MockTestCase: TestCase {
241246
}
242247
}
243248
}
249+
#endif // ENABLE_MOCKING
244250

245251
internal func withWindowsPaths(enabled: Bool, _ body: () -> ()) {
246252
_withWindowsPaths(enabled: enabled, body)

0 commit comments

Comments
 (0)