Skip to content

Commit 77d4d4c

Browse files
authored
Merge pull request swiftlang#171 from ahoppen/linux
Add support for building and testing on Linux
2 parents 5d091cd + 3e09eea commit 77d4d4c

17 files changed

+26
-138
lines changed

Diff for: Tests/LinuxMain.swift

-23
This file was deleted.

Diff for: Tests/SwiftSyntaxTest/AbsolutePosition.swift renamed to Tests/SwiftSyntaxTest/AbsolutePositionTests.swift

+9-21
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,7 @@ fileprivate class FuncRenamer: SyntaxRewriter {
1010
}
1111
}
1212

13-
public class AbsolutePositionTestCase: XCTestCase {
14-
15-
public static let allTests = [
16-
("testVisitor", testVisitor),
17-
("testClosure", testClosure),
18-
("testRename", testRename),
19-
("testCurrentFile", testCurrentFile),
20-
("testRecursion", testRecursion),
21-
("testTrivias", testTrivias),
22-
("testImplicit", testImplicit),
23-
("testWithoutSourceFileRoot", testWithoutSourceFileRoot),
24-
("testSourceLocation", testSourceLocation),
25-
]
13+
public class AbsolutePositionTests: XCTestCase {
2614

2715
public func testVisitor() {
2816
XCTAssertNoThrow(try {
@@ -114,8 +102,8 @@ public class AbsolutePositionTestCase: XCTestCase {
114102
$0.useItem(Syntax(ReturnStmtSyntax {
115103
$0.useReturnKeyword(
116104
SyntaxFactory.makeReturnKeyword(
117-
leadingTrivia: AbsolutePositionTestCase.leadingTrivia,
118-
trailingTrivia: AbsolutePositionTestCase.trailingTrivia))
105+
leadingTrivia: AbsolutePositionTests.leadingTrivia,
106+
trailingTrivia: AbsolutePositionTests.trailingTrivia))
119107
})
120108
)}, count: count)
121109
return SyntaxFactory.makeSourceFile(
@@ -138,12 +126,12 @@ public class AbsolutePositionTestCase: XCTestCase {
138126

139127
// Test Node trivia setters and getters
140128

141-
XCTAssertEqual(AbsolutePositionTestCase.leadingTrivia, root.leadingTrivia)
129+
XCTAssertEqual(AbsolutePositionTests.leadingTrivia, root.leadingTrivia)
142130
XCTAssertEqual([], root.trailingTrivia)
143131

144132
var modifiedRoot1 = root.withLeadingTrivia([.spaces(6), .tabs(1)])
145133
XCTAssertEqual([.spaces(6), .tabs(1)], modifiedRoot1.leadingTrivia)
146-
XCTAssertEqual(AbsolutePositionTestCase.leadingTrivia, root.leadingTrivia)
134+
XCTAssertEqual(AbsolutePositionTests.leadingTrivia, root.leadingTrivia)
147135
modifiedRoot1.leadingTrivia = [.blockComment("/* this is a comment */")]
148136
XCTAssertEqual([.blockComment("/* this is a comment */")], modifiedRoot1.leadingTrivia)
149137

@@ -155,18 +143,18 @@ public class AbsolutePositionTestCase: XCTestCase {
155143

156144
// Test Collection trivia setters and getters
157145

158-
XCTAssertEqual(AbsolutePositionTestCase.leadingTrivia, root.statements.leadingTrivia)
159-
XCTAssertEqual(AbsolutePositionTestCase.trailingTrivia, root.statements.trailingTrivia)
146+
XCTAssertEqual(AbsolutePositionTests.leadingTrivia, root.statements.leadingTrivia)
147+
XCTAssertEqual(AbsolutePositionTests.trailingTrivia, root.statements.trailingTrivia)
160148

161149
var modifiedStatements1 = root.withLeadingTrivia([.carriageReturnLineFeeds(3)])
162150
XCTAssertEqual([.carriageReturnLineFeeds(3)], modifiedStatements1.leadingTrivia)
163-
XCTAssertEqual(AbsolutePositionTestCase.leadingTrivia, root.statements.leadingTrivia)
151+
XCTAssertEqual(AbsolutePositionTests.leadingTrivia, root.statements.leadingTrivia)
164152
modifiedStatements1.leadingTrivia = [.garbageText("GARBAGE")]
165153
XCTAssertEqual([.garbageText("GARBAGE")], modifiedStatements1.leadingTrivia)
166154

167155
var modifiedStatements2 = root.withTrailingTrivia([.formfeeds(1), .carriageReturns(3)])
168156
XCTAssertEqual([.formfeeds(1), .carriageReturns(3)], modifiedStatements2.trailingTrivia)
169-
XCTAssertEqual(AbsolutePositionTestCase.trailingTrivia, root.statements.trailingTrivia)
157+
XCTAssertEqual(AbsolutePositionTests.trailingTrivia, root.statements.trailingTrivia)
170158
modifiedStatements2.trailingTrivia = [.verticalTabs(4)]
171159
XCTAssertEqual([.verticalTabs(4)], modifiedStatements2.trailingTrivia)
172160
}

Diff for: Tests/SwiftSyntaxTest/ClassificationTests.swift

-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ import XCTest
22
import SwiftSyntax
33

44
public class ClassificationTests: XCTestCase {
5-
public static let allTests = [
6-
("testClassification", testClassification),
7-
("testTokenClassification", testTokenClassification),
8-
]
95

106
public func testClassification() {
117
let source = "// blah.\nlet x/*yo*/ = 0"

Diff for: Tests/SwiftSyntaxTest/CustomReflecatbleTests.swift

-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ import SwiftSyntax
33

44

55
public class CustomReflectableTests: XCTestCase {
6-
public static let allTests = [
7-
("testDump", testDump),
8-
]
9-
106

117
public func testDump() {
128
struct TestCase {

Diff for: Tests/SwiftSyntaxTest/DiagnosticTest.swift renamed to Tests/SwiftSyntaxTest/DiagnosticTests.swift

+1-6
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,7 @@ fileprivate extension Diagnostic.Message {
2727
}
2828
}
2929

30-
public class DiagnosticTestCase: XCTestCase {
31-
32-
public static let allTests = [
33-
("testDiagnosticEmission", testDiagnosticEmission),
34-
("testSourceLocations", testSourceLocations),
35-
]
30+
public class DiagnosticTests: XCTestCase {
3631

3732
public func testDiagnosticEmission() {
3833
let startLoc = loc()

Diff for: Tests/SwiftSyntaxTest/IncrementalParsingTests.swift

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
import XCTest
22
import SwiftSyntax
33

4-
public class IncrementalParsingTestCase: XCTestCase {
5-
6-
public static let allTests = [
7-
("testIncrementalInvalid", testIncrementalInvalid),
8-
("testReusedNode", testReusedNode),
9-
]
4+
public class IncrementalParsingTests: XCTestCase {
105

116
public func testIncrementalInvalid() {
127
let original = "struct A { func f() {"

Diff for: Tests/SwiftSyntaxTest/MultithreadingTests.swift

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
import XCTest
22
import SwiftSyntax
33

4-
public class MultithreadingTestCase: XCTestCase {
5-
6-
public static let allTests = [
7-
("testPathological", testPathological),
8-
("testTwoAccesses", testTwoAccesses),
9-
]
4+
public class MultithreadingTests: XCTestCase {
105

116
public func testPathological() {
127
let tuple = SyntaxFactory.makeVoidTupleType()

Diff for: Tests/SwiftSyntaxTest/ParseFile.swift renamed to Tests/SwiftSyntaxTest/ParseFileTests.swift

+1-6
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,7 @@ enum Animal {
2323
case dog
2424
}
2525

26-
public class ParseFileTestCase: XCTestCase {
27-
28-
public static let allTests = [
29-
("testParseSingleFile", testParseSingleFile),
30-
("testEnumCaseStructure", testEnumCaseStructure)
31-
]
26+
public class ParseFileTests: XCTestCase {
3227

3328
public func testParseSingleFile() {
3429
let currentFile = URL(fileURLWithPath: #file)

Diff for: Tests/SwiftSyntaxTest/SyntaxChildren.swift renamed to Tests/SwiftSyntaxTest/SyntaxChildrenTests.swift

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
import XCTest
22
import SwiftSyntax
33

4-
public class SyntaxChildrenAPITestCase: XCTestCase {
5-
6-
public static let allTests = [
7-
("testIterateWithAllPresent", testIterateWithAllPresent),
8-
("testIterateWithSomeMissing", testIterateWithSomeMissing),
9-
("testIterateWithAllMissing", testIterateWithAllMissing),
10-
]
4+
public class SyntaxChildrenTests: XCTestCase {
115

126
public func testIterateWithAllPresent() {
137
let returnStmt = SyntaxFactory.makeReturnStmt(

Diff for: Tests/SwiftSyntaxTest/SyntaxCollections.swift renamed to Tests/SwiftSyntaxTest/SyntaxCollectionsTests.swift

+1-12
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,7 @@ fileprivate func integerLiteralElement(_ int: Int) -> ArrayElementSyntax {
88
trailingComma: nil)
99
}
1010

11-
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-
("testIteration", testIteration),
22-
]
11+
public class SyntaxCollectionsTests: XCTestCase {
2312

2413
public func testAppendingElement() {
2514
let arrayElementList = SyntaxFactory.makeArrayElementList([

Diff for: Tests/SwiftSyntaxTest/SyntaxFactory.swift renamed to Tests/SwiftSyntaxTest/SyntaxFactoryTests.swift

+1-11
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,7 @@ fileprivate func cannedStructDecl() -> StructDeclSyntax {
1616
}
1717
}
1818

19-
public class SyntaxFactoryAPITestCase: XCTestCase {
20-
21-
public static let allTests = [
22-
("testGenerated", testGenerated),
23-
("testTokenSyntax", testTokenSyntax),
24-
("testFunctionCallSyntaxBuilder", testFunctionCallSyntaxBuilder),
25-
("testWithOptionalChild", testWithOptionalChild),
26-
("testUnknownSyntax", testUnknownSyntax),
27-
("testMakeStringLiteralExpr", testMakeStringLiteralExpr),
28-
("testMakeBinaryOperator", testMakeBinaryOperator),
29-
]
19+
public class SyntaxFactoryTests: XCTestCase {
3020

3121
public func testGenerated() {
3222

Diff for: Tests/SwiftSyntaxTest/SyntaxTests.swift

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
import XCTest
22
import SwiftSyntax
33

4-
public class SyntaxAPITestCase: XCTestCase {
5-
6-
public static let allTests = [
7-
("testSyntaxAPI", testSyntaxAPI),
8-
("testPositions", testPositions),
9-
]
4+
public class SyntaxTests: XCTestCase {
105

116
public func testSyntaxAPI() {
127
let source = "struct A { func f() {} }"

Diff for: Tests/SwiftSyntaxTest/ModifierTests.swift renamed to Tests/SwiftSyntaxTest/SyntaxTreeModifierTests.swift

-4
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ fileprivate func cannedVarDecl() -> VariableDeclSyntax {
2020

2121
public class SyntaxTreeModifierTests: XCTestCase {
2222

23-
public static let allTests = [
24-
("testAccessorAsModifier", testAccessorAsModifier)
25-
]
26-
2723
public func testAccessorAsModifier() {
2824
var VD = cannedVarDecl()
2925
XCTAssertEqual("\(VD)", "let a: Int")

Diff for: Tests/SwiftSyntaxTest/VisitorTest.swift renamed to Tests/SwiftSyntaxTest/SyntaxVisitorTests.swift

+1-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
import XCTest
22
import SwiftSyntax
33

4-
public class SyntaxVisitorTestCase: XCTestCase {
5-
6-
public static let allTests = [
7-
("testBasic", testBasic),
8-
("testRewritingNodeWithEmptyChild", testRewritingNodeWithEmptyChild),
9-
("testSyntaxRewriterVisitAny", testSyntaxRewriterVisitAny),
10-
("testSyntaxRewriterVisitCollection", testSyntaxRewriterVisitCollection),
11-
("testVisitorClass", testVisitorClass),
12-
]
4+
public class SyntaxVisitorTests: XCTestCase {
135

146
public func testBasic() {
157
class FuncCounter: SyntaxVisitor {

Diff for: Tests/SwiftSyntaxTest/TokenTest.swift

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import XCTest
22
import SwiftSyntax
33

4-
public class TokenSyntaxTestCase: XCTestCase {
5-
6-
public static let allTests = [
7-
("testKeywordKinds", testKeywordKinds),
8-
]
4+
public class TokenTests: XCTestCase {
95

106
public func testKeywordKinds() {
117
XCTAssertTrue(TokenKind.operatorKeyword.isKeyword)

Diff for: Tests/SwiftSyntaxTest/TriviaTests.swift

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
import XCTest
22
import SwiftSyntax
33

4-
public class TriviaTestCase: XCTestCase {
5-
6-
public static let allTests = [
7-
("testTriviaEquatable", testTriviaEquatable),
8-
("testTriviaPieceEquatable", testTriviaPieceEquatable)
9-
]
4+
public class TriviaTests: XCTestCase {
105

116
func testTriviaEquatable() {
127
XCTAssertEqual([.spaces(2), .tabs(1)] as Trivia, [.spaces(2), .tabs(1)])

Diff for: build-script.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,12 @@ def check_gyb_exec():
8888
if not os.path.exists(GYB_EXEC):
8989
fatal_error('''
9090
Error: Could not find gyb.
91+
Looking at '%s'.
9192
9293
Make sure you have the main swift repo checked out next to the swift-syntax
9394
repository.
9495
Refer to README.md for more information.
95-
''')
96+
''' % GYB_EXEC)
9697

9798

9899
def check_rsync():
@@ -207,6 +208,8 @@ def get_swiftpm_invocation(toolchain, action, build_dir, multiroot_data_file,
207208

208209
swiftpm_call = [swift_exec, action]
209210
swiftpm_call.extend(['--package-path', PACKAGE_DIR])
211+
if platform.system() != 'Darwin':
212+
swiftpm_call.extend(['--enable-test-discovery'])
210213
if release:
211214
swiftpm_call.extend(['--configuration', 'release'])
212215
if build_dir:
@@ -289,10 +292,11 @@ def check_lit_exec():
289292
if not os.path.exists(LIT_EXEC):
290293
fatal_error('''
291294
Error: Could not find lit.py.
295+
Looking at '%s'.
292296
293297
Make sure you have the llvm repo checked out next to the swift-syntax repo.
294298
Refer to README.md for more information.
295-
''')
299+
''' % LIT_EXEC)
296300

297301

298302
def check_incr_transfer_roundtrip_exec():

0 commit comments

Comments
 (0)