diff --git a/lit.cfg b/lit.cfg index 1e17a51..f727d6e 100644 --- a/lit.cfg +++ b/lit.cfg @@ -58,7 +58,7 @@ config.suffixes = [".txt", ".py", ".md", ".test"] # excludes: A list of directories to exclude from the testsuite. The 'Inputs' # subdirectories contain auxiliary inputs for various tests in their parent # directories. -config.excludes = ['README.md', 'CONTRIBUTING.md', 'Inputs'] +config.excludes = ['README.md', 'CONTRIBUTING.md', 'Inputs', 'DocCTest.docc'] # test_source_root: The root path where tests are located. config.test_source_root = os.path.join(srcroot) @@ -196,7 +196,12 @@ lit_config.note("testing using 'repl_swift': {}".format(repl_swift_dummy_path)) sourcekit_lsp_path = lit_config.params.get( "sourcekit-lsp", os.path.join(package_path, "usr", "bin", "sourcekit-lsp")) - + +docc_path = lit_config.params.get( + "docc", + os.path.join(package_path, "usr", "bin", "docc")) +lit_config.note("testing using 'docc': {}".format(docc_path)) + # Verify they exist. if not os.path.exists(swift_path): lit_config.fatal("swift does not exist!") @@ -219,6 +224,9 @@ if os.path.exists(sourcekit_lsp_path): else: lit_config.note("'sourcekit-lsp' unavailable, skipping related tests") +if not os.path.exists(docc_path): + lit_config.fatal("docc does not exist!") + # Define our supported substitutions. config.substitutions.append( ('%{package_path}', package_path) ) config.substitutions.append( ('%{python}', sys.executable) ) @@ -231,6 +239,7 @@ config.substitutions.append( ('%{swiftc}', swiftc_path) ) config.substitutions.append( ('%{FileCheck}', filecheck_path) ) config.substitutions.append( ('%{readelf}', readelf_path) ) config.substitutions.append( ('%{sourcekit-lsp}', sourcekit_lsp_path) ) +config.substitutions.append( ('%{docc}', docc_path) ) # Add substitutions for swiftpm executables. swiftpm_build = lit_config.params.get("swiftpm-build") diff --git a/test-swift-docc/DocCTest/Package.swift b/test-swift-docc/DocCTest/Package.swift new file mode 100644 index 0000000..26a5c5d --- /dev/null +++ b/test-swift-docc/DocCTest/Package.swift @@ -0,0 +1,28 @@ +// swift-tools-version:5.5 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "DocCTest", + products: [ + // Products define the executables and libraries a package produces, and make them visible to other packages. + .library( + name: "DocCTest", + targets: ["DocCTest"]), + ], + dependencies: [ + // Dependencies declare other packages that this package depends on. + // .package(url: /* package url */, from: "1.0.0"), + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages this package depends on. + .target( + name: "DocCTest", + dependencies: []), + .testTarget( + name: "DocCTestTests", + dependencies: ["DocCTest"]), + ] +) diff --git a/test-swift-docc/DocCTest/README.md b/test-swift-docc/DocCTest/README.md new file mode 100644 index 0000000..415c290 --- /dev/null +++ b/test-swift-docc/DocCTest/README.md @@ -0,0 +1,3 @@ +# DocCTest + +This is a minimal test package to verify Swift-DocC integration. diff --git a/test-swift-docc/DocCTest/Sources/DocCTest/DocCTest.docc/Documentation.md b/test-swift-docc/DocCTest/Sources/DocCTest/DocCTest.docc/Documentation.md new file mode 100644 index 0000000..e4deff4 --- /dev/null +++ b/test-swift-docc/DocCTest/Sources/DocCTest/DocCTest.docc/Documentation.md @@ -0,0 +1,13 @@ +# ``DocCTest`` + +This is a summary + +## Overview + +This is an overview + +## Topics + +### This is a group + +- diff --git a/test-swift-docc/DocCTest/Sources/DocCTest/DocCTest.docc/Info.plist b/test-swift-docc/DocCTest/Sources/DocCTest/DocCTest.docc/Info.plist new file mode 100644 index 0000000..fbc0d75 --- /dev/null +++ b/test-swift-docc/DocCTest/Sources/DocCTest/DocCTest.docc/Info.plist @@ -0,0 +1,62 @@ + + + + + CDDefaultCodeListingLanguage + swift + CFBundleName + DocCTest + CFBundleDisplayName + DocCTest + CFBundleIdentifier + com.apple.DocCTest + CFBundleDevelopmentRegion + en + CFBundleIconFile + DocumentationIcon + CFBundleIconName + DocumentationIcon + CFBundlePackageType + DOCS + CFBundleShortVersionString + 0.1.0 + CFBundleVersion + 0.1.0 + CDAppleDefaultAvailability + + DocCTest + + + name + Mac Catalyst + version + 13.0 + + + name + iOS + version + 13.0 + + + name + tvOS + version + 13.0 + + + name + watchOS + version + 6.0 + + + name + macOS + version + 10.15 + + + + + diff --git a/test-swift-docc/DocCTest/Sources/DocCTest/DocCTest.swift b/test-swift-docc/DocCTest/Sources/DocCTest/DocCTest.swift new file mode 100644 index 0000000..ad630b2 --- /dev/null +++ b/test-swift-docc/DocCTest/Sources/DocCTest/DocCTest.swift @@ -0,0 +1,15 @@ +public struct DocCTest { + public private(set) var text = "Hello, World!" + + public var variable: Int + + public init() { + variable = 1 + } + + /// This is foo + /// - Returns: foo returns 0 + public func foo() -> Int { + return 0 + } +} diff --git a/test-swift-docc/DocCTest/Tests/DocCTestTests/DocCTestTests.swift b/test-swift-docc/DocCTest/Tests/DocCTestTests/DocCTestTests.swift new file mode 100644 index 0000000..cff0254 --- /dev/null +++ b/test-swift-docc/DocCTest/Tests/DocCTestTests/DocCTestTests.swift @@ -0,0 +1,11 @@ +import XCTest +@testable import DocCTest + +final class DocCTestTests: XCTestCase { + func testExample() throws { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct + // results. + XCTAssertEqual(DocCTest().text, "Hello, World!") + } +} diff --git a/test-swift-docc/test-swift-docc.txt b/test-swift-docc/test-swift-docc.txt new file mode 100644 index 0000000..59548b0 --- /dev/null +++ b/test-swift-docc/test-swift-docc.txt @@ -0,0 +1,5 @@ +// Check Swift-DocC can compile and preview documentation. +// +// RNU: rm -rf %S/Output +// RUN: %{docc} convert %S/DocCTest/Sources/DocCTest/DocCTest.docc --output-path %S/Output +// RUN: ls %S/Output