Skip to content

Commit e944cd7

Browse files
committed
Linux: Add LinuxMain and make 'swift test' run on Linux
1 parent 78a2370 commit e944cd7

File tree

10 files changed

+83
-2
lines changed

10 files changed

+83
-2
lines changed

Tests/LinuxMain.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import XCTest
2+
import SwiftSyntaxTest
3+
4+
XCTMain([
5+
testCase(AbsolutePositionTestCase.allTests),
6+
testCase(DecodeSyntaxTestCase.allTests),
7+
testCase(DiagnosticTestCase.allTests),
8+
testCase(LazyCachingTestCase.allTests),
9+
testCase(ParseFileTestCase.allTests),
10+
testCase(SyntaxChildrenAPITestCase.allTests),
11+
testCase(SyntaxCollectionsAPITestCase.allTests),
12+
testCase(SyntaxFactoryAPITestCase.allTests),
13+
testCase(SyntaxVisitorTestCase.allTests),
14+
])

Tests/SwiftSyntaxTest/AbsolutePosition.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ fileprivate class FuncRenamer: SyntaxRewriter {
99
}
1010

1111
public class AbsolutePositionTestCase: XCTestCase {
12+
13+
public static let allTests = [
14+
("testVisitor", testVisitor),
15+
("testClosure", testClosure),
16+
("testRename", testRename),
17+
("testCurrentFile", testCurrentFile),
18+
("testRecursion", testRecursion),
19+
("testTrivias", testTrivias),
20+
("testImplicit", testImplicit),
21+
("testWithoutSourceFileRoot", testWithoutSourceFileRoot),
22+
]
23+
1224
public func testVisitor() {
1325
XCTAssertNoThrow(try {
1426
let source = try String(contentsOf: getInput("visitor.swift"))

Tests/SwiftSyntaxTest/DeserializeFile.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import XCTest
22
import SwiftSyntax
33

4-
public class DecodeSytnaxTestCase: XCTestCase {
4+
public class DecodeSyntaxTestCase: XCTestCase {
5+
6+
public static let allTests = [
7+
("testBasic", testBasic),
8+
]
9+
510
public func testBasic() {
611
XCTAssertNoThrow(try {
712
let inputFile = getInput("visitor.swift")

Tests/SwiftSyntaxTest/DiagnosticTest.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ fileprivate extension Diagnostic.Message {
2828
}
2929

3030
public class DiagnosticTestCase: XCTestCase {
31+
32+
public static let allTests = [
33+
("testDiagnosticEmission", testDiagnosticEmission),
34+
("testSourceLocations", testSourceLocations),
35+
]
36+
3137
public func testDiagnosticEmission() {
3238
let startLoc = loc()
3339
let fixLoc = loc()

Tests/SwiftSyntaxTest/LazyCaching.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import XCTest
22
import SwiftSyntax
33

4-
class LazyCachingTestCase: XCTestCase {
4+
public class LazyCachingTestCase: XCTestCase {
5+
6+
public static let allTests = [
7+
("testPathological", testPathological),
8+
("testTwoAccesses", testTwoAccesses),
9+
]
10+
511
public func testPathological() {
612
let tuple = SyntaxFactory.makeVoidTupleType()
713

Tests/SwiftSyntaxTest/ParseFile.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ fileprivate class Test: NSObject {
1919
#endif
2020

2121
public class ParseFileTestCase: XCTestCase {
22+
23+
public static let allTests = [
24+
("testParseSingleFile", testParseSingleFile)
25+
]
26+
2227
public func testParseSingleFile() {
2328
let currentFile = URL(fileURLWithPath: #file)
2429
XCTAssertNoThrow(try {

Tests/SwiftSyntaxTest/SyntaxChildren.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ import XCTest
22
import SwiftSyntax
33

44
public class SyntaxChildrenAPITestCase: XCTestCase {
5+
6+
public static let allTests = [
7+
("testIterateWithAllPresent", testIterateWithAllPresent),
8+
("testIterateWithSomeMissing", testIterateWithSomeMissing),
9+
("testIterateWithAllMissing", testIterateWithAllMissing),
10+
]
11+
512
public func testIterateWithAllPresent() {
613
let returnStmt = SyntaxFactory.makeReturnStmt(
714
returnKeyword: SyntaxFactory.makeReturnKeyword(),

Tests/SwiftSyntaxTest/SyntaxCollections.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ fileprivate func integerLiteralElement(_ int: Int) -> ArrayElementSyntax {
99
}
1010

1111
public class SyntaxCollectionsAPITestCase: XCTestCase {
12+
13+
public static let allTests = [
14+
("testAppendingElement", testAppendingElement),
15+
("testInsertingElement", testInsertingElement),
16+
("testPrependingElement", testPrependingElement),
17+
("testRemovingFirstElement", testRemovingFirstElement),
18+
("testRemovingLastElement", testRemovingLastElement),
19+
("testRemovingElement", testRemovingElement),
20+
("testReplacingElement", testReplacingElement),
21+
]
22+
1223
public func testAppendingElement() {
1324
let arrayElementList = SyntaxFactory.makeArrayElementList([
1425
integerLiteralElement(0)

Tests/SwiftSyntaxTest/SyntaxFactory.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ fileprivate func cannedStructDecl() -> StructDeclSyntax {
1717
}
1818

1919
public class SyntaxFactoryAPITestCase: XCTestCase {
20+
21+
public static let allTests = [
22+
("testGenerated", testGenerated),
23+
("testTokenSyntax", testTokenSyntax),
24+
("testFunctionCallSyntaxBuilder", testFunctionCallSyntaxBuilder),
25+
]
26+
2027
public func testGenerated() {
2128

2229
let structDecl = cannedStructDecl()

Tests/SwiftSyntaxTest/VisitorTest.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@ import XCTest
22
import SwiftSyntax
33

44
public class SyntaxVisitorTestCase: XCTestCase {
5+
6+
public static let allTests = [
7+
("testBasic", testBasic),
8+
("testRewritingNodeWithEmptyChild", testRewritingNodeWithEmptyChild),
9+
("testSyntaxRewriterVisitAny", testSyntaxRewriterVisitAny),
10+
("testSyntaxRewriterVisitCollection", testSyntaxRewriterVisitCollection),
11+
]
12+
513
public func testBasic() {
614
class FuncCounter: SyntaxVisitor {
715
var funcCount = 0

0 commit comments

Comments
 (0)