@@ -3806,40 +3806,48 @@ final class WorkspaceTests: XCTestCase {
3806
3806
3807
3807
// This verifies that the simplest possible loading APIs are available for package clients.
3808
3808
func testSimpleAPI( ) throws {
3809
- // This checkout of the SwiftPM package.
3810
- let packagePath = AbsolutePath ( #file) . parentDirectory. parentDirectory. parentDirectory
3809
+ try testWithTemporaryDirectory { path in
3810
+ // Create a temporary package as a test case.
3811
+ let packagePath = path. appending ( component: " MyPkg " )
3812
+ let initPackage = try InitPackage ( name: packagePath. basename, destinationPath: packagePath, packageType: . executable)
3813
+ try initPackage. writePackageStructure ( )
3814
+
3815
+ // Load the workspace.
3816
+ let observability = ObservabilitySystem . bootstrapForTesting ( )
3817
+ let workspace = try Workspace ( forRootPackage: packagePath, customToolchain: UserToolchain . default)
3811
3818
3812
- let observability = ObservabilitySystem . bootstrapForTesting ( )
3813
- let workspace = try Workspace ( forRootPackage: packagePath, customToolchain: UserToolchain . default)
3814
-
3815
- // From here the API should be simple and straightforward:
3816
- let manifest = try tsc_await {
3817
- workspace. loadRootManifest (
3818
- at: packagePath,
3819
- diagnostics: ObservabilitySystem . topScope. makeDiagnosticsEngine ( ) ,
3820
- completion: $0
3821
- )
3822
- }
3823
- XCTAssertFalse ( observability. hasErrorDiagnostics)
3819
+ // From here the API should be simple and straightforward:
3820
+ let manifest = try tsc_await {
3821
+ workspace. loadRootManifest (
3822
+ at: packagePath,
3823
+ diagnostics: ObservabilitySystem . topScope. makeDiagnosticsEngine ( ) ,
3824
+ completion: $0
3825
+ )
3826
+ }
3827
+ XCTAssertFalse ( observability. hasWarningDiagnostics, observability. diagnostics. description)
3828
+ XCTAssertFalse ( observability. hasErrorDiagnostics, observability. diagnostics. description)
3824
3829
3825
- let package = try tsc_await {
3826
- workspace. loadRootPackage (
3827
- at: packagePath,
3828
- diagnostics: ObservabilitySystem . topScope. makeDiagnosticsEngine ( ) ,
3829
- completion: $0
3830
- )
3831
- }
3832
- XCTAssertFalse ( observability. hasErrorDiagnostics)
3830
+ let package = try tsc_await {
3831
+ workspace. loadRootPackage (
3832
+ at: packagePath,
3833
+ diagnostics: ObservabilitySystem . topScope. makeDiagnosticsEngine ( ) ,
3834
+ completion: $0
3835
+ )
3836
+ }
3837
+ XCTAssertFalse ( observability. hasWarningDiagnostics, observability. diagnostics. description)
3838
+ XCTAssertFalse ( observability. hasErrorDiagnostics, observability. diagnostics. description)
3833
3839
3834
- let graph = try workspace. loadPackageGraph (
3835
- rootPath: packagePath,
3836
- diagnostics: ObservabilitySystem . topScope. makeDiagnosticsEngine ( )
3837
- )
3838
- XCTAssertFalse ( observability. hasErrorDiagnostics)
3840
+ let graph = try workspace. loadPackageGraph (
3841
+ rootPath: packagePath,
3842
+ diagnostics: ObservabilitySystem . topScope. makeDiagnosticsEngine ( )
3843
+ )
3844
+ XCTAssertFalse ( observability. hasWarningDiagnostics, observability. diagnostics. description)
3845
+ XCTAssertFalse ( observability. hasErrorDiagnostics, observability. diagnostics. description)
3839
3846
3840
- XCTAssertEqual ( manifest. name, " SwiftPM " )
3841
- XCTAssertEqual ( package . manifestName, manifest. name)
3842
- XCTAssert ( graph. reachableProducts. contains ( where: { $0. name == " SwiftPM " } ) )
3847
+ XCTAssertEqual ( manifest. name, " MyPkg " )
3848
+ XCTAssertEqual ( package . manifestName, manifest. name)
3849
+ XCTAssert ( graph. reachableProducts. contains ( where: { $0. name == " MyPkg " } ) )
3850
+ }
3843
3851
}
3844
3852
3845
3853
func testRevisionDepOnLocal( ) throws {
0 commit comments