Skip to content

Consider excludes while walking Tests #152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 8, 2016
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
6 changes: 6 additions & 0 deletions Fixtures/Miscellaneous/ExcludeDiagnostic4/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import PackageDescription

let package = Package(
name: "FooPackage",
exclude: ["Tests/Fixtures"]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print("hello")
Empty file.
6 changes: 6 additions & 0 deletions Fixtures/Miscellaneous/ExcludeDiagnostic5/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import PackageDescription

let package = Package(
name: "FooPackage",
exclude: ["Tests"]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print("hello")
Empty file.
5 changes: 4 additions & 1 deletion Sources/Transmute/Package+testModules.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ import Utility

extension Package {
func testModules() throws -> [TestModule] {
return walk(path, "Tests", recursively: false).filter{ $0.isDirectory }.flatMap { dir in
let testsPath = Path.join(path, "Tests")
//Don't try to walk Tests if it is in excludes
if testsPath.isDirectory && excludes.contains(testsPath) { return [] }
return walk(testsPath, recursively: false).filter(shouldConsiderDirectory).flatMap { dir in
if let sources = try? self.sourcify(dir) {
return TestModule(basename: dir.basename, sources: sources)
} else {
Expand Down
20 changes: 20 additions & 0 deletions Tests/Functional/TestMiscellaneous.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,26 @@ class MiscellaneousTestCase: XCTestCase {
XCTAssertNoSuchPath(prefix, "App", ".build", "debug", "some")
}
}

func testManifestExcludes4() {

// exclude directory is inside Tests folder (Won't build without exclude)

fixture(name: "Miscellaneous/ExcludeDiagnostic4") { prefix in
XCTAssertBuilds(prefix)
XCTAssertFileExists(prefix, ".build", "debug", "FooPackage.swiftmodule")
}
}

func testManifestExcludes5() {

// exclude directory is Tests folder (Won't build without exclude)

fixture(name: "Miscellaneous/ExcludeDiagnostic5") { prefix in
XCTAssertBuilds(prefix)
XCTAssertFileExists(prefix, ".build", "debug", "FooPackage.swiftmodule")
}
}

func testTestDependenciesSimple() {
#if false
Expand Down
2 changes: 2 additions & 0 deletions Tests/Functional/TestValidLayouts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ extension MiscellaneousTestCase {
("testManifestExcludes1", testManifestExcludes1),
("testManifestExcludes2", testManifestExcludes2),
("testManifestExcludes3", testManifestExcludes3),
("testManifestExcludes4", testManifestExcludes4),
("testManifestExcludes5", testManifestExcludes5),
("testTestDependenciesSimple", testTestDependenciesSimple),
("testTestDependenciesComplex", testTestDependenciesComplex),
("testPassExactDependenciesToBuildCommand", testPassExactDependenciesToBuildCommand),
Expand Down