Skip to content

Conversation

@vlsi
Copy link
Collaborator

@vlsi vlsi commented Dec 26, 2023

Description

Groovy-based tests are somewhat uneasy to maintain as the language is too dynamic for "find usages", "navigate to implementation" to work.

At the same time, Spock/Groovy have issues with support of recent Java (see #6114)

The major part is only a mechanical work, however, there are interesting cases:

ThroughputControllerTest

Groovy-based test lacks structure, and it is hard to tell what is going on.

    def createLoopController(int innerLoops) {
        LoopController innerLoop = new LoopController()
        innerLoop.setLoops(innerLoops)
        innerLoop.addTestElement(new TestSampler("zero"))
        innerLoop.addTestElement(sut)
        innerLoop.addIterationListener(sut)
        innerLoop.addTestElement(new TestSampler("three"))

        def outerLoop = new LoopController()
        outerLoop.setLoops(1)
        outerLoop.addTestElement(innerLoop)
        sut.testStarted()
        outerLoop.setRunningVersion(true)
        sut.setRunningVersion(true)
        innerLoop.setRunningVersion(true)
        outerLoop.initialize()
        outerLoop
    }

The same data is much easier to understand in Kotlin:

    private fun createLoopController(innerLoops: Int): LoopController {
        sut.testStarted()
        val tree = testTree {
            LoopController::class {
                loops = 1
                LoopController::class {
                    loops = innerLoops
                    +TestSampler("zero")
                    +sut
                    +TestSampler("three")
                }
            }
        }
        val compiler = TestCompiler(tree)
        tree.traverse(compiler)

        val outerLoop = tree.list().first() as LoopController
        outerLoop.initialize()

        sut.isRunningVersion = true
        sut.testStarted()

        return outerLoop
    }

@vlsi vlsi changed the title test: replace Groovy tests in jorphan with Kotlin test: replace Groovy tests in :src:jorphan, :src:core with Kotlin Dec 26, 2023
@vlsi vlsi force-pushed the groovy branch 2 times, most recently from 2b590d7 to 38ac9a5 Compare December 27, 2023 09:22
@vlsi vlsi changed the title test: replace Groovy tests in :src:jorphan, :src:core with Kotlin refactor: migrate existing Groovy tests to Kotlin, remove Groovy compiler from the build pipeline Dec 27, 2023
@vlsi vlsi force-pushed the groovy branch 2 times, most recently from 6c0b393 to d382e26 Compare December 27, 2023 14:09
@vlsi
Copy link
Collaborator Author

vlsi commented Dec 27, 2023

For reference, after this PR, ./gradlew -PjdkBuildVersion=23 -PtargetJavaVersion=17 test pass. In other words the PR resolves #6114

@vlsi vlsi force-pushed the groovy branch 2 times, most recently from e6d06f6 to eaf063d Compare December 29, 2023 14:01
@vlsi vlsi added this to the 5.6.3 milestone Dec 29, 2023
vlsi added 19 commits December 29, 2023 17:30
@vlsi vlsi merged commit e5355de into apache:master Dec 29, 2023
@vlsi vlsi deleted the groovy branch December 29, 2023 15:24
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.

1 participant