diff --git a/Sources/SwiftSyntax/SwiftcInvocation.swift b/Sources/SwiftSyntax/SwiftcInvocation.swift index 9c1dda60254..bd5f0305b77 100644 --- a/Sources/SwiftSyntax/SwiftcInvocation.swift +++ b/Sources/SwiftSyntax/SwiftcInvocation.swift @@ -52,15 +52,21 @@ private func runCore(_ executable: URL, _ arguments: [String] = []) -> ProcessResult { let stdoutPipe = Pipe() var stdoutData = Data() - stdoutPipe.fileHandleForReading.readabilityHandler = { file in - stdoutData.append(file.availableData) + let stdoutSource = DispatchSource.makeReadSource( + fileDescriptor: stdoutPipe.fileHandleForReading.fileDescriptor) + stdoutSource.setEventHandler { + stdoutData.append(stdoutPipe.fileHandleForReading.availableData) } + stdoutSource.resume() let stderrPipe = Pipe() var stderrData = Data() - stderrPipe.fileHandleForReading.readabilityHandler = { file in - stderrData.append(file.availableData) + let stderrSource = DispatchSource.makeReadSource( + fileDescriptor: stderrPipe.fileHandleForReading.fileDescriptor) + stderrSource.setEventHandler { + stderrData.append(stderrPipe.fileHandleForReading.availableData) } + stderrSource.resume() let process = Process() process.launchPath = executable.path diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift new file mode 100644 index 00000000000..2385dc58522 --- /dev/null +++ b/Tests/LinuxMain.swift @@ -0,0 +1,14 @@ +import XCTest +import SwiftSyntaxTest + +XCTMain([ + testCase(AbsolutePositionTestCase.allTests), + testCase(DecodeSyntaxTestCase.allTests), + testCase(DiagnosticTestCase.allTests), + testCase(LazyCachingTestCase.allTests), + testCase(ParseFileTestCase.allTests), + testCase(SyntaxChildrenAPITestCase.allTests), + testCase(SyntaxCollectionsAPITestCase.allTests), + testCase(SyntaxFactoryAPITestCase.allTests), + testCase(SyntaxVisitorTestCase.allTests), +]) diff --git a/Tests/SwiftSyntaxTest/AbsolutePosition.swift b/Tests/SwiftSyntaxTest/AbsolutePosition.swift index b09e1d8c417..d0f43cdc929 100644 --- a/Tests/SwiftSyntaxTest/AbsolutePosition.swift +++ b/Tests/SwiftSyntaxTest/AbsolutePosition.swift @@ -9,6 +9,18 @@ fileprivate class FuncRenamer: SyntaxRewriter { } public class AbsolutePositionTestCase: XCTestCase { + + public static let allTests = [ + ("testVisitor", testVisitor), + ("testClosure", testClosure), + ("testRename", testRename), + ("testCurrentFile", testCurrentFile), + ("testRecursion", testRecursion), + ("testTrivias", testTrivias), + ("testImplicit", testImplicit), + ("testWithoutSourceFileRoot", testWithoutSourceFileRoot), + ] + public func testVisitor() { XCTAssertNoThrow(try { let source = try String(contentsOf: getInput("visitor.swift")) diff --git a/Tests/SwiftSyntaxTest/DeserializeFile.swift b/Tests/SwiftSyntaxTest/DeserializeFile.swift index b0855e1ee5d..72589b143c2 100644 --- a/Tests/SwiftSyntaxTest/DeserializeFile.swift +++ b/Tests/SwiftSyntaxTest/DeserializeFile.swift @@ -1,7 +1,12 @@ import XCTest import SwiftSyntax -public class DecodeSytnaxTestCase: XCTestCase { +public class DecodeSyntaxTestCase: XCTestCase { + + public static let allTests = [ + ("testBasic", testBasic), + ] + public func testBasic() { XCTAssertNoThrow(try { let inputFile = getInput("visitor.swift") diff --git a/Tests/SwiftSyntaxTest/DiagnosticTest.swift b/Tests/SwiftSyntaxTest/DiagnosticTest.swift index 329c1b468bc..4f783ff7c1e 100644 --- a/Tests/SwiftSyntaxTest/DiagnosticTest.swift +++ b/Tests/SwiftSyntaxTest/DiagnosticTest.swift @@ -28,6 +28,12 @@ fileprivate extension Diagnostic.Message { } public class DiagnosticTestCase: XCTestCase { + + public static let allTests = [ + ("testDiagnosticEmission", testDiagnosticEmission), + ("testSourceLocations", testSourceLocations), + ] + public func testDiagnosticEmission() { let startLoc = loc() let fixLoc = loc() diff --git a/Tests/SwiftSyntaxTest/LazyCaching.swift b/Tests/SwiftSyntaxTest/LazyCaching.swift index 08960199031..abfe7b8a36b 100644 --- a/Tests/SwiftSyntaxTest/LazyCaching.swift +++ b/Tests/SwiftSyntaxTest/LazyCaching.swift @@ -1,7 +1,13 @@ import XCTest import SwiftSyntax -class LazyCachingTestCase: XCTestCase { +public class LazyCachingTestCase: XCTestCase { + + public static let allTests = [ + ("testPathological", testPathological), + ("testTwoAccesses", testTwoAccesses), + ] + public func testPathological() { let tuple = SyntaxFactory.makeVoidTupleType() diff --git a/Tests/SwiftSyntaxTest/ParseFile.swift b/Tests/SwiftSyntaxTest/ParseFile.swift index fc71e8c8b1f..4cc6ffb40db 100644 --- a/Tests/SwiftSyntaxTest/ParseFile.swift +++ b/Tests/SwiftSyntaxTest/ParseFile.swift @@ -19,6 +19,11 @@ fileprivate class Test: NSObject { #endif public class ParseFileTestCase: XCTestCase { + + public static let allTests = [ + ("testParseSingleFile", testParseSingleFile) + ] + public func testParseSingleFile() { let currentFile = URL(fileURLWithPath: #file) XCTAssertNoThrow(try { diff --git a/Tests/SwiftSyntaxTest/SyntaxChildren.swift b/Tests/SwiftSyntaxTest/SyntaxChildren.swift index c99140179d3..a5e24ac54ef 100644 --- a/Tests/SwiftSyntaxTest/SyntaxChildren.swift +++ b/Tests/SwiftSyntaxTest/SyntaxChildren.swift @@ -2,6 +2,13 @@ import XCTest import SwiftSyntax public class SyntaxChildrenAPITestCase: 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/SyntaxCollections.swift b/Tests/SwiftSyntaxTest/SyntaxCollections.swift index 44a0cbe7ac9..b4517433238 100644 --- a/Tests/SwiftSyntaxTest/SyntaxCollections.swift +++ b/Tests/SwiftSyntaxTest/SyntaxCollections.swift @@ -9,6 +9,17 @@ fileprivate func integerLiteralElement(_ int: Int) -> ArrayElementSyntax { } public class SyntaxCollectionsAPITestCase: XCTestCase { + + public static let allTests = [ + ("testAppendingElement", testAppendingElement), + ("testInsertingElement", testInsertingElement), + ("testPrependingElement", testPrependingElement), + ("testRemovingFirstElement", testRemovingFirstElement), + ("testRemovingLastElement", testRemovingLastElement), + ("testRemovingElement", testRemovingElement), + ("testReplacingElement", testReplacingElement), + ] + public func testAppendingElement() { let arrayElementList = SyntaxFactory.makeArrayElementList([ integerLiteralElement(0) diff --git a/Tests/SwiftSyntaxTest/SyntaxFactory.swift b/Tests/SwiftSyntaxTest/SyntaxFactory.swift index 5ede24919d0..cadc84d7351 100644 --- a/Tests/SwiftSyntaxTest/SyntaxFactory.swift +++ b/Tests/SwiftSyntaxTest/SyntaxFactory.swift @@ -17,6 +17,13 @@ fileprivate func cannedStructDecl() -> StructDeclSyntax { } public class SyntaxFactoryAPITestCase: XCTestCase { + + public static let allTests = [ + ("testGenerated", testGenerated), + ("testTokenSyntax", testTokenSyntax), + ("testFunctionCallSyntaxBuilder", testFunctionCallSyntaxBuilder), + ] + public func testGenerated() { let structDecl = cannedStructDecl() diff --git a/Tests/SwiftSyntaxTest/VisitorTest.swift b/Tests/SwiftSyntaxTest/VisitorTest.swift index 0cf0714e601..1941c84fa84 100644 --- a/Tests/SwiftSyntaxTest/VisitorTest.swift +++ b/Tests/SwiftSyntaxTest/VisitorTest.swift @@ -2,6 +2,14 @@ import XCTest import SwiftSyntax public class SyntaxVisitorTestCase: XCTestCase { + + public static let allTests = [ + ("testBasic", testBasic), + ("testRewritingNodeWithEmptyChild", testRewritingNodeWithEmptyChild), + ("testSyntaxRewriterVisitAny", testSyntaxRewriterVisitAny), + ("testSyntaxRewriterVisitCollection", testSyntaxRewriterVisitCollection), + ] + public func testBasic() { class FuncCounter: SyntaxVisitor { var funcCount = 0