1010
1111import Foundation
1212import XCTest
13- @testable @ _spi ( FileManagerProtocol ) import SwiftDocC
13+ @testable import SwiftDocC
1414
1515/// A Data provider and file manager that accepts pre-built documentation bundles with files on the local filesystem.
1616///
@@ -40,14 +40,13 @@ import XCTest
4040///
4141/// - Note: This class is thread-safe by using a naive locking for each access to the files dictionary.
4242/// - Warning: Use this type for unit testing.
43- @_spi ( FileManagerProtocol) // This needs to be SPI because it conforms to an SPI protocol
44- public class TestFileSystem : FileManagerProtocol , DocumentationWorkspaceDataProvider {
45- public let currentDirectoryPath = " / "
43+ package class TestFileSystem : FileManagerProtocol , DocumentationWorkspaceDataProvider {
44+ package let currentDirectoryPath = " / "
4645
47- public var identifier : String = UUID ( ) . uuidString
46+ package var identifier : String = UUID ( ) . uuidString
4847
4948 private var _bundles = [ DocumentationBundle] ( )
50- public func bundles( options: BundleDiscoveryOptions ) throws -> [ DocumentationBundle ] {
49+ package func bundles( options: BundleDiscoveryOptions ) throws -> [ DocumentationBundle ] {
5150 // Ignore the bundle discovery options, these test bundles are already built.
5251 return _bundles
5352 }
@@ -65,7 +64,7 @@ public class TestFileSystem: FileManagerProtocol, DocumentationWorkspaceDataProv
6564 /// A data fixture to use in the `files` index to mark folders.
6665 static let folderFixtureData = " Folder " . data ( using: . utf8) !
6766
68- public convenience init ( folders: [ Folder ] ) throws {
67+ package convenience init ( folders: [ Folder ] ) throws {
6968 self . init ( )
7069
7170 // Default system paths
@@ -117,7 +116,7 @@ public class TestFileSystem: FileManagerProtocol, DocumentationWorkspaceDataProv
117116 }
118117 }
119118
120- public func contentsOfURL( _ url: URL ) throws -> Data {
119+ package func contentsOfURL( _ url: URL ) throws -> Data {
121120 filesLock. lock ( )
122121 defer { filesLock. unlock ( ) }
123122
@@ -127,7 +126,7 @@ public class TestFileSystem: FileManagerProtocol, DocumentationWorkspaceDataProv
127126 return file
128127 }
129128
130- public func contents( of url: URL ) throws -> Data {
129+ package func contents( of url: URL ) throws -> Data {
131130 try contentsOfURL ( url)
132131 }
133132
@@ -166,7 +165,7 @@ public class TestFileSystem: FileManagerProtocol, DocumentationWorkspaceDataProv
166165 return Array ( fileList. keys)
167166 }
168167
169- public func fileExists( atPath path: String , isDirectory: UnsafeMutablePointer < ObjCBool > ? ) -> Bool {
168+ package func fileExists( atPath path: String , isDirectory: UnsafeMutablePointer < ObjCBool > ? ) -> Bool {
170169 filesLock. lock ( )
171170 defer { filesLock. unlock ( ) }
172171
@@ -179,14 +178,14 @@ public class TestFileSystem: FileManagerProtocol, DocumentationWorkspaceDataProv
179178 return true
180179 }
181180
182- public func fileExists( atPath path: String ) -> Bool {
181+ package func fileExists( atPath path: String ) -> Bool {
183182 filesLock. lock ( )
184183 defer { filesLock. unlock ( ) }
185184
186185 return files. keys. contains ( path)
187186 }
188187
189- public func copyItem( at srcURL: URL , to dstURL: URL ) throws {
188+ package func copyItem( at srcURL: URL , to dstURL: URL ) throws {
190189 guard !disableWriting else { return }
191190
192191 filesLock. lock ( )
@@ -203,7 +202,7 @@ public class TestFileSystem: FileManagerProtocol, DocumentationWorkspaceDataProv
203202 }
204203 }
205204
206- public func moveItem( at srcURL: URL , to dstURL: URL ) throws {
205+ package func moveItem( at srcURL: URL , to dstURL: URL ) throws {
207206 guard !disableWriting else { return }
208207
209208 filesLock. lock ( )
@@ -240,7 +239,7 @@ public class TestFileSystem: FileManagerProtocol, DocumentationWorkspaceDataProv
240239 files [ path] = Self . folderFixtureData
241240 }
242241
243- public func createDirectory( at url: URL , withIntermediateDirectories createIntermediates: Bool , attributes: [ FileAttributeKey : Any ] ? = nil ) throws {
242+ package func createDirectory( at url: URL , withIntermediateDirectories createIntermediates: Bool , attributes: [ FileAttributeKey : Any ] ? = nil ) throws {
244243 guard !disableWriting else { return }
245244
246245 filesLock. lock ( )
@@ -249,14 +248,14 @@ public class TestFileSystem: FileManagerProtocol, DocumentationWorkspaceDataProv
249248 try createDirectory ( atPath: url. path, withIntermediateDirectories: createIntermediates)
250249 }
251250
252- public func contentsEqual( atPath path1: String , andPath path2: String ) -> Bool {
251+ package func contentsEqual( atPath path1: String , andPath path2: String ) -> Bool {
253252 filesLock. lock ( )
254253 defer { filesLock. unlock ( ) }
255254
256255 return files [ path1] == files [ path2]
257256 }
258257
259- public func removeItem( at: URL ) throws {
258+ package func removeItem( at: URL ) throws {
260259 guard !disableWriting else { return }
261260
262261 filesLock. lock ( )
@@ -268,7 +267,7 @@ public class TestFileSystem: FileManagerProtocol, DocumentationWorkspaceDataProv
268267 }
269268 }
270269
271- public func createFile( at url: URL , contents: Data ) throws {
270+ package func createFile( at url: URL , contents: Data ) throws {
272271 filesLock. lock ( )
273272 defer { filesLock. unlock ( ) }
274273
@@ -279,18 +278,18 @@ public class TestFileSystem: FileManagerProtocol, DocumentationWorkspaceDataProv
279278 }
280279 }
281280
282- public func createFile( at url: URL , contents: Data , options: NSData . WritingOptions ? ) throws {
281+ package func createFile( at url: URL , contents: Data , options: NSData . WritingOptions ? ) throws {
283282 try createFile ( at: url, contents: contents)
284283 }
285284
286- public func contents( atPath: String ) -> Data ? {
285+ package func contents( atPath: String ) -> Data ? {
287286 filesLock. lock ( )
288287 defer { filesLock. unlock ( ) }
289288
290289 return files [ atPath]
291290 }
292291
293- public func contentsOfDirectory( atPath path: String ) throws -> [ String ] {
292+ package func contentsOfDirectory( atPath path: String ) throws -> [ String ] {
294293 filesLock. lock ( )
295294 defer { filesLock. unlock ( ) }
296295
@@ -309,7 +308,7 @@ public class TestFileSystem: FileManagerProtocol, DocumentationWorkspaceDataProv
309308 return Array ( results)
310309 }
311310
312- public func contentsOfDirectory( at url: URL , includingPropertiesForKeys keys: [ URLResourceKey ] ? , options mask: FileManager . DirectoryEnumerationOptions ) throws -> [ URL ] {
311+ package func contentsOfDirectory( at url: URL , includingPropertiesForKeys keys: [ URLResourceKey ] ? , options mask: FileManager . DirectoryEnumerationOptions ) throws -> [ URL ] {
313312
314313 if let keys {
315314 XCTAssertTrue ( keys. isEmpty, " includingPropertiesForKeys is not implemented in contentsOfDirectory in TestFileSystem " )
@@ -328,7 +327,7 @@ public class TestFileSystem: FileManagerProtocol, DocumentationWorkspaceDataProv
328327 return output
329328 }
330329
331- public func uniqueTemporaryDirectory( ) -> URL {
330+ package func uniqueTemporaryDirectory( ) -> URL {
332331 URL ( fileURLWithPath: " /tmp/ \( ProcessInfo . processInfo. globallyUniqueString) " , isDirectory: true )
333332 }
334333
@@ -345,7 +344,7 @@ public class TestFileSystem: FileManagerProtocol, DocumentationWorkspaceDataProv
345344 ///
346345 /// - Parameter path: The path to the sub hierarchy to dump to a string representation.
347346 /// - Returns: A stable string representation that can be checked in tests.
348- public func dump( subHierarchyFrom path: String = " / " ) -> String {
347+ package func dump( subHierarchyFrom path: String = " / " ) -> String {
349348 filesLock. lock ( )
350349 defer { filesLock. unlock ( ) }
351350
@@ -368,7 +367,7 @@ public class TestFileSystem: FileManagerProtocol, DocumentationWorkspaceDataProv
368367 }
369368
370369 // This is a convenience utility for testing, not FileManagerProtocol API
371- public func recursiveContentsOfDirectory( atPath path: String ) throws -> [ String ] {
370+ package func recursiveContentsOfDirectory( atPath path: String ) throws -> [ String ] {
372371 var allSubpaths = try contentsOfDirectory ( atPath: path)
373372
374373 for subpath in allSubpaths { // This is iterating over a copy
0 commit comments