Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Sources/PackageLoading/TargetSourcesBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ public struct TargetSourcesBuilder {
} else {
matchedRule = .compile
}
// The source file might have been declared twice so
// exit on first match.
// FIXME: We should emitting warnings for duplicate// declarations.
break
}
}
}
Expand Down
26 changes: 26 additions & 0 deletions Tests/PackageLoadingTests/PackageBuilderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,32 @@ class PackageBuilderTests: XCTestCase {
}
}

func testOverlappingDeclaredSources() throws {
let fs = InMemoryFileSystem(emptyFiles:
"/Sources/clib/subfolder/foo.h",
"/Sources/clib/subfolder/foo.c",
"/Sources/clib/bar.h",
"/Sources/clib/bar.c",
"/done"
)

let manifest = Manifest.createV4Manifest(
name: "MyPackage",
targets: [
TargetDescription(
name: "clib",
path: "Sources",
sources: ["clib", "clib/subfolder"]
),
]
)
PackageBuilderTester(manifest, in: fs) { result in
result.checkModule("clib") { module in
module.checkSources(sources: ["clib/bar.c", "clib/subfolder/foo.c"])
}
}
}

func testDeclaredExecutableProducts() {
// Check that declaring executable product doesn't collide with the
// inferred products.
Expand Down
2 changes: 2 additions & 0 deletions Tests/PackageLoadingTests/XCTestManifests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ extension PackageBuilderTests {
("testCustomTargetPaths", testCustomTargetPaths),
("testCustomTargetPathsOverlap", testCustomTargetPathsOverlap),
("testDeclaredExecutableProducts", testDeclaredExecutableProducts),
("testDeclaredSourcesWithDot", testDeclaredSourcesWithDot),
("testDotFilesAreIgnored", testDotFilesAreIgnored),
("testDuplicateProducts", testDuplicateProducts),
("testDuplicateTargetDependencies", testDuplicateTargetDependencies),
Expand All @@ -46,6 +47,7 @@ extension PackageBuilderTests {
("testMixedSources", testMixedSources),
("testModuleMapLayout", testModuleMapLayout),
("testMultipleTestProducts", testMultipleTestProducts),
("testOverlappingDeclaredSources", testOverlappingDeclaredSources),
("testPlatforms", testPlatforms),
("testPredefinedTargetSearchError", testPredefinedTargetSearchError),
("testPublicHeadersPath", testPublicHeadersPath),
Expand Down