From c6adb3d5947159380faf603df4eb40389e0f4e11 Mon Sep 17 00:00:00 2001 From: kitasuke Date: Wed, 24 Jul 2019 11:57:59 +0900 Subject: [PATCH 1/4] Rename test files with consistent suffix --- ...ition.swift => AbsolutePositionTests.swift} | 18 +++++++++--------- ...gnosticTest.swift => DiagnosticTests.swift} | 2 +- .../IncrementalParsingTests.swift | 2 +- .../SwiftSyntaxTest/MultithreadingTests.swift | 2 +- .../{ParseFile.swift => ParseFileTests.swift} | 2 +- ...hildren.swift => SyntaxChildrenTests.swift} | 2 +- ...ions.swift => SyntaxCollectionsTests.swift} | 2 +- ...xFactory.swift => SyntaxFactoryTests.swift} | 2 +- Tests/SwiftSyntaxTest/SyntaxTests.swift | 2 +- ...sts.swift => SyntaxTreeModifierTests.swift} | 0 ...itorTest.swift => SyntaxVisitorTests.swift} | 2 +- Tests/SwiftSyntaxTest/TokenTest.swift | 2 +- Tests/SwiftSyntaxTest/TriviaTests.swift | 2 +- 13 files changed, 20 insertions(+), 20 deletions(-) rename Tests/SwiftSyntaxTest/{AbsolutePosition.swift => AbsolutePositionTests.swift} (92%) rename Tests/SwiftSyntaxTest/{DiagnosticTest.swift => DiagnosticTests.swift} (98%) rename Tests/SwiftSyntaxTest/{ParseFile.swift => ParseFileTests.swift} (96%) rename Tests/SwiftSyntaxTest/{SyntaxChildren.swift => SyntaxChildrenTests.swift} (95%) rename Tests/SwiftSyntaxTest/{SyntaxCollections.swift => SyntaxCollectionsTests.swift} (98%) rename Tests/SwiftSyntaxTest/{SyntaxFactory.swift => SyntaxFactoryTests.swift} (99%) rename Tests/SwiftSyntaxTest/{ModifierTests.swift => SyntaxTreeModifierTests.swift} (100%) rename Tests/SwiftSyntaxTest/{VisitorTest.swift => SyntaxVisitorTests.swift} (98%) diff --git a/Tests/SwiftSyntaxTest/AbsolutePosition.swift b/Tests/SwiftSyntaxTest/AbsolutePositionTests.swift similarity index 92% rename from Tests/SwiftSyntaxTest/AbsolutePosition.swift rename to Tests/SwiftSyntaxTest/AbsolutePositionTests.swift index 11ae7724a8d..7705b762006 100644 --- a/Tests/SwiftSyntaxTest/AbsolutePosition.swift +++ b/Tests/SwiftSyntaxTest/AbsolutePositionTests.swift @@ -8,7 +8,7 @@ fileprivate class FuncRenamer: SyntaxRewriter { } } -public class AbsolutePositionTestCase: XCTestCase { +public class AbsolutePositionTests: XCTestCase { public static let allTests = [ ("testVisitor", testVisitor), @@ -106,8 +106,8 @@ public class AbsolutePositionTestCase: XCTestCase { $0.useItem(ReturnStmtSyntax { $0.useReturnKeyword( SyntaxFactory.makeReturnKeyword( - leadingTrivia: AbsolutePositionTestCase.leadingTrivia, - trailingTrivia: AbsolutePositionTestCase.trailingTrivia)) + leadingTrivia: AbsolutePositionTests.leadingTrivia, + trailingTrivia: AbsolutePositionTests.trailingTrivia)) })}, count: count) return SyntaxFactory.makeSourceFile( statements: SyntaxFactory.makeCodeBlockItemList(items), @@ -129,12 +129,12 @@ public class AbsolutePositionTestCase: XCTestCase { // Test Node trivia setters and getters - XCTAssertEqual(AbsolutePositionTestCase.leadingTrivia, root.leadingTrivia) + XCTAssertEqual(AbsolutePositionTests.leadingTrivia, root.leadingTrivia) XCTAssertEqual([], root.trailingTrivia) var modifiedRoot1 = root.withLeadingTrivia([.spaces(6), .tabs(1)]) XCTAssertEqual([.spaces(6), .tabs(1)], modifiedRoot1.leadingTrivia) - XCTAssertEqual(AbsolutePositionTestCase.leadingTrivia, root.leadingTrivia) + XCTAssertEqual(AbsolutePositionTests.leadingTrivia, root.leadingTrivia) modifiedRoot1.leadingTrivia = [.blockComment("/* this is a comment */")] XCTAssertEqual([.blockComment("/* this is a comment */")], modifiedRoot1.leadingTrivia) @@ -146,18 +146,18 @@ public class AbsolutePositionTestCase: XCTestCase { // Test Collection trivia setters and getters - XCTAssertEqual(AbsolutePositionTestCase.leadingTrivia, root.statements.leadingTrivia) - XCTAssertEqual(AbsolutePositionTestCase.trailingTrivia, root.statements.trailingTrivia) + XCTAssertEqual(AbsolutePositionTests.leadingTrivia, root.statements.leadingTrivia) + XCTAssertEqual(AbsolutePositionTests.trailingTrivia, root.statements.trailingTrivia) var modifiedStatements1 = root.withLeadingTrivia([.carriageReturnLineFeeds(3)]) XCTAssertEqual([.carriageReturnLineFeeds(3)], modifiedStatements1.leadingTrivia) - XCTAssertEqual(AbsolutePositionTestCase.leadingTrivia, root.statements.leadingTrivia) + XCTAssertEqual(AbsolutePositionTests.leadingTrivia, root.statements.leadingTrivia) modifiedStatements1.leadingTrivia = [.garbageText("GARBAGE")] XCTAssertEqual([.garbageText("GARBAGE")], modifiedStatements1.leadingTrivia) var modifiedStatements2 = root.withTrailingTrivia([.formfeeds(1), .carriageReturns(3)]) XCTAssertEqual([.formfeeds(1), .carriageReturns(3)], modifiedStatements2.trailingTrivia) - XCTAssertEqual(AbsolutePositionTestCase.trailingTrivia, root.statements.trailingTrivia) + XCTAssertEqual(AbsolutePositionTests.trailingTrivia, root.statements.trailingTrivia) modifiedStatements2.trailingTrivia = [.verticalTabs(4)] XCTAssertEqual([.verticalTabs(4)], modifiedStatements2.trailingTrivia) } diff --git a/Tests/SwiftSyntaxTest/DiagnosticTest.swift b/Tests/SwiftSyntaxTest/DiagnosticTests.swift similarity index 98% rename from Tests/SwiftSyntaxTest/DiagnosticTest.swift rename to Tests/SwiftSyntaxTest/DiagnosticTests.swift index 5a5e315d7ef..41599a558e3 100644 --- a/Tests/SwiftSyntaxTest/DiagnosticTest.swift +++ b/Tests/SwiftSyntaxTest/DiagnosticTests.swift @@ -27,7 +27,7 @@ fileprivate extension Diagnostic.Message { } } -public class DiagnosticTestCase: XCTestCase { +public class DiagnosticTests: XCTestCase { public static let allTests = [ ("testDiagnosticEmission", testDiagnosticEmission), diff --git a/Tests/SwiftSyntaxTest/IncrementalParsingTests.swift b/Tests/SwiftSyntaxTest/IncrementalParsingTests.swift index 18c2f5f5da2..f86aab23596 100644 --- a/Tests/SwiftSyntaxTest/IncrementalParsingTests.swift +++ b/Tests/SwiftSyntaxTest/IncrementalParsingTests.swift @@ -1,7 +1,7 @@ import XCTest import SwiftSyntax -public class IncrementalParsingTestCase: XCTestCase { +public class IncrementalParsingTests: XCTestCase { public static let allTests = [ ("testIncrementalInvalid", testIncrementalInvalid), diff --git a/Tests/SwiftSyntaxTest/MultithreadingTests.swift b/Tests/SwiftSyntaxTest/MultithreadingTests.swift index c3977a30f51..99dace761da 100644 --- a/Tests/SwiftSyntaxTest/MultithreadingTests.swift +++ b/Tests/SwiftSyntaxTest/MultithreadingTests.swift @@ -1,7 +1,7 @@ import XCTest import SwiftSyntax -public class MultithreadingTestCase: XCTestCase { +public class MultithreadingTests: XCTestCase { public static let allTests = [ ("testPathological", testPathological), diff --git a/Tests/SwiftSyntaxTest/ParseFile.swift b/Tests/SwiftSyntaxTest/ParseFileTests.swift similarity index 96% rename from Tests/SwiftSyntaxTest/ParseFile.swift rename to Tests/SwiftSyntaxTest/ParseFileTests.swift index 65fa8ad5e8c..0be5abb868c 100644 --- a/Tests/SwiftSyntaxTest/ParseFile.swift +++ b/Tests/SwiftSyntaxTest/ParseFileTests.swift @@ -23,7 +23,7 @@ enum Animal { case dog } -public class ParseFileTestCase: XCTestCase { +public class ParseFileTests: XCTestCase { public static let allTests = [ ("testParseSingleFile", testParseSingleFile), diff --git a/Tests/SwiftSyntaxTest/SyntaxChildren.swift b/Tests/SwiftSyntaxTest/SyntaxChildrenTests.swift similarity index 95% rename from Tests/SwiftSyntaxTest/SyntaxChildren.swift rename to Tests/SwiftSyntaxTest/SyntaxChildrenTests.swift index a5e24ac54ef..750c0230dd1 100644 --- a/Tests/SwiftSyntaxTest/SyntaxChildren.swift +++ b/Tests/SwiftSyntaxTest/SyntaxChildrenTests.swift @@ -1,7 +1,7 @@ import XCTest import SwiftSyntax -public class SyntaxChildrenAPITestCase: XCTestCase { +public class SyntaxChildrenTests: XCTestCase { public static let allTests = [ ("testIterateWithAllPresent", testIterateWithAllPresent), diff --git a/Tests/SwiftSyntaxTest/SyntaxCollections.swift b/Tests/SwiftSyntaxTest/SyntaxCollectionsTests.swift similarity index 98% rename from Tests/SwiftSyntaxTest/SyntaxCollections.swift rename to Tests/SwiftSyntaxTest/SyntaxCollectionsTests.swift index e9489aef0b3..dc3da927294 100644 --- a/Tests/SwiftSyntaxTest/SyntaxCollections.swift +++ b/Tests/SwiftSyntaxTest/SyntaxCollectionsTests.swift @@ -8,7 +8,7 @@ fileprivate func integerLiteralElement(_ int: Int) -> ArrayElementSyntax { trailingComma: nil) } -public class SyntaxCollectionsAPITestCase: XCTestCase { +public class SyntaxCollectionsTests: XCTestCase { public static let allTests = [ ("testAppendingElement", testAppendingElement), diff --git a/Tests/SwiftSyntaxTest/SyntaxFactory.swift b/Tests/SwiftSyntaxTest/SyntaxFactoryTests.swift similarity index 99% rename from Tests/SwiftSyntaxTest/SyntaxFactory.swift rename to Tests/SwiftSyntaxTest/SyntaxFactoryTests.swift index 9dfbaa6a52a..7b4318b3128 100644 --- a/Tests/SwiftSyntaxTest/SyntaxFactory.swift +++ b/Tests/SwiftSyntaxTest/SyntaxFactoryTests.swift @@ -16,7 +16,7 @@ fileprivate func cannedStructDecl() -> StructDeclSyntax { } } -public class SyntaxFactoryAPITestCase: XCTestCase { +public class SyntaxFactoryTests: XCTestCase { public static let allTests = [ ("testGenerated", testGenerated), diff --git a/Tests/SwiftSyntaxTest/SyntaxTests.swift b/Tests/SwiftSyntaxTest/SyntaxTests.swift index cef67aba339..02f0b129e41 100644 --- a/Tests/SwiftSyntaxTest/SyntaxTests.swift +++ b/Tests/SwiftSyntaxTest/SyntaxTests.swift @@ -1,7 +1,7 @@ import XCTest import SwiftSyntax -public class SyntaxAPITestCase: XCTestCase { +public class SyntaxTests: XCTestCase { public static let allTests = [ ("testSyntaxAPI", testSyntaxAPI), diff --git a/Tests/SwiftSyntaxTest/ModifierTests.swift b/Tests/SwiftSyntaxTest/SyntaxTreeModifierTests.swift similarity index 100% rename from Tests/SwiftSyntaxTest/ModifierTests.swift rename to Tests/SwiftSyntaxTest/SyntaxTreeModifierTests.swift diff --git a/Tests/SwiftSyntaxTest/VisitorTest.swift b/Tests/SwiftSyntaxTest/SyntaxVisitorTests.swift similarity index 98% rename from Tests/SwiftSyntaxTest/VisitorTest.swift rename to Tests/SwiftSyntaxTest/SyntaxVisitorTests.swift index bc663b10291..c4147beaf24 100644 --- a/Tests/SwiftSyntaxTest/VisitorTest.swift +++ b/Tests/SwiftSyntaxTest/SyntaxVisitorTests.swift @@ -1,7 +1,7 @@ import XCTest import SwiftSyntax -public class SyntaxVisitorTestCase: XCTestCase { +public class SyntaxVisitorTests: XCTestCase { public static let allTests = [ ("testBasic", testBasic), diff --git a/Tests/SwiftSyntaxTest/TokenTest.swift b/Tests/SwiftSyntaxTest/TokenTest.swift index b6d7e659b48..bf82bfedaba 100644 --- a/Tests/SwiftSyntaxTest/TokenTest.swift +++ b/Tests/SwiftSyntaxTest/TokenTest.swift @@ -1,7 +1,7 @@ import XCTest import SwiftSyntax -public class TokenSyntaxTestCase: XCTestCase { +public class TokenTests: XCTestCase { public static let allTests = [ ("testKeywordKinds", testKeywordKinds), diff --git a/Tests/SwiftSyntaxTest/TriviaTests.swift b/Tests/SwiftSyntaxTest/TriviaTests.swift index f5f4520d201..ebf5e359df0 100644 --- a/Tests/SwiftSyntaxTest/TriviaTests.swift +++ b/Tests/SwiftSyntaxTest/TriviaTests.swift @@ -1,7 +1,7 @@ import XCTest import SwiftSyntax -public class TriviaTestCase: XCTestCase { +public class TriviaTests: XCTestCase { public static let allTests = [ ("testTriviaEquatable", testTriviaEquatable), From f61ec829b6667c38e59efb04ad97c491c65b9bd3 Mon Sep 17 00:00:00 2001 From: kitasuke Date: Wed, 24 Jul 2019 12:01:35 +0900 Subject: [PATCH 2/4] Run swift test --generate-linuxmain --- Tests/LinuxMain.swift | 25 +-- .../AbsolutePositionTests.swift | 12 -- .../SwiftSyntaxTest/ClassificationTests.swift | 4 - .../CustomReflecatbleTests.swift | 5 - Tests/SwiftSyntaxTest/DiagnosticTests.swift | 5 - .../IncrementalParsingTests.swift | 5 - .../SwiftSyntaxTest/MultithreadingTests.swift | 5 - Tests/SwiftSyntaxTest/ParseFileTests.swift | 5 - .../SwiftSyntaxTest/SyntaxChildrenTests.swift | 6 - .../SyntaxCollectionsTests.swift | 11 - .../SwiftSyntaxTest/SyntaxFactoryTests.swift | 8 - Tests/SwiftSyntaxTest/SyntaxTests.swift | 5 - .../SyntaxTreeModifierTests.swift | 4 - .../SwiftSyntaxTest/SyntaxVisitorTests.swift | 8 - Tests/SwiftSyntaxTest/TokenTest.swift | 4 - Tests/SwiftSyntaxTest/TriviaTests.swift | 5 - Tests/SwiftSyntaxTest/XCTestManifests.swift | 192 ++++++++++++++++++ 17 files changed, 197 insertions(+), 112 deletions(-) create mode 100644 Tests/SwiftSyntaxTest/XCTestManifests.swift diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift index 86ffff82fe0..20e06a889d5 100644 --- a/Tests/LinuxMain.swift +++ b/Tests/LinuxMain.swift @@ -1,23 +1,8 @@ import XCTest + import SwiftSyntaxTest -XCTMain({ () -> [XCTestCaseEntry] in - var testCases: [XCTestCaseEntry] = [ - testCase(AbsolutePositionTestCase.allTests), - testCase(ClassificationTests.allTests), - testCase(DiagnosticTestCase.allTests), - testCase(IncrementalParsingTestCase.allTests), - testCase(MultithreadingTestCase.allTests), - testCase(ParseFileTestCase.allTests), - testCase(SyntaxChildrenAPITestCase.allTests), - testCase(SyntaxCollectionsAPITestCase.allTests), - testCase(SyntaxFactoryAPITestCase.allTests), - testCase(SyntaxAPITestCase.allTests), - testCase(SyntaxVisitorTestCase.allTests), - testCase(TokenSyntaxTestCase.allTests), - testCase(SyntaxTreeModifierTests.allTests), - testCase(TriviaTests.allTests), - testCase(CustomReflectableTests.allTests), - ] - return testCases -}()) +var tests = [XCTestCaseEntry]() +tests += SwiftSyntaxTest.__allTests() + +XCTMain(tests) diff --git a/Tests/SwiftSyntaxTest/AbsolutePositionTests.swift b/Tests/SwiftSyntaxTest/AbsolutePositionTests.swift index 7705b762006..0462b6d7b64 100644 --- a/Tests/SwiftSyntaxTest/AbsolutePositionTests.swift +++ b/Tests/SwiftSyntaxTest/AbsolutePositionTests.swift @@ -10,18 +10,6 @@ fileprivate class FuncRenamer: SyntaxRewriter { public class AbsolutePositionTests: XCTestCase { - public static let allTests = [ - ("testVisitor", testVisitor), - ("testClosure", testClosure), - ("testRename", testRename), - ("testCurrentFile", testCurrentFile), - ("testRecursion", testRecursion), - ("testTrivias", testTrivias), - ("testImplicit", testImplicit), - ("testWithoutSourceFileRoot", testWithoutSourceFileRoot), - ("testSourceLocation", testSourceLocation), - ] - public func testVisitor() { XCTAssertNoThrow(try { let source = try String(contentsOf: getInput("visitor.swift")) diff --git a/Tests/SwiftSyntaxTest/ClassificationTests.swift b/Tests/SwiftSyntaxTest/ClassificationTests.swift index 205f11669c2..0e2e2073bf2 100644 --- a/Tests/SwiftSyntaxTest/ClassificationTests.swift +++ b/Tests/SwiftSyntaxTest/ClassificationTests.swift @@ -2,10 +2,6 @@ import XCTest import SwiftSyntax public class ClassificationTests: XCTestCase { - public static let allTests = [ - ("testClassification", testClassification), - ("testTokenClassification", testTokenClassification), - ] public func testClassification() { let source = "// blah.\nlet x/*yo*/ = 0" diff --git a/Tests/SwiftSyntaxTest/CustomReflecatbleTests.swift b/Tests/SwiftSyntaxTest/CustomReflecatbleTests.swift index 180a97c4aee..ee18a9ab2ca 100644 --- a/Tests/SwiftSyntaxTest/CustomReflecatbleTests.swift +++ b/Tests/SwiftSyntaxTest/CustomReflecatbleTests.swift @@ -3,11 +3,6 @@ import SwiftSyntax public class CustomReflectableTests: XCTestCase { - public static let allTests = [ - ("testDump", testDump), - ("testConformanceToCustomReflectable", testConformanceToCustomReflectable), - ] - public func testDump() { struct TestCase { diff --git a/Tests/SwiftSyntaxTest/DiagnosticTests.swift b/Tests/SwiftSyntaxTest/DiagnosticTests.swift index 41599a558e3..08df4cbd19c 100644 --- a/Tests/SwiftSyntaxTest/DiagnosticTests.swift +++ b/Tests/SwiftSyntaxTest/DiagnosticTests.swift @@ -29,11 +29,6 @@ fileprivate extension Diagnostic.Message { public class DiagnosticTests: XCTestCase { - public static let allTests = [ - ("testDiagnosticEmission", testDiagnosticEmission), - ("testSourceLocations", testSourceLocations), - ] - public func testDiagnosticEmission() { let startLoc = loc() let fixLoc = loc() diff --git a/Tests/SwiftSyntaxTest/IncrementalParsingTests.swift b/Tests/SwiftSyntaxTest/IncrementalParsingTests.swift index f86aab23596..c1fa489c5a4 100644 --- a/Tests/SwiftSyntaxTest/IncrementalParsingTests.swift +++ b/Tests/SwiftSyntaxTest/IncrementalParsingTests.swift @@ -3,11 +3,6 @@ import SwiftSyntax public class IncrementalParsingTests: XCTestCase { - public static let allTests = [ - ("testIncrementalInvalid", testIncrementalInvalid), - ("testReusedNode", testReusedNode), - ] - public func testIncrementalInvalid() { let original = "struct A { func f() {" let step: (String, (Int, Int, String)) = diff --git a/Tests/SwiftSyntaxTest/MultithreadingTests.swift b/Tests/SwiftSyntaxTest/MultithreadingTests.swift index 99dace761da..b3b753e8ed9 100644 --- a/Tests/SwiftSyntaxTest/MultithreadingTests.swift +++ b/Tests/SwiftSyntaxTest/MultithreadingTests.swift @@ -3,11 +3,6 @@ import SwiftSyntax public class MultithreadingTests: XCTestCase { - public static let allTests = [ - ("testPathological", testPathological), - ("testTwoAccesses", testTwoAccesses), - ] - public func testPathological() { let tuple = SyntaxFactory.makeVoidTupleType() diff --git a/Tests/SwiftSyntaxTest/ParseFileTests.swift b/Tests/SwiftSyntaxTest/ParseFileTests.swift index 0be5abb868c..e4edf247344 100644 --- a/Tests/SwiftSyntaxTest/ParseFileTests.swift +++ b/Tests/SwiftSyntaxTest/ParseFileTests.swift @@ -25,11 +25,6 @@ enum Animal { public class ParseFileTests: XCTestCase { - public static let allTests = [ - ("testParseSingleFile", testParseSingleFile), - ("testEnumCaseStructure", testEnumCaseStructure) - ] - public func testParseSingleFile() { let currentFile = URL(fileURLWithPath: #file) XCTAssertNoThrow(try { diff --git a/Tests/SwiftSyntaxTest/SyntaxChildrenTests.swift b/Tests/SwiftSyntaxTest/SyntaxChildrenTests.swift index 750c0230dd1..374c87d3cd9 100644 --- a/Tests/SwiftSyntaxTest/SyntaxChildrenTests.swift +++ b/Tests/SwiftSyntaxTest/SyntaxChildrenTests.swift @@ -3,12 +3,6 @@ import SwiftSyntax public class SyntaxChildrenTests: XCTestCase { - public static let allTests = [ - ("testIterateWithAllPresent", testIterateWithAllPresent), - ("testIterateWithSomeMissing", testIterateWithSomeMissing), - ("testIterateWithAllMissing", testIterateWithAllMissing), - ] - public func testIterateWithAllPresent() { let returnStmt = SyntaxFactory.makeReturnStmt( returnKeyword: SyntaxFactory.makeReturnKeyword(), diff --git a/Tests/SwiftSyntaxTest/SyntaxCollectionsTests.swift b/Tests/SwiftSyntaxTest/SyntaxCollectionsTests.swift index dc3da927294..0c8076b326a 100644 --- a/Tests/SwiftSyntaxTest/SyntaxCollectionsTests.swift +++ b/Tests/SwiftSyntaxTest/SyntaxCollectionsTests.swift @@ -10,17 +10,6 @@ fileprivate func integerLiteralElement(_ int: Int) -> ArrayElementSyntax { public class SyntaxCollectionsTests: XCTestCase { - public static let allTests = [ - ("testAppendingElement", testAppendingElement), - ("testInsertingElement", testInsertingElement), - ("testPrependingElement", testPrependingElement), - ("testRemovingFirstElement", testRemovingFirstElement), - ("testRemovingLastElement", testRemovingLastElement), - ("testRemovingElement", testRemovingElement), - ("testReplacingElement", testReplacingElement), - ("testIteration", testIteration), - ] - public func testAppendingElement() { let arrayElementList = SyntaxFactory.makeArrayElementList([ integerLiteralElement(0) diff --git a/Tests/SwiftSyntaxTest/SyntaxFactoryTests.swift b/Tests/SwiftSyntaxTest/SyntaxFactoryTests.swift index 7b4318b3128..ddf4102e19a 100644 --- a/Tests/SwiftSyntaxTest/SyntaxFactoryTests.swift +++ b/Tests/SwiftSyntaxTest/SyntaxFactoryTests.swift @@ -18,14 +18,6 @@ fileprivate func cannedStructDecl() -> StructDeclSyntax { public class SyntaxFactoryTests: XCTestCase { - public static let allTests = [ - ("testGenerated", testGenerated), - ("testTokenSyntax", testTokenSyntax), - ("testFunctionCallSyntaxBuilder", testFunctionCallSyntaxBuilder), - ("testWithOptionalChild", testWithOptionalChild), - ("testUnknownSyntax", testUnknownSyntax), - ] - public func testGenerated() { let structDecl = cannedStructDecl() diff --git a/Tests/SwiftSyntaxTest/SyntaxTests.swift b/Tests/SwiftSyntaxTest/SyntaxTests.swift index 02f0b129e41..5494968ca40 100644 --- a/Tests/SwiftSyntaxTest/SyntaxTests.swift +++ b/Tests/SwiftSyntaxTest/SyntaxTests.swift @@ -3,11 +3,6 @@ import SwiftSyntax public class SyntaxTests: XCTestCase { - public static let allTests = [ - ("testSyntaxAPI", testSyntaxAPI), - ("testPositions", testPositions), - ] - public func testSyntaxAPI() { let source = "struct A { func f() {} }" let tree = try! SyntaxParser.parse(source: source) diff --git a/Tests/SwiftSyntaxTest/SyntaxTreeModifierTests.swift b/Tests/SwiftSyntaxTest/SyntaxTreeModifierTests.swift index aa4ec688d63..c9ec6c7732d 100644 --- a/Tests/SwiftSyntaxTest/SyntaxTreeModifierTests.swift +++ b/Tests/SwiftSyntaxTest/SyntaxTreeModifierTests.swift @@ -17,10 +17,6 @@ fileprivate func cannedVarDecl() -> VariableDeclSyntax { public class SyntaxTreeModifierTests: XCTestCase { - public static let allTests = [ - ("testAccessorAsModifier", testAccessorAsModifier) - ] - public func testAccessorAsModifier() { var VD = cannedVarDecl() XCTAssertEqual("\(VD)", "let a: Int") diff --git a/Tests/SwiftSyntaxTest/SyntaxVisitorTests.swift b/Tests/SwiftSyntaxTest/SyntaxVisitorTests.swift index c4147beaf24..430da06a069 100644 --- a/Tests/SwiftSyntaxTest/SyntaxVisitorTests.swift +++ b/Tests/SwiftSyntaxTest/SyntaxVisitorTests.swift @@ -3,14 +3,6 @@ import SwiftSyntax public class SyntaxVisitorTests: XCTestCase { - public static let allTests = [ - ("testBasic", testBasic), - ("testRewritingNodeWithEmptyChild", testRewritingNodeWithEmptyChild), - ("testSyntaxRewriterVisitAny", testSyntaxRewriterVisitAny), - ("testSyntaxRewriterVisitCollection", testSyntaxRewriterVisitCollection), - ("testVisitorClass", testVisitorClass), - ] - public func testBasic() { struct FuncCounter: SyntaxVisitor { var funcCount = 0 diff --git a/Tests/SwiftSyntaxTest/TokenTest.swift b/Tests/SwiftSyntaxTest/TokenTest.swift index bf82bfedaba..c22e8a5be9e 100644 --- a/Tests/SwiftSyntaxTest/TokenTest.swift +++ b/Tests/SwiftSyntaxTest/TokenTest.swift @@ -3,10 +3,6 @@ import SwiftSyntax public class TokenTests: XCTestCase { - public static let allTests = [ - ("testKeywordKinds", testKeywordKinds), - ] - public func testKeywordKinds() { XCTAssertTrue(TokenKind.operatorKeyword.isKeyword) XCTAssertTrue(TokenKind.funcKeyword.isKeyword) diff --git a/Tests/SwiftSyntaxTest/TriviaTests.swift b/Tests/SwiftSyntaxTest/TriviaTests.swift index ebf5e359df0..ab9292897ee 100644 --- a/Tests/SwiftSyntaxTest/TriviaTests.swift +++ b/Tests/SwiftSyntaxTest/TriviaTests.swift @@ -3,11 +3,6 @@ import SwiftSyntax public class TriviaTests: XCTestCase { - public static let allTests = [ - ("testTriviaEquatable", testTriviaEquatable), - ("testTriviaPieceEquatable", testTriviaPieceEquatable) - ] - func testTriviaEquatable() { XCTAssertEqual([.spaces(2), .tabs(1)] as Trivia, [.spaces(2), .tabs(1)]) XCTAssertNotEqual([.spaces(2), .tabs(1)] as Trivia, [.spaces(2), .tabs(2)]) diff --git a/Tests/SwiftSyntaxTest/XCTestManifests.swift b/Tests/SwiftSyntaxTest/XCTestManifests.swift new file mode 100644 index 00000000000..1ea01fd3b36 --- /dev/null +++ b/Tests/SwiftSyntaxTest/XCTestManifests.swift @@ -0,0 +1,192 @@ +#if !canImport(ObjectiveC) +import XCTest + +extension AbsolutePositionTests { + // DO NOT MODIFY: This is autogenerated, use: + // `swift test --generate-linuxmain` + // to regenerate. + static let __allTests__AbsolutePositionTests = [ + ("testClosure", testClosure), + ("testCurrentFile", testCurrentFile), + ("testImplicit", testImplicit), + ("testRecursion", testRecursion), + ("testRename", testRename), + ("testSourceLocation", testSourceLocation), + ("testTrivias", testTrivias), + ("testVisitor", testVisitor), + ("testWithoutSourceFileRoot", testWithoutSourceFileRoot), + ] +} + +extension ClassificationTests { + // DO NOT MODIFY: This is autogenerated, use: + // `swift test --generate-linuxmain` + // to regenerate. + static let __allTests__ClassificationTests = [ + ("testClassification", testClassification), + ("testTokenClassification", testTokenClassification), + ] +} + +extension CustomReflectableTests { + // DO NOT MODIFY: This is autogenerated, use: + // `swift test --generate-linuxmain` + // to regenerate. + static let __allTests__CustomReflectableTests = [ + ("testConformanceToCustomReflectable", testConformanceToCustomReflectable), + ("testDump", testDump), + ] +} + +extension DiagnosticTests { + // DO NOT MODIFY: This is autogenerated, use: + // `swift test --generate-linuxmain` + // to regenerate. + static let __allTests__DiagnosticTests = [ + ("testDiagnosticEmission", testDiagnosticEmission), + ("testSourceLocations", testSourceLocations), + ] +} + +extension IncrementalParsingTests { + // DO NOT MODIFY: This is autogenerated, use: + // `swift test --generate-linuxmain` + // to regenerate. + static let __allTests__IncrementalParsingTests = [ + ("testIncrementalInvalid", testIncrementalInvalid), + ("testReusedNode", testReusedNode), + ] +} + +extension MultithreadingTests { + // DO NOT MODIFY: This is autogenerated, use: + // `swift test --generate-linuxmain` + // to regenerate. + static let __allTests__MultithreadingTests = [ + ("testPathological", testPathological), + ("testTwoAccesses", testTwoAccesses), + ] +} + +extension ParseFileTests { + // DO NOT MODIFY: This is autogenerated, use: + // `swift test --generate-linuxmain` + // to regenerate. + static let __allTests__ParseFileTests = [ + ("testEnumCaseStructure", testEnumCaseStructure), + ("testParseSingleFile", testParseSingleFile), + ] +} + +extension SyntaxChildrenTests { + // DO NOT MODIFY: This is autogenerated, use: + // `swift test --generate-linuxmain` + // to regenerate. + static let __allTests__SyntaxChildrenTests = [ + ("testIterateWithAllMissing", testIterateWithAllMissing), + ("testIterateWithAllPresent", testIterateWithAllPresent), + ("testIterateWithSomeMissing", testIterateWithSomeMissing), + ] +} + +extension SyntaxCollectionsTests { + // DO NOT MODIFY: This is autogenerated, use: + // `swift test --generate-linuxmain` + // to regenerate. + static let __allTests__SyntaxCollectionsTests = [ + ("testAppendingElement", testAppendingElement), + ("testInsertingElement", testInsertingElement), + ("testIteration", testIteration), + ("testPrependingElement", testPrependingElement), + ("testRemovingElement", testRemovingElement), + ("testRemovingFirstElement", testRemovingFirstElement), + ("testRemovingLastElement", testRemovingLastElement), + ("testReplacingElement", testReplacingElement), + ] +} + +extension SyntaxFactoryTests { + // DO NOT MODIFY: This is autogenerated, use: + // `swift test --generate-linuxmain` + // to regenerate. + static let __allTests__SyntaxFactoryTests = [ + ("testFunctionCallSyntaxBuilder", testFunctionCallSyntaxBuilder), + ("testGenerated", testGenerated), + ("testTokenSyntax", testTokenSyntax), + ("testUnknownSyntax", testUnknownSyntax), + ("testWithOptionalChild", testWithOptionalChild), + ] +} + +extension SyntaxTests { + // DO NOT MODIFY: This is autogenerated, use: + // `swift test --generate-linuxmain` + // to regenerate. + static let __allTests__SyntaxTests = [ + ("testPositions", testPositions), + ("testSyntaxAPI", testSyntaxAPI), + ] +} + +extension SyntaxTreeModifierTests { + // DO NOT MODIFY: This is autogenerated, use: + // `swift test --generate-linuxmain` + // to regenerate. + static let __allTests__SyntaxTreeModifierTests = [ + ("testAccessorAsModifier", testAccessorAsModifier), + ] +} + +extension SyntaxVisitorTests { + // DO NOT MODIFY: This is autogenerated, use: + // `swift test --generate-linuxmain` + // to regenerate. + static let __allTests__SyntaxVisitorTests = [ + ("testBasic", testBasic), + ("testRewritingNodeWithEmptyChild", testRewritingNodeWithEmptyChild), + ("testSyntaxRewriterVisitAny", testSyntaxRewriterVisitAny), + ("testSyntaxRewriterVisitCollection", testSyntaxRewriterVisitCollection), + ("testVisitorClass", testVisitorClass), + ] +} + +extension TokenTests { + // DO NOT MODIFY: This is autogenerated, use: + // `swift test --generate-linuxmain` + // to regenerate. + static let __allTests__TokenTests = [ + ("testKeywordKinds", testKeywordKinds), + ("testTokenLgnth", testTokenLgnth), + ] +} + +extension TriviaTests { + // DO NOT MODIFY: This is autogenerated, use: + // `swift test --generate-linuxmain` + // to regenerate. + static let __allTests__TriviaTests = [ + ("testTriviaEquatable", testTriviaEquatable), + ("testTriviaPieceEquatable", testTriviaPieceEquatable), + ] +} + +public func __allTests() -> [XCTestCaseEntry] { + return [ + testCase(AbsolutePositionTests.__allTests__AbsolutePositionTests), + testCase(ClassificationTests.__allTests__ClassificationTests), + testCase(CustomReflectableTests.__allTests__CustomReflectableTests), + testCase(DiagnosticTests.__allTests__DiagnosticTests), + testCase(IncrementalParsingTests.__allTests__IncrementalParsingTests), + testCase(MultithreadingTests.__allTests__MultithreadingTests), + testCase(ParseFileTests.__allTests__ParseFileTests), + testCase(SyntaxChildrenTests.__allTests__SyntaxChildrenTests), + testCase(SyntaxCollectionsTests.__allTests__SyntaxCollectionsTests), + testCase(SyntaxFactoryTests.__allTests__SyntaxFactoryTests), + testCase(SyntaxTests.__allTests__SyntaxTests), + testCase(SyntaxTreeModifierTests.__allTests__SyntaxTreeModifierTests), + testCase(SyntaxVisitorTests.__allTests__SyntaxVisitorTests), + testCase(TokenTests.__allTests__TokenTests), + testCase(TriviaTests.__allTests__TriviaTests), + ] +} +#endif From 3d45c04dd81b88e7aba287233be217082dcd1935 Mon Sep 17 00:00:00 2001 From: kitasuke Date: Wed, 31 Jul 2019 14:13:04 +0900 Subject: [PATCH 3/4] Use --enable-test-discovery instead to generate test file for Linux --- Tests/LinuxMain.swift | 8 - Tests/SwiftSyntaxTest/XCTestManifests.swift | 192 -------------------- 2 files changed, 200 deletions(-) delete mode 100644 Tests/LinuxMain.swift delete mode 100644 Tests/SwiftSyntaxTest/XCTestManifests.swift diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift deleted file mode 100644 index 20e06a889d5..00000000000 --- a/Tests/LinuxMain.swift +++ /dev/null @@ -1,8 +0,0 @@ -import XCTest - -import SwiftSyntaxTest - -var tests = [XCTestCaseEntry]() -tests += SwiftSyntaxTest.__allTests() - -XCTMain(tests) diff --git a/Tests/SwiftSyntaxTest/XCTestManifests.swift b/Tests/SwiftSyntaxTest/XCTestManifests.swift deleted file mode 100644 index 1ea01fd3b36..00000000000 --- a/Tests/SwiftSyntaxTest/XCTestManifests.swift +++ /dev/null @@ -1,192 +0,0 @@ -#if !canImport(ObjectiveC) -import XCTest - -extension AbsolutePositionTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__AbsolutePositionTests = [ - ("testClosure", testClosure), - ("testCurrentFile", testCurrentFile), - ("testImplicit", testImplicit), - ("testRecursion", testRecursion), - ("testRename", testRename), - ("testSourceLocation", testSourceLocation), - ("testTrivias", testTrivias), - ("testVisitor", testVisitor), - ("testWithoutSourceFileRoot", testWithoutSourceFileRoot), - ] -} - -extension ClassificationTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__ClassificationTests = [ - ("testClassification", testClassification), - ("testTokenClassification", testTokenClassification), - ] -} - -extension CustomReflectableTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__CustomReflectableTests = [ - ("testConformanceToCustomReflectable", testConformanceToCustomReflectable), - ("testDump", testDump), - ] -} - -extension DiagnosticTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__DiagnosticTests = [ - ("testDiagnosticEmission", testDiagnosticEmission), - ("testSourceLocations", testSourceLocations), - ] -} - -extension IncrementalParsingTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__IncrementalParsingTests = [ - ("testIncrementalInvalid", testIncrementalInvalid), - ("testReusedNode", testReusedNode), - ] -} - -extension MultithreadingTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__MultithreadingTests = [ - ("testPathological", testPathological), - ("testTwoAccesses", testTwoAccesses), - ] -} - -extension ParseFileTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__ParseFileTests = [ - ("testEnumCaseStructure", testEnumCaseStructure), - ("testParseSingleFile", testParseSingleFile), - ] -} - -extension SyntaxChildrenTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__SyntaxChildrenTests = [ - ("testIterateWithAllMissing", testIterateWithAllMissing), - ("testIterateWithAllPresent", testIterateWithAllPresent), - ("testIterateWithSomeMissing", testIterateWithSomeMissing), - ] -} - -extension SyntaxCollectionsTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__SyntaxCollectionsTests = [ - ("testAppendingElement", testAppendingElement), - ("testInsertingElement", testInsertingElement), - ("testIteration", testIteration), - ("testPrependingElement", testPrependingElement), - ("testRemovingElement", testRemovingElement), - ("testRemovingFirstElement", testRemovingFirstElement), - ("testRemovingLastElement", testRemovingLastElement), - ("testReplacingElement", testReplacingElement), - ] -} - -extension SyntaxFactoryTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__SyntaxFactoryTests = [ - ("testFunctionCallSyntaxBuilder", testFunctionCallSyntaxBuilder), - ("testGenerated", testGenerated), - ("testTokenSyntax", testTokenSyntax), - ("testUnknownSyntax", testUnknownSyntax), - ("testWithOptionalChild", testWithOptionalChild), - ] -} - -extension SyntaxTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__SyntaxTests = [ - ("testPositions", testPositions), - ("testSyntaxAPI", testSyntaxAPI), - ] -} - -extension SyntaxTreeModifierTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__SyntaxTreeModifierTests = [ - ("testAccessorAsModifier", testAccessorAsModifier), - ] -} - -extension SyntaxVisitorTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__SyntaxVisitorTests = [ - ("testBasic", testBasic), - ("testRewritingNodeWithEmptyChild", testRewritingNodeWithEmptyChild), - ("testSyntaxRewriterVisitAny", testSyntaxRewriterVisitAny), - ("testSyntaxRewriterVisitCollection", testSyntaxRewriterVisitCollection), - ("testVisitorClass", testVisitorClass), - ] -} - -extension TokenTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__TokenTests = [ - ("testKeywordKinds", testKeywordKinds), - ("testTokenLgnth", testTokenLgnth), - ] -} - -extension TriviaTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__TriviaTests = [ - ("testTriviaEquatable", testTriviaEquatable), - ("testTriviaPieceEquatable", testTriviaPieceEquatable), - ] -} - -public func __allTests() -> [XCTestCaseEntry] { - return [ - testCase(AbsolutePositionTests.__allTests__AbsolutePositionTests), - testCase(ClassificationTests.__allTests__ClassificationTests), - testCase(CustomReflectableTests.__allTests__CustomReflectableTests), - testCase(DiagnosticTests.__allTests__DiagnosticTests), - testCase(IncrementalParsingTests.__allTests__IncrementalParsingTests), - testCase(MultithreadingTests.__allTests__MultithreadingTests), - testCase(ParseFileTests.__allTests__ParseFileTests), - testCase(SyntaxChildrenTests.__allTests__SyntaxChildrenTests), - testCase(SyntaxCollectionsTests.__allTests__SyntaxCollectionsTests), - testCase(SyntaxFactoryTests.__allTests__SyntaxFactoryTests), - testCase(SyntaxTests.__allTests__SyntaxTests), - testCase(SyntaxTreeModifierTests.__allTests__SyntaxTreeModifierTests), - testCase(SyntaxVisitorTests.__allTests__SyntaxVisitorTests), - testCase(TokenTests.__allTests__TokenTests), - testCase(TriviaTests.__allTests__TriviaTests), - ] -} -#endif From dd37bf6c69b909ef12825ab657ed48826dce0d26 Mon Sep 17 00:00:00 2001 From: kitasuke Date: Wed, 31 Jul 2019 15:22:42 +0900 Subject: [PATCH 4/4] Add --enable-test-discovery option for test command Fix typo --- build-script.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/build-script.py b/build-script.py index 84f86d2d012..7df02e0c616 100755 --- a/build-script.py +++ b/build-script.py @@ -168,6 +168,9 @@ def get_swiftpm_invocation(spm_exec, build_dir, parser_header_dir, swiftpm_call = ['swift', 'build'] elif spm_exec == 'swift test': swiftpm_call = ['swift', 'test'] + + # To discover test files for Linux + swiftpm_call.extend(['--enable-test-discovery']) else: swiftpm_call = [spm_exec] @@ -469,12 +472,12 @@ def main(): testing_group.add_argument('--swift-build-exec', default='swift build', help=''' Path to the swift-build executable that is used to build SwiftPM projects - If not specified the the 'swift build' command will be used. + If not specified the 'swift build' command will be used. ''') testing_group.add_argument('--swift-test-exec', default='swift test', help=''' Path to the swift-test executable that is used to test SwiftPM projects - If not specified the the 'swift test' command will be used. + If not specified the 'swift test' command will be used. ''') testing_group.add_argument('--swiftc-exec', default='swiftc', help=''' Path to the swift executable. If not specified the swiftc exeuctable