Skip to content
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

fix: use match to identify test configuration #392

Merged
merged 6 commits into from
May 16, 2024
Merged
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -377,18 +377,15 @@ abstract class AbstractAnalyze extends ConfiguredTask {
* Checks whether a configuration is considered to be a test configuration in order to skip it.
* A configuration is considered a test configuration if and only if any of the following conditions holds:
* <ul>
* <li>the name of the configuration or any of its parent configurations equals 'testCompile'</li>
* <li>the name of the configuration or any of its parent configurations equals 'testImplementation'</li>
* <li>the name of the configuration or any of its parent configurations equals 'androidTestCompile'</li>
* <li>the configuration name starts with 'test'</li>
* <li>the configuration name starts with 'androidTest'</li>
* <li>the name of the configuration or any of its parent configurations matches /^(.*[a-z0-9_]T|_?t)est([A-Z0-9_].*)?$/</li>
jeremylong marked this conversation as resolved.
Show resolved Hide resolved
* </ul>
* The intent of the regular expression is to match `test` in a camel case or snake case configuration name.
*/
@groovy.transform.CompileStatic
static boolean isTestConfigurationCheck(Configuration configuration) {
boolean isTestConfiguration = configuration.name.startsWith("test") || configuration.name.startsWith("androidTest")
boolean isTestConfiguration = configuration.name =~ /((^|[a-z0-9_])T|(^|_)t)est([A-Z0-9_]|$)/
jeremylong marked this conversation as resolved.
Show resolved Hide resolved
configuration.hierarchy.each {
isTestConfiguration |= (it.name == "testCompile" || it.name == "androidTestCompile" || it.name == "testImplementation")
isTestConfiguration |= it.name ==~ /((^|[a-z0-9_])T|(^|_)t)est([A-Z0-9_]|$)/
}
isTestConfiguration
}
Expand Down
Loading