Support having multiple files in framework tests

This commit is contained in:
Svyatoslav Scherbina
2020-02-21 14:26:32 +03:00
committed by SvyatoslavScherbina
parent 09be2b2cbf
commit 3b27cb512c
5 changed files with 16 additions and 10 deletions
@@ -11,7 +11,7 @@ func testGh3343() throws {
// -------- Execution of the test --------
class Gh3343Tests : TestProvider {
class UselibTests : TestProvider {
var tests: [TestCase] = []
init() {
+5 -2
View File
@@ -132,12 +132,15 @@ private func execute(tests: [TestCase]) {
* Entry point of the test
*/
private func main() {
// Generated method that instantiates TestProvider
registerProvider()
// Generated method that instantiates test providers.
registerProviders()
let stats = Statistics.getInstance()
for pr in providers {
let name = String(describing: type(of: pr))
print("-- \(name) started")
execute(tests: pr.tests)
print("-- \(name) finished")
}
print(stats)
@@ -50,7 +50,7 @@ func testIsolation3() throws {
#endif
}
class MultipleFrameworksTests : TestProvider {
class MultipleTests : TestProvider {
var tests: [TestCase] = []
init() {
@@ -275,7 +275,7 @@ func testGenericExtensions() throws {
// -------- Execution of the test --------
class ValuesGenericsTests : TestProvider {
class ValuesTests : TestProvider {
var tests: [TestCase] = []
init() {
@@ -80,13 +80,16 @@ open class FrameworkTest : DefaultTask(), KonanTestExecutable {
// create a test provider and get main entry point
val provider = Paths.get(testOutput, testName, "provider.swift")
FileWriter(provider.toFile()).use {
it.write("""
FileWriter(provider.toFile()).use { writer ->
val providers = swiftSources
.map { Paths.get(it).fileName.toString().removeSuffix(".swift").capitalize() }
.map { "${it}Tests" }
writer.write("""
|// THIS IS AUTOGENERATED FILE
|// This method is invoked by the main routine to get a list of tests
|func registerProvider() {
| // TODO: assuming this naming for now
| ${testName}Tests()
|func registerProviders() {
| ${providers.joinToString("\n ") { "$it()" }}
|}
""".trimMargin())
}