Skip to content

Commit ada7abd

Browse files
authored
Merge pull request #93 from eango/r79454450-add-swift-docc-integration-test
Add integration test for Swift-DocC
2 parents 5983543 + 598a785 commit ada7abd

File tree

8 files changed

+148
-2
lines changed

8 files changed

+148
-2
lines changed

lit.cfg

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ config.suffixes = [".txt", ".py", ".md", ".test"]
5858
# excludes: A list of directories to exclude from the testsuite. The 'Inputs'
5959
# subdirectories contain auxiliary inputs for various tests in their parent
6060
# directories.
61-
config.excludes = ['README.md', 'CONTRIBUTING.md', 'Inputs']
61+
config.excludes = ['README.md', 'CONTRIBUTING.md', 'Inputs', 'DocCTest.docc']
6262

6363
# test_source_root: The root path where tests are located.
6464
config.test_source_root = os.path.join(srcroot)
@@ -196,7 +196,12 @@ lit_config.note("testing using 'repl_swift': {}".format(repl_swift_dummy_path))
196196
sourcekit_lsp_path = lit_config.params.get(
197197
"sourcekit-lsp",
198198
os.path.join(package_path, "usr", "bin", "sourcekit-lsp"))
199-
199+
200+
docc_path = lit_config.params.get(
201+
"docc",
202+
os.path.join(package_path, "usr", "bin", "docc"))
203+
lit_config.note("testing using 'docc': {}".format(docc_path))
204+
200205
# Verify they exist.
201206
if not os.path.exists(swift_path):
202207
lit_config.fatal("swift does not exist!")
@@ -219,6 +224,9 @@ if os.path.exists(sourcekit_lsp_path):
219224
else:
220225
lit_config.note("'sourcekit-lsp' unavailable, skipping related tests")
221226

227+
if not os.path.exists(docc_path):
228+
lit_config.fatal("docc does not exist!")
229+
222230
# Define our supported substitutions.
223231
config.substitutions.append( ('%{package_path}', package_path) )
224232
config.substitutions.append( ('%{python}', sys.executable) )
@@ -231,6 +239,7 @@ config.substitutions.append( ('%{swiftc}', swiftc_path) )
231239
config.substitutions.append( ('%{FileCheck}', filecheck_path) )
232240
config.substitutions.append( ('%{readelf}', readelf_path) )
233241
config.substitutions.append( ('%{sourcekit-lsp}', sourcekit_lsp_path) )
242+
config.substitutions.append( ('%{docc}', docc_path) )
234243

235244
# Add substitutions for swiftpm executables.
236245
swiftpm_build = lit_config.params.get("swiftpm-build")
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// swift-tools-version:5.5
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "DocCTest",
8+
products: [
9+
// Products define the executables and libraries a package produces, and make them visible to other packages.
10+
.library(
11+
name: "DocCTest",
12+
targets: ["DocCTest"]),
13+
],
14+
dependencies: [
15+
// Dependencies declare other packages that this package depends on.
16+
// .package(url: /* package url */, from: "1.0.0"),
17+
],
18+
targets: [
19+
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
20+
// Targets can depend on other targets in this package, and on products in packages this package depends on.
21+
.target(
22+
name: "DocCTest",
23+
dependencies: []),
24+
.testTarget(
25+
name: "DocCTestTests",
26+
dependencies: ["DocCTest"]),
27+
]
28+
)

test-swift-docc/DocCTest/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# DocCTest
2+
3+
This is a minimal test package to verify Swift-DocC integration.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# ``DocCTest``
2+
3+
This is a summary
4+
5+
## Overview
6+
7+
This is an overview
8+
9+
## Topics
10+
11+
### This is a group
12+
13+
- <doc:DocCTest>
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CDDefaultCodeListingLanguage</key>
6+
<string>swift</string>
7+
<key>CFBundleName</key>
8+
<string>DocCTest</string>
9+
<key>CFBundleDisplayName</key>
10+
<string>DocCTest</string>
11+
<key>CFBundleIdentifier</key>
12+
<string>com.apple.DocCTest</string>
13+
<key>CFBundleDevelopmentRegion</key>
14+
<string>en</string>
15+
<key>CFBundleIconFile</key>
16+
<string>DocumentationIcon</string>
17+
<key>CFBundleIconName</key>
18+
<string>DocumentationIcon</string>
19+
<key>CFBundlePackageType</key>
20+
<string>DOCS</string>
21+
<key>CFBundleShortVersionString</key>
22+
<string>0.1.0</string>
23+
<key>CFBundleVersion</key>
24+
<string>0.1.0</string>
25+
<key>CDAppleDefaultAvailability</key>
26+
<dict>
27+
<key>DocCTest</key>
28+
<array>
29+
<dict>
30+
<key>name</key>
31+
<string>Mac Catalyst</string>
32+
<key>version</key>
33+
<string>13.0</string>
34+
</dict>
35+
<dict>
36+
<key>name</key>
37+
<string>iOS</string>
38+
<key>version</key>
39+
<string>13.0</string>
40+
</dict>
41+
<dict>
42+
<key>name</key>
43+
<string>tvOS</string>
44+
<key>version</key>
45+
<string>13.0</string>
46+
</dict>
47+
<dict>
48+
<key>name</key>
49+
<string>watchOS</string>
50+
<key>version</key>
51+
<string>6.0</string>
52+
</dict>
53+
<dict>
54+
<key>name</key>
55+
<string>macOS</string>
56+
<key>version</key>
57+
<string>10.15</string>
58+
</dict>
59+
</array>
60+
</dict>
61+
</dict>
62+
</plist>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
public struct DocCTest {
2+
public private(set) var text = "Hello, World!"
3+
4+
public var variable: Int
5+
6+
public init() {
7+
variable = 1
8+
}
9+
10+
/// This is foo
11+
/// - Returns: foo returns 0
12+
public func foo() -> Int {
13+
return 0
14+
}
15+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import XCTest
2+
@testable import DocCTest
3+
4+
final class DocCTestTests: XCTestCase {
5+
func testExample() throws {
6+
// This is an example of a functional test case.
7+
// Use XCTAssert and related functions to verify your tests produce the correct
8+
// results.
9+
XCTAssertEqual(DocCTest().text, "Hello, World!")
10+
}
11+
}

test-swift-docc/test-swift-docc.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Check Swift-DocC can compile and preview documentation.
2+
//
3+
// RNU: rm -rf %S/Output
4+
// RUN: %{docc} convert %S/DocCTest/Sources/DocCTest/DocCTest.docc --output-path %S/Output
5+
// RUN: ls %S/Output

0 commit comments

Comments
 (0)