|
2 | 2 | //
|
3 | 3 | // This source file is part of the Swift open source project
|
4 | 4 | //
|
5 |
| -// Copyright (c) 2014-2017 Apple Inc. and the Swift project authors |
| 5 | +// Copyright (c) 2014-2023 Apple Inc. and the Swift project authors |
6 | 6 | // Licensed under Apache License v2.0 with Runtime Library Exception
|
7 | 7 | //
|
8 | 8 | // See http://swift.org/LICENSE.txt for license information
|
@@ -149,6 +149,34 @@ class InitTests: XCTestCase {
|
149 | 149 | }
|
150 | 150 | }
|
151 | 151 |
|
| 152 | + func testInitPackageCommandPlugin() throws { |
| 153 | + try testWithTemporaryDirectory { tmpPath in |
| 154 | + let fs = localFileSystem |
| 155 | + let path = tmpPath.appending("MyCommandPlugin") |
| 156 | + let name = path.basename |
| 157 | + try fs.createDirectory(path) |
| 158 | + |
| 159 | + // Create the package |
| 160 | + try InitPackage( |
| 161 | + name: name, |
| 162 | + packageType: .commandPlugin, |
| 163 | + destinationPath: path, |
| 164 | + fileSystem: localFileSystem |
| 165 | + ).writePackageStructure() |
| 166 | + |
| 167 | + // Verify basic file system content that we expect in the package |
| 168 | + let manifest = path.appending("Package.swift") |
| 169 | + XCTAssertFileExists(manifest) |
| 170 | + let manifestContents: String = try localFileSystem.readFileContents(manifest) |
| 171 | + XCTAssertMatch(manifestContents, .and(.contains(".plugin("), .contains("capability: .command(intent: .custom(verb"))) |
| 172 | + |
| 173 | + let source = path.appending("Plugins", "MyCommandPlugin", "plugin.swift") |
| 174 | + XCTAssertFileExists(source) |
| 175 | + let sourceContents: String = try localFileSystem.readFileContents(source) |
| 176 | + XCTAssertMatch(sourceContents, .contains("struct MyCommandPlugin: CommandPlugin")) |
| 177 | + } |
| 178 | + } |
| 179 | + |
152 | 180 | // MARK: Special case testing
|
153 | 181 |
|
154 | 182 | func testInitPackageNonc99Directory() throws {
|
|
0 commit comments