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

Conversation

kitasuke
Copy link
Contributor

@kitasuke kitasuke commented Jul 24, 2019

Overview

Let's use swift test --enable-test-discovery to support auto-generation of test files for Linux instead of manually adding/removing test cases.
I also renamed test files to have consistent common suffix which is Tests.

@akyrtzi
Copy link
Contributor

akyrtzi commented Jul 24, 2019

@swift-ci Please test

@harlanhaskins
Copy link
Contributor

I'd love to pull this in, but I wonder if we could go all-in and try doing --enable-test-discovery on Linux (swiftlang/swift-package-manager#2174)

@akyrtzi
Copy link
Contributor

akyrtzi commented Jul 24, 2019

Yeah, let's hold on to this change for now to try out auto-discovery. Plus we are not yet building+testing SwiftSyntax on linux which makes it hard to validate the PR changes.

@harlanhaskins
Copy link
Contributor

Could you update this patch to try auto-test-discovery? I'd love to still take the renaming and the removal of all the manual stuff.

@kitasuke
Copy link
Contributor Author

Didn't know we have this option, but this is actually better. Yes, I'll give it a try.

# Conflicts:
#	Tests/SwiftSyntaxTest/SyntaxFactoryTests.swift
@kitasuke
Copy link
Contributor Author

I guess it worked!
It generated two files below in .build/x86_64-unknown-linux/debug/testlist.derived/ by running swift test --enable-test-discovery with this docker image

Should I delete XCTestManifests.swift and LinuxMain.swift from the commit?

// main.swift
import XCTest

var tests = [XCTestCaseEntry]()
tests += __allTests_SwiftSyntaxTest()

XCTMain(tests)
// SwiftSyntaxTest.swift
import XCTest
@testable import SwiftSyntaxTest

fileprivate extension AbsolutePositionTests {
    static let __allTests__AbsolutePositionTests = [
        ("testClosure", testClosure),
        ("testCurrentFile", testCurrentFile),
        ("testImplicit", testImplicit),
        ("testRecursion", testRecursion),
        ("testRename", testRename),
        ("testSourceLocation", testSourceLocation),
        ("testTrivias", testTrivias),
        ("testVisitor", testVisitor),
        ("testWithoutSourceFileRoot", testWithoutSourceFileRoot),
    ]
}

fileprivate extension ClassificationTests {
    static let __allTests__ClassificationTests = [
        ("testClassification", testClassification),
        ("testTokenClassification", testTokenClassification),
    ]
}

fileprivate extension CustomReflectableTests {
    static let __allTests__CustomReflectableTests = [
        ("testConformanceToCustomReflectable", testConformanceToCustomReflectable),
        ("testDump", testDump),
    ]
}

fileprivate extension DiagnosticTests {
    static let __allTests__DiagnosticTests = [
        ("testDiagnosticEmission", testDiagnosticEmission),
        ("testSourceLocations", testSourceLocations),
    ]
}

fileprivate extension IncrementalParsingTests {
    static let __allTests__IncrementalParsingTests = [
        ("testIncrementalInvalid", testIncrementalInvalid),
        ("testReusedNode", testReusedNode),
    ]
}

fileprivate extension MultithreadingTests {
    static let __allTests__MultithreadingTests = [
        ("testPathological", testPathological),
        ("testTwoAccesses", testTwoAccesses),
    ]
}

fileprivate extension ParseFileTests {
    static let __allTests__ParseFileTests = [
        ("testEnumCaseStructure", testEnumCaseStructure),
        ("testParseSingleFile", testParseSingleFile),
    ]
}

fileprivate extension SyntaxChildrenTests {
    static let __allTests__SyntaxChildrenTests = [
        ("testIterateWithAllMissing", testIterateWithAllMissing),
        ("testIterateWithAllPresent", testIterateWithAllPresent),
        ("testIterateWithSomeMissing", testIterateWithSomeMissing),
    ]
}

