Skip to content

Commit f57a878

Browse files
committed
Merge pull request #214 from kostiakoval/init-lib-tests
[swift-build] update `swift build --init library` tests format
2 parents fcb9fe2 + 3c5683a commit f57a878

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

Sources/swift-build/initPackage.swift

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ final class InitPackage {
121121
}
122122
print("Creating Tests/LinuxMain.swift")
123123
try fputs("import XCTest\n", linuxMainFP)
124-
try fputs("@testable import \(pkgname)test\n\n", linuxMainFP)
124+
try fputs("@testable import \(pkgname)TestSuite\n\n", linuxMainFP)
125125
try fputs("XCTMain([\n", linuxMainFP)
126-
try fputs("\t\(pkgname)(),\n", linuxMainFP)
126+
try fputs("\t testCase(\(pkgname)Tests.allTests),\n", linuxMainFP)
127127
try fputs("])\n", linuxMainFP)
128128
}
129129

@@ -132,16 +132,16 @@ final class InitPackage {
132132
print("Creating Tests/\(pkgname)/")
133133
try mkdir(testModule)
134134

135-
let testsFile = Path.join(testModule, "\(pkgname).swift")
136-
print("Creating Tests/\(pkgname)/\(pkgname).swift")
135+
let testsFile = Path.join(testModule, "\(pkgname)Tests.swift")
136+
print("Creating Tests/\(pkgname)/\(pkgname)Tests.swift")
137137
let testsFileFP = try fopen(testsFile, mode: .Write)
138138
defer {
139139
fclose(testsFileFP)
140140
}
141141
try fputs("import XCTest\n", testsFileFP)
142142
try fputs("@testable import \(pkgname)\n\n", testsFileFP)
143143

144-
try fputs("class \(pkgname): XCTestCase {\n\n", testsFileFP)
144+
try fputs("class \(pkgname)Tests: XCTestCase {\n\n", testsFileFP)
145145

146146
try fputs("\tfunc testExample() {\n", testsFileFP)
147147
try fputs("\t\t// This is an example of a functional test case.\n", testsFileFP)
@@ -150,14 +150,12 @@ final class InitPackage {
150150

151151
try fputs("}\n", testsFileFP)
152152

153-
try fputs("\n#if os(Linux)\n", testsFileFP)
154-
try fputs("extension \(pkgname): XCTestCaseProvider {\n", testsFileFP)
155-
try fputs("\tvar allTests : [(String, () throws -> Void)] {\n", testsFileFP)
153+
try fputs("extension \(pkgname)Tests {\n", testsFileFP)
154+
try fputs("\tstatic var allTests : [(String, \(pkgname)Tests -> () throws -> Void)] {\n", testsFileFP)
156155
try fputs("\t\treturn [\n", testsFileFP)
157156
try fputs("\t\t\t(\"testExample\", testExample),\n", testsFileFP)
158157
try fputs("\t\t]\n", testsFileFP)
159158
try fputs("\t}\n", testsFileFP)
160159
try fputs("}\n", testsFileFP)
161-
try fputs("#endif\n", testsFileFP)
162160
}
163161
}

0 commit comments

Comments
 (0)