Support having multiple files in framework tests
This commit is contained in:
committed by
SvyatoslavScherbina
parent
09be2b2cbf
commit
3b27cb512c
@@ -11,7 +11,7 @@ func testGh3343() throws {
|
||||
|
||||
// -------- Execution of the test --------
|
||||
|
||||
class Gh3343Tests : TestProvider {
|
||||
class UselibTests : TestProvider {
|
||||
var tests: [TestCase] = []
|
||||
|
||||
init() {
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user