Skip to content

Auto generate linux test #136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions Tests/LinuxMain.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,7 @@ 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),
("testSourceLocation", testSourceLocation),
]
public class AbsolutePositionTests: XCTestCase {

public func testVisitor() {
XCTAssertNoThrow(try {
Expand Down Expand Up @@ -106,8 +94,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),
Expand All @@ -129,12 +117,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)

Expand All @@ -146,18 +134,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)
}
Expand Down
4 changes: 0 additions & 4 deletions Tests/SwiftSyntaxTest/ClassificationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 0 additions & 5 deletions Tests/SwiftSyntaxTest/CustomReflecatbleTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ import SwiftSyntax


public class CustomReflectableTests: XCTestCase {
public static let allTests = [
("testDump", testDump),
("testConformanceToCustomReflectable", testConformanceToCustomReflectable),
]


public func testDump() {
struct TestCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,7 @@ fileprivate extension Diagnostic.Message {
}
}

public class DiagnosticTestCase: XCTestCase {

public static let allTests = [
("testDiagnosticEmission", testDiagnosticEmission),
("testSourceLocations", testSourceLocations),
]
public class DiagnosticTests: XCTestCase {

public func testDiagnosticEmission() {
let startLoc = loc()
Expand Down
7 changes: 1 addition & 6 deletions Tests/SwiftSyntaxTest/IncrementalParsingTests.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import XCTest
import SwiftSyntax

public class IncrementalParsingTestCase: XCTestCase {

public static let allTests = [
("testIncrementalInvalid", testIncrementalInvalid),
("testReusedNode", testReusedNode),
]
public class IncrementalParsingTests: XCTestCase {

public func testIncrementalInvalid() {
let original = "struct A { func f() {"
Expand Down
7 changes: 1 addition & 6 deletions Tests/SwiftSyntaxTest/MultithreadingTests.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import XCTest
import SwiftSyntax

public class MultithreadingTestCase: XCTestCase {

public static let allTests = [
("testPathological", testPathological),
("testTwoAccesses", testTwoAccesses),
]
public class MultithreadingTests: XCTestCase {

public func testPathological() {
let tuple = SyntaxFactory.makeVoidTupleType()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@ enum Animal {
case dog
}

public class ParseFileTestCase: XCTestCase {

public static let allTests = [
("testParseSingleFile", testParseSingleFile),
("testEnumCaseStructure", testEnumCaseStructure)
]
public class ParseFileTests: XCTestCase {

public func testParseSingleFile() {
let currentFile = URL(fileURLWithPath: #file)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import XCTest
import SwiftSyntax

public class SyntaxChildrenAPITestCase: XCTestCase {

public static let allTests = [
("testIterateWithAllPresent", testIterateWithAllPresent),
("testIterateWithSomeMissing", testIterateWithSomeMissing),
("testIterateWithAllMissing", testIterateWithAllMissing),
]
public class SyntaxChildrenTests: XCTestCase {

public func testIterateWithAllPresent() {
let returnStmt = SyntaxFactory.makeReturnStmt(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,7 @@ fileprivate func integerLiteralElement(_ int: Int) -> ArrayElementSyntax {
trailingComma: nil)
}

public class SyntaxCollectionsAPITestCase: XCTestCase {

public static let allTests = [
("testAppendingElement", testAppendingElement),
("testInsertingElement", testInsertingElement),
("testPrependingElement", testPrependingElement),
("testRemovingFirstElement", testRemovingFirstElement),
("testRemovingLastElement", testRemovingLastElement),
("testRemovingElement", testRemovingElement),
("testReplacingElement", testReplacingElement),
("testIteration", testIteration),
]
public class SyntaxCollectionsTests: XCTestCase {

public func testAppendingElement() {
let arrayElementList = SyntaxFactory.makeArrayElementList([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,7 @@ fileprivate func cannedStructDecl() -> StructDeclSyntax {
}
}

public class SyntaxFactoryAPITestCase: XCTestCase {

public static let allTests = [
("testGenerated", testGenerated),
("testTokenSyntax", testTokenSyntax),
("testFunctionCallSyntaxBuilder", testFunctionCallSyntaxBuilder),
("testWithOptionalChild", testWithOptionalChild),
("testUnknownSyntax", testUnknownSyntax),
("testMakeStringLiteralExpr", testMakeStringLiteralExpr),
("testMakeBinaryOperator", testMakeBinaryOperator),
]
public class SyntaxFactoryTests: XCTestCase {

public func testGenerated() {

Expand Down
7 changes: 1 addition & 6 deletions Tests/SwiftSyntaxTest/SyntaxTests.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import XCTest
import SwiftSyntax

public class SyntaxAPITestCase: XCTestCase {

public static let allTests = [
("testSyntaxAPI", testSyntaxAPI),
("testPositions", testPositions),
]
public class SyntaxTests: XCTestCase {

public func testSyntaxAPI() {
let source = "struct A { func f() {} }"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
import XCTest
import SwiftSyntax

public class SyntaxVisitorTestCase: XCTestCase {

public static let allTests = [
("testBasic", testBasic),
("testRewritingNodeWithEmptyChild", testRewritingNodeWithEmptyChild),
("testSyntaxRewriterVisitAny", testSyntaxRewriterVisitAny),
("testSyntaxRewriterVisitCollection", testSyntaxRewriterVisitCollection),
("testVisitorClass", testVisitorClass),
]
public class SyntaxVisitorTests: XCTestCase {

public func testBasic() {
struct FuncCounter: SyntaxVisitor {
Expand Down
6 changes: 1 addition & 5 deletions Tests/SwiftSyntaxTest/TokenTest.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import XCTest
import SwiftSyntax

public class TokenSyntaxTestCase: XCTestCase {

public static let allTests = [
("testKeywordKinds", testKeywordKinds),
]
public class TokenTests: XCTestCase {

public func testKeywordKinds() {
XCTAssertTrue(TokenKind.operatorKeyword.isKeyword)
Expand Down
7 changes: 1 addition & 6 deletions Tests/SwiftSyntaxTest/TriviaTests.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import XCTest
import SwiftSyntax

public class TriviaTestCase: XCTestCase {

public static let allTests = [
("testTriviaEquatable", testTriviaEquatable),
("testTriviaPieceEquatable", testTriviaPieceEquatable)
]
public class TriviaTests: XCTestCase {

func testTriviaEquatable() {
XCTAssertEqual([.spaces(2), .tabs(1)] as Trivia, [.spaces(2), .tabs(1)])
Expand Down
7 changes: 5 additions & 2 deletions build-script.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -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
Expand Down