diff --git a/Tests/PackageLoadingTests/PD_5_6_LoadingTests.swift b/Tests/PackageLoadingTests/PD_5_6_LoadingTests.swift index 39b5b901a97..0e536caad83 100644 --- a/Tests/PackageLoadingTests/PD_5_6_LoadingTests.swift +++ b/Tests/PackageLoadingTests/PD_5_6_LoadingTests.swift @@ -154,12 +154,11 @@ class PackageDescription5_6LoadingTests: PackageDescriptionLoadingTests { } - func testPackageContext() throws { + /// Tests use of Context.current.packageDirectory + func testPackageContextName() throws { let stream = BufferedOutputByteStream() stream <<< """ import PackageDescription - import Foundation - let package = Package(name: Context.current.packageDirectory) """ @@ -168,4 +167,25 @@ class PackageDescription5_6LoadingTests: PackageDescriptionLoadingTests { XCTAssertEqual(manifest.name, name) } } + + /// Tests access to the package's directory contents. + func testPackageContextDirectory() throws { + let stream = BufferedOutputByteStream() + stream <<< """ + import PackageDescription + import Foundation + + let context = Context.current + let fileManager = FileManager.default + let contents = (try? fileManager.contentsOfDirectory(atPath: context.packageDirectory)) ?? [] + let swiftFiles = contents.filter { $0.hasPrefix("TemporaryFile") && $0.hasSuffix(".swift") } + + let package = Package(name: swiftFiles[0]) + """ + + loadManifest(stream.bytes) { manifest in + let name = parsedManifest?.components.last ?? "" + XCTAssertEqual(manifest.name, name) + } + } }