Skip to content

runAffectedUnitTests still runs all tests! #337

@Reprator

Description

@Reprator

When running
./gradlew testReleaseUnitTest -Paffected_module_detector.enable

with AffectedModuleDetector, all modules are being marked as affected, even when only a few files have changed, that too in a specific module, which does not affect the other module at all. The output.log shows repeated entries of:

[LIFECYCLE] [amd] projects evaluated
[INFO] [amd] initializing ProjectGraph
[INFO] [amd] creating node for :abc
[INFO] [amd] relative path: abc , sections: [abc]
[INFO] [amd] creating node for :abcd
[INFO] [amd] relative path: abcd , sections: [abcd]
|
| so on
|
[INFO] [amd] finished creating ProjectGraph
[INFO] [amd] Using real detector with ALL_AFFECTED_PROJECTS

This seems similar to #63, but that issue is unanswered.

Environment
AffectedModuleDetector Version: 0.6.2
Gradle Version: 8.14.3
Java Version: 17
Kotlin Version: 2.0.21

Root build.gradle Configuration

       import com.dropbox.affectedmoduledetector.AffectedModuleDetector
       buildscript {
        apply from: 'xyz.gradle'
        repositories {
          mavenCentral()
        }
       dependencies {
           classpath "com.dropbox.affectedmoduledetector:affectedmoduledetector:0.6.2"
       }
    }

    apply plugin: "com.dropbox.affectedmoduledetector"
    affectedModuleDetector {
       baseDir = "${project.rootDir}"
       pathsAffectingAllModules = [
         "settings.gradle"
       ]
       logFilename = "output.log"
       logFolder = "${project.rootDir}/output"
       specifiedBranch = "origin/main"
       compareFrom = "SpecifiedBranchCommitMergeBase"
       buildAllWhenNoProjectsChanged = false
       ignoredFiles = [
          ".*\\.md",
          ".*\\.txt"
       ]
     }

     subprojects {
      tasks.withType(Test) {
          filter {
              setFailOnNoMatchingTests(false)
          }
          doFirst {
             maxParallelForks = System.getenv("UNIT_TESTS_FORKS") ?: Runtime.runtime.availableProcessors().intdiv(2) ?: 1
          }
          jvmArgs = ["--add-opens", "java.base/java.lang.invoke=ALL-UNNAMED", "-Xshare:off"]
        }

        tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
            kotlinOptions {
              jvmTarget = "17"
              freeCompilerArgs = ["-Xjdk-release=17"]
           }
       }

       afterEvaluate {
          if (project.hasProperty('kapt')) kapt {
              useBuildCache = false
             correctErrorTypes = true
              javacOptions {
                  option("-source", "17")
                  option("-target", "17")
              }
           }
        } 

        project.affectedTestConfiguration {
           jvmTestTask = "testReleaseUnitTest"
         }
      }

     class AffectedTask extends DefaultTask {
        @TaskAction
        void printAffected() {
           project.subprojects.each { subproj ->
               println("Is ${subproj.name} Affected? : " + AffectedModuleDetector.isProjectAffected(subproj))
           }
        }
     }
    tasks.register('affectedTask', AffectedTask)

Git log

    commit b279dfg34534534cf8 (HEAD -> bugfix/XYZ-326, origin/bugfix/XYZ-326)
    Merge: 3d56dfgdf464701
    Author: XYZ <1304+SDFD4@users.noreply.github.com>
    Date:   Tue Jan 2 22:23:42 2026 +0530

    Merge branch 'main' into bugfix/XYZ-326

   commit 1a2e8c3454dffdg457014d
   Author: XYZ <148445+XYZ@users.noreply.github.com>
   Date:   Tue Jan 6 21:16:37 2026 +0530

    Fix for scores init API called without feature flag enabled (#16235)

output.log with ./gradlew affectedTask

[INFO] [amd] [AcceptAll] acceptAll.shouldInclude returning true
[INFO] [amd] [AcceptAll] acceptAll.shouldInclude returning true
[INFO] [amd] [AcceptAll] acceptAll.shouldInclude returning true
[INFO] [amd] [AcceptAll] acceptAll.shouldInclude returning true
|
| so on 
|
[INFO] [amd] [AcceptAll] acceptAll.shouldInclude returning true
[INFO] [amd] [AcceptAll] acceptAll.shouldInclude returning true
[INFO] [amd] [AcceptAll] acceptAll.shouldInclude returning true
[INFO] [amd] [AcceptAll] acceptAll.shouldInclude returning true
[INFO] [amd] [AcceptAll] acceptAll.shouldInclude returning true
[INFO] [amd] [AcceptAll] acceptAll.shouldInclude returning true
[INFO] [amd] [AcceptAll] acceptAll.shouldInclude returning true
[INFO] [amd] [AcceptAll] acceptAll.shouldInclude returning true
[INFO] [amd] [AcceptAll] acceptAll.shouldInclude returning true
[INFO] [amd] [AcceptAll] acceptAll.shouldInclude returning true
[INFO] [amd] [AcceptAll] acceptAll.shouldInclude returning true
[INFO] [amd] [AcceptAll] acceptAll.shouldInclude returning true
[INFO] [amd] [AcceptAll] acceptAll.shouldInclude returning true

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions