diff --git a/Sources/ProjectSpec/Project.swift b/Sources/ProjectSpec/Project.swift index aa873bcfe..63c0ef313 100644 --- a/Sources/ProjectSpec/Project.swift +++ b/Sources/ProjectSpec/Project.swift @@ -241,6 +241,7 @@ extension Project: PathContainer { .object("aggregateTargets", AggregateTarget.pathProperties), .object("schemes", Scheme.pathProperties), .object("projectReferences", ProjectReference.pathProperties), + .object("packages", SwiftPackage.pathProperties) ] } } diff --git a/Sources/ProjectSpec/SwiftPackage.swift b/Sources/ProjectSpec/SwiftPackage.swift index 216a60617..f43294a78 100644 --- a/Sources/ProjectSpec/SwiftPackage.swift +++ b/Sources/ProjectSpec/SwiftPackage.swift @@ -127,3 +127,13 @@ extension SwiftPackage.VersionRequirement: JSONObjectConvertible { } } } + +extension SwiftPackage: PathContainer { + static var pathProperties: [PathProperty] { + [ + .dictionary([ + .string("path"), + ]), + ] + } +} diff --git a/Tests/Fixtures/paths_test/included_paths_test.yml b/Tests/Fixtures/paths_test/included_paths_test.yml index a8d4fbb0e..2fe651969 100644 --- a/Tests/Fixtures/paths_test/included_paths_test.yml +++ b/Tests/Fixtures/paths_test/included_paths_test.yml @@ -1,6 +1,8 @@ include: - recursive_test/recursive_test.yml - same_relative_path_test/same_relative_path_test.yml + - path: relative_local_package/inc.yml + relativePaths: true configFiles: IncludedConfig: config projectReferences: diff --git a/Tests/Fixtures/paths_test/relative_local_package/LocalPackage/.gitignore b/Tests/Fixtures/paths_test/relative_local_package/LocalPackage/.gitignore new file mode 100644 index 000000000..0023a5340 --- /dev/null +++ b/Tests/Fixtures/paths_test/relative_local_package/LocalPackage/.gitignore @@ -0,0 +1,8 @@ +.DS_Store +/.build +/Packages +xcuserdata/ +DerivedData/ +.swiftpm/configuration/registries.json +.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +.netrc diff --git a/Tests/Fixtures/paths_test/relative_local_package/LocalPackage/Package.swift b/Tests/Fixtures/paths_test/relative_local_package/LocalPackage/Package.swift new file mode 100644 index 000000000..84af3c9f8 --- /dev/null +++ b/Tests/Fixtures/paths_test/relative_local_package/LocalPackage/Package.swift @@ -0,0 +1,20 @@ +// swift-tools-version: 5.7 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "LocalPackage", + products: [ + // Products define the executables and libraries a package produces, making them visible to other packages. + .library( + name: "LocalPackage", + targets: ["LocalPackage"] + ) + ], + targets: [ + // Targets are the basic building blocks of a package, defining a module or a test suite. + // Targets can depend on other targets in this package and products from dependencies. + .target(name: "LocalPackage") + ] +) diff --git a/Tests/Fixtures/paths_test/relative_local_package/LocalPackage/Sources/LocalPackage/LocalPackage.swift b/Tests/Fixtures/paths_test/relative_local_package/LocalPackage/Sources/LocalPackage/LocalPackage.swift new file mode 100644 index 000000000..08b22b80f --- /dev/null +++ b/Tests/Fixtures/paths_test/relative_local_package/LocalPackage/Sources/LocalPackage/LocalPackage.swift @@ -0,0 +1,2 @@ +// The Swift Programming Language +// https://docs.swift.org/swift-book diff --git a/Tests/Fixtures/paths_test/relative_local_package/inc.yml b/Tests/Fixtures/paths_test/relative_local_package/inc.yml new file mode 100644 index 000000000..5f3bd94be --- /dev/null +++ b/Tests/Fixtures/paths_test/relative_local_package/inc.yml @@ -0,0 +1,3 @@ +packages: + LocalPackage: + path: LocalPackage diff --git a/Tests/ProjectSpecTests/SpecLoadingTests.swift b/Tests/ProjectSpecTests/SpecLoadingTests.swift index 6a81c0907..055088f9d 100644 --- a/Tests/ProjectSpecTests/SpecLoadingTests.swift +++ b/Tests/ProjectSpecTests/SpecLoadingTests.swift @@ -193,6 +193,10 @@ class SpecLoadingTests: XCTestCase { test: .init(testPlans: [.init(path: "paths_test/TestPlan.xctestplan")]) ) ] + + try expect(project.packages) == [ + "LocalPackage": .local(path: "paths_test/relative_local_package/LocalPackage", group: nil), + ] } $0.it("respects directory expansion preference") {