Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tooling to verify that all tests run on Linux (#9)
Add tooling to verify that all tests run on Linux Since the Swift Package Manager requires all tests to be manually declared on Linux, add a test that runs on macOS that identifies all tests using the Objective-C-based APIs, and then asserts that all of those tests have been declared on Linux.
- Loading branch information
1 parent
cfe1528
commit e2f76b1
Showing
13 changed files
with
76 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* Ink | ||
* Copyright (c) John Sundell 2019 | ||
* MIT license, see LICENSE file for details | ||
*/ | ||
|
||
import XCTest | ||
|
||
public enum Linux {} | ||
|
||
public extension Linux { | ||
typealias TestCase = (testCaseClass: XCTestCase.Type, allTests: TestManifest) | ||
typealias TestManifest = [(String, TestRunner)] | ||
typealias TestRunner = (XCTestCase) throws -> Void | ||
typealias TestList<T: XCTestCase> = [(String, Test<T>)] | ||
typealias Test<T: XCTestCase> = (T) -> () throws -> Void | ||
} | ||
|
||
internal extension Linux { | ||
static func makeTestCase<T: XCTestCase>(using list: TestList<T>) -> TestCase { | ||
let manifest: TestManifest = list.map { name, function in | ||
(name, { type in | ||
try function(type as! T)() | ||
}) | ||
} | ||
|
||
return (T.self, manifest) | ||
} | ||
} | ||
|
||
#if canImport(ObjectiveC) | ||
internal final class LinuxVerificationTests: XCTestCase { | ||
func testAllTestsRunOnLinux() { | ||
for testCase in allTests() { | ||
let type = testCase.testCaseClass | ||
|
||
let testNames: [String] = type.defaultTestSuite.tests.map { test in | ||
let components = test.name.components(separatedBy: .whitespaces) | ||
return components[1].replacingOccurrences(of: "]", with: "") | ||
} | ||
|
||
let linuxTestNames = Set(testCase.allTests.map { $0.0 }) | ||
|
||
for name in testNames { | ||
if !linuxTestNames.contains(name) { | ||
XCTFail(""" | ||
\(type).\(name) does not run on Linux. | ||
Please add it to \(type).allTests. | ||
""") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters