From 26de8f1c9bb609434561dce6536426605fe0ceb6 Mon Sep 17 00:00:00 2001 From: Shaun Harrison Date: Sat, 5 Apr 2025 01:10:18 -0400 Subject: [PATCH] Support relative paths for fileGroups in includes (#1534) --- Sources/ProjectSpec/Project.swift | 3 ++- Tests/Fixtures/duplicated_include/duplicated_import_sut.yml | 3 ++- Tests/Fixtures/paths_test/included_paths_test.yml | 3 +++ Tests/Fixtures/paths_test/relative_file_groups/TestFile.md | 1 + Tests/Fixtures/paths_test/relative_file_groups/inc.yml | 2 ++ Tests/ProjectSpecTests/SpecLoadingTests.swift | 2 ++ 6 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 Tests/Fixtures/paths_test/relative_file_groups/TestFile.md create mode 100644 Tests/Fixtures/paths_test/relative_file_groups/inc.yml diff --git a/Sources/ProjectSpec/Project.swift b/Sources/ProjectSpec/Project.swift index 527a7b9a..72daf032 100644 --- a/Sources/ProjectSpec/Project.swift +++ b/Sources/ProjectSpec/Project.swift @@ -242,7 +242,8 @@ extension Project: PathContainer { .object("schemes", Scheme.pathProperties), .object("projectReferences", ProjectReference.pathProperties), .object("packages", SwiftPackage.pathProperties), - .string("localPackages") + .string("localPackages"), + .string("fileGroups") ] } } diff --git a/Tests/Fixtures/duplicated_include/duplicated_import_sut.yml b/Tests/Fixtures/duplicated_include/duplicated_import_sut.yml index 5ade0abe..5a1ea760 100644 --- a/Tests/Fixtures/duplicated_include/duplicated_import_sut.yml +++ b/Tests/Fixtures/duplicated_include/duplicated_import_sut.yml @@ -2,7 +2,8 @@ include: - duplicated_import_transitive.yml - duplicated_import_root.yml - duplicated_import_root.yml - - different_path/duplicated_import_root.yml + - path: different_path/duplicated_import_root.yml + relativePaths: false name: DuplicatedImportDependent targets: IncludedTarget: diff --git a/Tests/Fixtures/paths_test/included_paths_test.yml b/Tests/Fixtures/paths_test/included_paths_test.yml index 2fe65196..93a400fd 100644 --- a/Tests/Fixtures/paths_test/included_paths_test.yml +++ b/Tests/Fixtures/paths_test/included_paths_test.yml @@ -1,8 +1,11 @@ +name: IncludedPathsTest include: - recursive_test/recursive_test.yml - same_relative_path_test/same_relative_path_test.yml - path: relative_local_package/inc.yml relativePaths: true + - path: relative_file_groups/inc.yml + relativePaths: true configFiles: IncludedConfig: config projectReferences: diff --git a/Tests/Fixtures/paths_test/relative_file_groups/TestFile.md b/Tests/Fixtures/paths_test/relative_file_groups/TestFile.md new file mode 100644 index 00000000..49de0ae4 --- /dev/null +++ b/Tests/Fixtures/paths_test/relative_file_groups/TestFile.md @@ -0,0 +1 @@ +This is a test file for relative file groups diff --git a/Tests/Fixtures/paths_test/relative_file_groups/inc.yml b/Tests/Fixtures/paths_test/relative_file_groups/inc.yml new file mode 100644 index 00000000..bd89ac32 --- /dev/null +++ b/Tests/Fixtures/paths_test/relative_file_groups/inc.yml @@ -0,0 +1,2 @@ +fileGroups: + - TestFile.md diff --git a/Tests/ProjectSpecTests/SpecLoadingTests.swift b/Tests/ProjectSpecTests/SpecLoadingTests.swift index 2fd6e7db..c0bbb281 100644 --- a/Tests/ProjectSpecTests/SpecLoadingTests.swift +++ b/Tests/ProjectSpecTests/SpecLoadingTests.swift @@ -197,6 +197,8 @@ class SpecLoadingTests: XCTestCase { try expect(project.packages) == [ "LocalPackage": .local(path: "paths_test/relative_local_package/LocalPackage", group: nil, excludeFromProject: false), ] + + try expect(project.fileGroups.contains("paths_test/relative_file_groups/TestFile.md")) == true } $0.it("respects directory expansion preference") {