Skip to content

Commit 2b579c4

Browse files
committed
[Commands] Skip test cases with no tests
This prevents a crash when a test class doesn't contain any test methods. <rdar://problem/42554220> swift test --generate-linuxmain can't handle tests with underscores in the name
1 parent 40c4a2d commit 2b579c4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Sources/Commands/GenerateLinuxMain.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,12 @@ private final class ModulesBuilder {
165165
for testCase in cases {
166166
let (module, theKlass) = testCase.name.split(around: ".")
167167
guard let klass = theKlass else {
168-
fatalError("Unsupported test case name \(testCase.name)")
168+
// This should only happen if there are no tests in the test case.
169+
if testCase.tests.isEmpty {
170+
print("warning: \(testCase.name) does not contain any tests")
171+
continue
172+
}
173+
fatalError("unreachable \(testCase.name)")
169174
}
170175
for method in testCase.tests {
171176
add(module, klass, method)

0 commit comments

Comments
 (0)