Skip to content

[swift-build] update swift build --init library tests format #214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 2, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions Sources/swift-build/initPackage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ final class InitPackage {
}
print("Creating Tests/LinuxMain.swift")
try fputs("import XCTest\n", linuxMainFP)
try fputs("@testable import \(pkgname)test\n\n", linuxMainFP)
try fputs("@testable import \(pkgname)TestSuite\n\n", linuxMainFP)
try fputs("XCTMain([\n", linuxMainFP)
try fputs("\t\(pkgname)(),\n", linuxMainFP)
try fputs("\t testCase(\(pkgname)Tests.allTests),\n", linuxMainFP)
try fputs("])\n", linuxMainFP)
}

Expand All @@ -133,16 +133,16 @@ final class InitPackage {
print("Creating Tests/\(pkgname)/")
try mkdir(testModule)

let testsFile = Path.join(testModule, "\(pkgname).swift")
print("Creating Tests/\(pkgname)/\(pkgname).swift")
let testsFile = Path.join(testModule, "\(pkgname)Tests.swift")
print("Creating Tests/\(pkgname)/\(pkgname)Tests.swift")
let testsFileFP = try fopen(testsFile, mode: .Write)
defer {
fclose(testsFileFP)
}
try fputs("import XCTest\n", testsFileFP)
try fputs("@testable import \(pkgname)\n\n", testsFileFP)

try fputs("class \(pkgname): XCTestCase {\n\n", testsFileFP)
try fputs("class \(pkgname)Tests: XCTestCase {\n\n", testsFileFP)

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

try fputs("}\n", testsFileFP)

try fputs("\n#if os(Linux)\n", testsFileFP)
try fputs("extension \(pkgname): XCTestCaseProvider {\n", testsFileFP)
try fputs("\tvar allTests : [(String, () throws -> Void)] {\n", testsFileFP)
try fputs("extension \(pkgname)Tests {\n", testsFileFP)
try fputs("\tstatic var allTests : [(String, \(pkgname)Tests -> () throws -> Void)] {\n", testsFileFP)
try fputs("\t\treturn [\n", testsFileFP)
try fputs("\t\t\t(\"testExample\", testExample),\n", testsFileFP)
try fputs("\t\t]\n", testsFileFP)
try fputs("\t}\n", testsFileFP)
try fputs("}\n", testsFileFP)
try fputs("#endif\n", testsFileFP)
}
}