Skip to content

Commit f43740c

Browse files
authored
Link Swift Testing documentation in its test template (#9368)
Link Swift Testing documentation in its test template ### Motivation: This hopefully makes it easier for new users to find relevant documentation for our test framework! It also matches the existing pattern where XCTest documentation is linked in its respective test template. ### Modifications: - Add a link to Swift Testing documentation in the test template. - Trims some trailing whitespace. Realistically, I don't have much control over this since my editor is respecting the project's .editorconfig's `trim_trailing_whitespace = true` directive. I can manually put them back if that would be better. ### Result: Default Swift Testing template will include a comment linking to the developer docs. Testing it locally: ``` ~/scraps/autogen/xx.ZtJsA ❯ /Users/jerrychen/workspace/opensource/swift-package-manager/.build/arm64-apple-macosx/debug/swift-package init Creating library package: xx.ZtJsA Creating Package.swift Creating .gitignore Creating Sources Creating Sources/xx.ZtJsA/xx_ZtJsA.swift Creating Tests/ Creating Tests/xx.ZtJsATests/ Creating Tests/xx.ZtJsATests/xx_ZtJsATests.swift ~/scraps/autogen/xx.ZtJsA ❯ /bin/cat Tests/xx.ZtJsATests/xx_ZtJsATests.swift import Testing @testable import xx_ZtJsA @test func example() async throws { // Write your test here and use APIs like `#expect(...)` to check expected conditions. // Swift Testing Documentation // https://developer.apple.com/documentation/testing } ```
1 parent f13f2a4 commit f43740c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Sources/Workspace/InitPackage.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ public final class InitPackage {
549549
func createBuildCommand(for inputPath: URL, in outputDirectoryPath: URL, with generatorToolPath: URL) -> Command? {
550550
// Skip any file that doesn't have the extension we're looking for (replace this with the actual one).
551551
guard inputPath.pathExtension == "my-input-suffix" else { return .none }
552-
552+
553553
// Return a command that will run during the build to generate the output file.
554554
let inputName = inputPath.lastPathComponent
555555
let outputName = inputPath.deletingPathExtension().lastPathComponent + ".swift"
@@ -644,7 +644,7 @@ public final class InitPackage {
644644
content = """
645645
// The Swift Programming Language
646646
// https://docs.swift.org/swift-book
647-
//
647+
//
648648
// Swift Argument Parser
649649
// https://swiftpackageindex.com/apple/swift-argument-parser/documentation
650650
@@ -731,6 +731,8 @@ public final class InitPackage {
731731
732732
@Test func example() async throws {
733733
// Write your test here and use APIs like `#expect(...)` to check expected conditions.
734+
// Swift Testing Documentation
735+
// https://swiftpackageindex.com/swiftlang/swift-testing/documentation
734736
}
735737
736738
"""

0 commit comments

Comments
 (0)