fileprivate extension SyntaxCollectionsTests {
    static let __allTests__SyntaxCollectionsTests = [
        ("testAppendingElement", testAppendingElement),
        ("testInsertingElement", testInsertingElement),
        ("testIteration", testIteration),
        ("testPrependingElement", testPrependingElement),
        ("testRemovingElement", testRemovingElement),
        ("testRemovingFirstElement", testRemovingFirstElement),
        ("testRemovingLastElement", testRemovingLastElement),
        ("testReplacingElement", testReplacingElement),
    ]
}

fileprivate extension SyntaxFactoryTests {
    static let __allTests__SyntaxFactoryTests = [
        ("testFunctionCallSyntaxBuilder", testFunctionCallSyntaxBuilder),
        ("testGenerated", testGenerated),
        ("testMakeBinaryOperator", testMakeBinaryOperator),
        ("testMakeStringLiteralExpr", testMakeStringLiteralExpr),
        ("testTokenSyntax", testTokenSyntax),
        ("testUnknownSyntax", testUnknownSyntax),
        ("testWithOptionalChild", testWithOptionalChild),
    ]
}

fileprivate extension SyntaxTests {
    static let __allTests__SyntaxTests = [
        ("testPositions", testPositions),
        ("testSyntaxAPI", testSyntaxAPI),
    ]
}

fileprivate extension SyntaxTreeModifierTests {
    static let __allTests__SyntaxTreeModifierTests = [
        ("testAccessorAsModifier", testAccessorAsModifier),
    ]
}

fileprivate extension SyntaxVisitorTests {
    static let __allTests__SyntaxVisitorTests = [
        ("testBasic", testBasic),
        ("testRewritingNodeWithEmptyChild", testRewritingNodeWithEmptyChild),
        ("testSyntaxRewriterVisitAny", testSyntaxRewriterVisitAny),
        ("testSyntaxRewriterVisitCollection", testSyntaxRewriterVisitCollection),
        ("testVisitorClass", testVisitorClass),
    ]
}

fileprivate extension TokenTests {
    static let __allTests__TokenTests = [
        ("testKeywordKinds", testKeywordKinds),
        ("testTokenLgnth", testTokenLgnth),
    ]
}

fileprivate extension TriviaTests {
    static let __allTests__TriviaTests = [
        ("testTriviaEquatable", testTriviaEquatable),
        ("testTriviaPieceEquatable", testTriviaPieceEquatable),
    ]
}
func __allTests_SwiftSyntaxTest() -> [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),
    ]
}

@harlanhaskins
Copy link
Contributor

That sounds good to me!

@kitasuke
Copy link
Contributor Author

Addressed your feedback

@harlanhaskins
Copy link
Contributor

Last bit: can you add this flag in build-script.py?

@kitasuke kitasuke force-pushed the auto-generate-linux-test branch from a11a96a to dd37bf6 Compare July 31, 2019 06:24
@harlanhaskins
Copy link
Contributor

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - f61ec82

@akyrtzi
Copy link
Contributor

akyrtzi commented Jul 31, 2019

I'd like to hold on this for a bit, we are going to switch to using multiroot packages for CI, that @aciidb0mb3r recently added, and test discovery is not yet working for that setup.

@ahoppen
Copy link
Member

ahoppen commented Nov 5, 2019

@kitasuke Sorry this was sitting here for so long and not being merged. But thanks a lot for your work on this. I have rebased your changes and cleaned them up a little in #171. Could you take a look at them?

Because we are now using a unified build for all SwiftSyntax dependencies, we unfortunately cannot use --enable-test-discovery, so I reverted to your old version of using the generated LinuxMain.swift

Closing this now since it’s being tracked by #171.

@ahoppen ahoppen closed this Nov 5, 2019
@kitasuke
Copy link
Contributor Author

kitasuke commented Nov 6, 2019

Makes sense. Thanks for the heads up!

@kitasuke kitasuke deleted the auto-generate-linux-test branch November 6, 2019 05:55
adevress pushed a commit to adevress/swift-syntax that referenced this pull request Jan 14, 2024
Various visibility (and other) cleanup.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants