Skip to content

Commit 8fe00db

Browse files
committed
Squash this shit
1 parent 1759889 commit 8fe00db

File tree

14 files changed

+164
-10
lines changed

14 files changed

+164
-10
lines changed

Fixtures/InvalidLayouts/DirectTestsWithModules1/Package.swift

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class Foo {
2+
var bar: Int = 0
3+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import XCTest
2+
3+
@testable import ModuleA
4+
5+
class FooTests: XCTestCase {
6+
func testSuccess() {
7+
}
8+
}
9+
10+
#if os(Linux)
11+
extension FooTests: XCTestCaseProvider {
12+
var allTests: [(String, () throws -> Void)] {
13+
return [
14+
("testSuccess", testSuccess),
15+
]
16+
}
17+
}
18+
#endif
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import XCTest
2+
3+
@testable import DirectTestsWithModules1
4+
@testable import ModuleAtest
5+
6+
XCTMain([
7+
FooTests(),
8+
BarTests(),
9+
])
10+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import XCTest
2+
3+
@testable import ModuleA
4+
5+
class BarTests: XCTestCase {
6+
func testSuccess() {
7+
}
8+
}
9+
10+
#if os(Linux)
11+
extension BarTests: XCTestCaseProvider {
12+
var allTests: [(String, () throws -> Void)] {
13+
return [
14+
("testSuccess", testSuccess),
15+
]
16+
}
17+
}
18+
#endif
19+

Fixtures/InvalidLayouts/DirectTestsWithModules2/Package.swift

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class Foo {
2+
var bar: Int = 0
3+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import XCTest
2+
3+
@testable import DirectTestsWithModules2
4+
5+
class BarTests: XCTestCase {
6+
func testSuccess() {
7+
}
8+
}
9+
10+
#if os(Linux)
11+
extension BarTests: XCTestCaseProvider {
12+
var allTests: [(String, () throws -> Void)] {
13+
return [
14+
("testSuccess", testSuccess),
15+
]
16+
}
17+
}
18+
#endif
19+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import XCTest
2+
3+
class FooTests: XCTestCase {
4+
func testSuccess() {
5+
}
6+
}
7+
8+
#if os(Linux)
9+
extension FooTests: XCTestCaseProvider {
10+
var allTests: [(String, () throws -> Void)] {
11+
return [
12+
("testSuccess", testSuccess),
13+
]
14+
}
15+
}
16+
#endif
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import XCTest
2+
3+
@testable import DirectTests
4+
@testable import DirectTestsWithModules2
5+
6+
XCTMain([
7+
FooTests(),
8+
BarTests(),
9+
])
10+

Fixtures/ValidLayouts/SingleModule/DirectTests/Tests/FooTests.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,13 @@ class FooTests: XCTestCase {
44
func testSuccess() {
55
}
66
}
7+
8+
#if os(Linux)
9+
extension FooTests: XCTestCaseProvider {
10+
var allTests: [(String, () throws -> Void)] {
11+
return [
12+
("testSuccess", testSuccess),
13+
]
14+
}
15+
}
16+
#endif

Sources/Transmute/Package+testModules.swift

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,19 @@ import Utility
1414
extension Package {
1515
func testModules() throws -> [TestModule] {
1616
let (directories, files) = walk(path, "Tests", recursively: false).partition{ $0.isDirectory }
17-
18-
if (directories.count > 0) {
19-
return try directories
20-
.filter { !excludes.contains($0) }
21-
.map { TestModule(basename: $0.basename, sources: try self.sourcify($0)) }
22-
23-
} else {
24-
let rootTestFiles = files.filter {
25-
!$0.hasSuffix("LinuxMain.swift") && isValidSource($0)
17+
18+
let testDirectories = directories.filter{ !excludes.contains($0) }
19+
let rootTestFiles = files.filter {
20+
!$0.hasSuffix("LinuxMain.swift") && isValidSource($0) && !excludes.contains($0)
21+
}
22+
23+
if (testDirectories.count > 0 && rootTestFiles.count > 0) {
24+
throw ModuleError.InvalidLayout(.InvalidLayout)
25+
} else if (testDirectories.count > 0) {
26+
return try testDirectories.map {
27+
TestModule(basename: $0.basename, sources: try self.sourcify($0))
2628
}
27-
29+
} else {
2830
if (rootTestFiles.count > 0) {
2931
let rootTestSource = Sources(paths: rootTestFiles, root: path)
3032
return [TestModule(basename: name, sources: rootTestSource)]

Tests/Functional/TestInvalidLayouts.swift

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import XCTest
1212
import func POSIX.rmdir
1313
import func POSIX.unlink
14+
import func POSIX.rename
1415

1516
class InvalidLayoutsTestCase: XCTestCase {
1617

@@ -111,4 +112,46 @@ class InvalidLayoutsTestCase: XCTestCase {
111112
XCTAssertBuilds(prefix)
112113
}
113114
}
115+
116+
func testDirectTestsWithModules1() {
117+
/*
118+
Package
119+
├── Sources
120+
│ └── ModuleA
121+
│ └── Foo.swift
122+
└── Tests
123+
├── FooTests.swift <-- Invalid
124+
└── ModuleA
125+
└── ModuleATests.swift
126+
*/
127+
128+
fixture(name: "InvalidLayouts/DirectTestsWithModules1") { prefix in
129+
130+
XCTAssertBuildFails(prefix)
131+
132+
try POSIX.unlink("\(prefix)/Tests/FooTests.swift")
133+
XCTAssertBuilds(prefix)
134+
}
135+
}
136+
137+
func testDirectTestsWithModules2() {
138+
/*
139+
Package
140+
├── Sources
141+
│ └── Foo.swift
142+
└── Tests
143+
├── FooTests.swift <-- Invalid
144+
└── ImplicitModuleName
145+
└── ModuleTests.swift
146+
*/
147+
148+
fixture(name: "InvalidLayouts/DirectTestsWithModules1") { prefix in
149+
150+
XCTAssertBuildFails(prefix)
151+
152+
try POSIX.unlink("\(prefix)/Tests/FooTests.swift")
153+
XCTAssertBuilds(prefix)
154+
}
155+
}
156+
114157
}

Tests/Functional/TestValidLayouts.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ extension ValidLayoutsTestCase {
196196
("testSingleModuleExecutable", testSingleModuleExecutable),
197197
("testSingleModuleCustomizedName", testSingleModuleCustomizedName),
198198
("testSingleModuleSubfolderWithSwiftSuffix", testSingleModuleSubfolderWithSwiftSuffix),
199+
("testEmptyPackageWithDirectTests", testEmptyPackageWithDirectTests),
199200
("testMultipleModulesLibraries", testMultipleModulesLibraries),
200201
("testMultipleModulesExecutables", testMultipleModulesExecutables),
201202
("testPackageIdentifiers", testPackageIdentifiers),

0 commit comments

Comments
 (0)