Skip to content

Fine-grained selective testing at a class-level granularity (1500USD Bounty) #4109

Open
@lihaoyi

Description

@lihaoyi

From the maintainer Li Haoyi: I'm putting a 1500USD bounty on this issue, payable by bank transfer on a merged PR implementing this.

See https://github.com/orgs/com-lihaoyi/discussions/6 for other bounties and the terms and conditions that bounties operate under


#4091 implements selective execution and testing at a granularity of mill build modules, but we should be able to do better.

There are two main implementation strategies we could use

Method Code Hash Signature Bytecode Analysis

  • We already have the ability to compute code signatures for JVM bytecode and do basic callgraph analysis, which we currently use for selectively invalidating targets in the build.mill file.

  • We should be able to apply the same bytecode analysis to classes and methods in the JavaModule and ScalaModule compile output, automatically determining which test classes within a module could potentially be affected by a code change and would need to be executed to validate it

This would provide much finer grained selective testing than the initial module-level implementation, and help greatly in messy real-world projects where the module structure is not as fine grained as it could be. It should also work for Java
and Kotlin-JVM modules, since the analysis happens on JVM bytecode which is universal across JVM languages

The implement strategy would be:

  • Add a new task JavaModule#methodCodeHashSignatures, that runs the same mill.core.codesig logic we currently run on MillBuildRootModule, but makes the signatures available for any JavaModule.

  • Add a new command TestModule#testQuick, that compares the previous and current methodCodeHashSignatures (maybe using a persistent task to store the old value), and selects the test classes to run based on those who have a method in methodCodeHashSignatures that changed

  • The first time testQuick is run it would run all the tests, but if you change code subsequent runs of testQuick would only run test classes that either (1) failed previously or (2) were affected by the code changes, via the hash signature computation above

Zinc Incremental Compilation Dependency Graph

  • We already have analysis files that the Zinc incremental compiler generates, which contains file-by-file dependency information in the local codebase. We can use this dependency graph similarly as above, and find the test classes that were affected by any code change

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions