Skip to content

Commit 2d70e5a

Browse files
committed
Merge pull request #152 from aciidb0mb3r/testModules_excludes
Consider excludes while walking Tests
2 parents 1224b1b + 43e0041 commit 2d70e5a

File tree

9 files changed

+40
-1
lines changed

9 files changed

+40
-1
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import PackageDescription
2+
3+
let package = Package(
4+
name: "FooPackage",
5+
exclude: ["Tests/Fixtures"]
6+
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print("hello")

Fixtures/Miscellaneous/ExcludeDiagnostic4/Tests/Fixtures/Foo.txt

Whitespace-only changes.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import PackageDescription
2+
3+
let package = Package(
4+
name: "FooPackage",
5+
exclude: ["Tests"]
6+
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print("hello")

Fixtures/Miscellaneous/ExcludeDiagnostic5/Tests/Fixtures/Foo.txt

Whitespace-only changes.

Sources/Transmute/Package+testModules.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ import Utility
1313

1414
extension Package {
1515
func testModules() throws -> [TestModule] {
16-
return walk(path, "Tests", recursively: false).filter{ $0.isDirectory }.flatMap { dir in
16+
let testsPath = Path.join(path, "Tests")
17+
//Don't try to walk Tests if it is in excludes
18+
if testsPath.isDirectory && excludes.contains(testsPath) { return [] }
19+
return walk(testsPath, recursively: false).filter(shouldConsiderDirectory).flatMap { dir in
1720
if let sources = try? self.sourcify(dir) {
1821
return TestModule(basename: dir.basename, sources: sources)
1922
} else {

Tests/Functional/TestMiscellaneous.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,26 @@ class MiscellaneousTestCase: XCTestCase {
6969
XCTAssertNoSuchPath(prefix, "App", ".build", "debug", "some")
7070
}
7171
}
72+
73+
func testManifestExcludes4() {
74+
75+
// exclude directory is inside Tests folder (Won't build without exclude)
76+
77+
fixture(name: "Miscellaneous/ExcludeDiagnostic4") { prefix in
78+
XCTAssertBuilds(prefix)
79+
XCTAssertFileExists(prefix, ".build", "debug", "FooPackage.swiftmodule")
80+
}
81+
}
82+
83+
func testManifestExcludes5() {
84+
85+
// exclude directory is Tests folder (Won't build without exclude)
86+
87+
fixture(name: "Miscellaneous/ExcludeDiagnostic5") { prefix in
88+
XCTAssertBuilds(prefix)
89+
XCTAssertFileExists(prefix, ".build", "debug", "FooPackage.swiftmodule")
90+
}
91+
}
7292

7393
func testTestDependenciesSimple() {
7494
#if false

Tests/Functional/TestValidLayouts.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ extension MiscellaneousTestCase {
163163
("testManifestExcludes1", testManifestExcludes1),
164164
("testManifestExcludes2", testManifestExcludes2),
165165
("testManifestExcludes3", testManifestExcludes3),
166+
("testManifestExcludes4", testManifestExcludes4),
167+
("testManifestExcludes5", testManifestExcludes5),
166168
("testTestDependenciesSimple", testTestDependenciesSimple),
167169
("testTestDependenciesComplex", testTestDependenciesComplex),
168170
("testPassExactDependenciesToBuildCommand", testPassExactDependenciesToBuildCommand),

0 commit comments

Comments
 (0)