Skip to content

Commit 9bd9389

Browse files
committed
Only check Java tests, PR feedback
- Name checker was ran for Groovy tests that don't adhere to the same convections causing the check to fail - implement PR feedback
1 parent 684234b commit 9bd9389

File tree

8 files changed

+21
-13
lines changed

8 files changed

+21
-13
lines changed

buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/RandomizedTestingPlugin.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class RandomizedTestingPlugin implements Plugin<Project> {
4545
}
4646

4747
static void replaceTestTask(Project project) {
48-
def tasks = project.tasks
48+
TaskContainer tasks = project.tasks
4949
Test oldTestTask = tasks.findByPath('test')
5050
if (oldTestTask == null) {
5151
// no test task, ok, user will use testing task on their own

buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/RandomizedTestingTask.groovy

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ class RandomizedTestingTask extends DefaultTask {
9898
}
9999

100100
void basedOn(RandomizedTestingTask other) {
101-
configure(BuildPlugin.commonTestConfig(project))
102101
classpath = other.classpath;
103102
testClassesDirs = other.testClassesDirs;
104103
dependsOn = other.dependsOn
@@ -224,7 +223,7 @@ class RandomizedTestingTask extends DefaultTask {
224223

225224
DefaultLogger listener = null
226225
ByteArrayOutputStream antLoggingBuffer = null
227-
if (!logger.isInfoEnabled()) {
226+
if (false == logger.isInfoEnabled()) {
228227
// in info logging, ant already outputs info level, so we see everything
229228
// but on errors or when debugging, we want to see info level messages
230229
// because junit4 emits jvm output with ant logging

buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/NamingConventionsTask.groovy

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public class NamingConventionsTask extends LoggedExec {
6767

6868
NamingConventionsTask() {
6969
// Extra classpath contains the actual test
70-
if (!project.configurations.names.contains('namingConventions')) {
70+
if (false == project.configurations.names.contains('namingConventions')) {
7171
project.configurations.create('namingConventions')
7272
Dependency buildToolsDep = project.dependencies.add('namingConventions',
7373
"org.elasticsearch.gradle:build-tools:${VersionProperties.elasticsearch}")
@@ -81,17 +81,11 @@ public class NamingConventionsTask extends LoggedExec {
8181
description = "Tests that test classes aren't misnamed or misplaced"
8282
executable = new File(project.runtimeJavaHome, 'bin/java')
8383

84-
def dirsToUse = (checkForTestsInMain ?
85-
project.sourceSets.main.output.classesDirs :
86-
project.sourceSets.test.output.classesDirs)
87-
.filter {it.exists()}
88-
.collect {it.getAbsolutePath()}
89-
90-
if (!checkForTestsInMain) {
84+
if (false == checkForTestsInMain) {
9185
/* This task is created by default for all subprojects with this
9286
* setting and there is no point in running it if the files don't
9387
* exist. */
94-
onlyIf { dirsToUse.size() != 0 }
88+
onlyIf { getJavaClassesDir() != null && getJavaClassesDir().exists() }
9589
}
9690

9791
/*
@@ -124,10 +118,20 @@ public class NamingConventionsTask extends LoggedExec {
124118
} else {
125119
args('--')
126120
}
127-
args(dirsToUse.join(File.pathSeparator))
121+
args(getJavaClassesDir().absolutePath)
128122
}
129123
}
130124
doLast { successMarker.setText("", 'UTF-8') }
131125
}
132126

127+
File getJavaClassesDir() {
128+
FileCollection classesDirs = (checkForTestsInMain ?
129+
project.sourceSets.main.output.classesDirs :
130+
project.sourceSets.test.output.classesDirs)
131+
if (classesDirs.isEmpty()) { return null }
132+
// see https://docs.gradle.org/current/dsl/org.gradle.api.tasks.SourceSetOutput.html the deprecated property
133+
// classesDir is the first in the FileCollection. There seems to be no other way to refer to the Java output dir
134+
// We can't run the check against all classes as Groovy tests don't adhere to naming conventions.
135+
return classesDirs[0]
136+
}
133137
}

server/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ dependencyLicenses {
328328
if (isEclipse == false || project.path == ":server-tests") {
329329
task integTest(type: RandomizedTestingTask,group: JavaBasePlugin.VERIFICATION_GROUP) {
330330
description = 'Multi-node tests'
331+
configure(BuildPlugin.commonTestConfig(project))
331332
basedOn tasks.test
332333
include '**/*IT.class'
333334
}

x-pack/plugin/ml/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ integTest.enabled = false
9292

9393
// Instead we create a separate task to run the tests based on ESIntegTestCase
9494
task internalClusterTest(type: RandomizedTestingTask, group: JavaBasePlugin.VERIFICATION_GROUP) {
95+
configure(BuildPlugin.commonTestConfig(project))
9596
description = 'Multi-node tests'
9697
basedOn tasks.test
9798
include '**/*IT.class'

x-pack/plugin/monitoring/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ integTest.enabled = false
5757
// Instead we create a separate task to run the tests based on ESIntegTestCase
5858
task internalClusterTest(type: RandomizedTestingTask, group: JavaBasePlugin.VERIFICATION_GROUP) {
5959
description = 'Multi-node tests'
60+
configure(BuildPlugin.commonTestConfig(project))
6061
basedOn test
6162
include '**/*IT.class'
6263
systemProperty 'es.set.netty.runtime.available.processors', 'false'

x-pack/plugin/rollup/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ integTest.enabled = false
3737
// Instead we create a separate task to run the tests based on ESIntegTestCase
3838
task internalClusterTest(type: RandomizedTestingTask, group: JavaBasePlugin.VERIFICATION_GROUP) {
3939
description = 'Multi-node tests'
40+
configure(BuildPlugin.commonTestConfig(project))
4041
basedOn tasks.test
4142
include '**/*IT.class'
4243
systemProperty 'es.set.netty.runtime.available.processors', 'false'

x-pack/plugin/upgrade/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ integTest.enabled = false
3131
// tests based on ESIntegTestCase
3232
task internalClusterTest(type: RandomizedTestingTask, group: JavaBasePlugin.VERIFICATION_GROUP) {
3333
description = 'Multi-node tests'
34+
configure(BuildPlugin.commonTestConfig(project))
3435
basedOn tasks.test
3536
include '**/*IT.class'
3637
systemProperty 'es.set.netty.runtime.available.processors', 'false'

0 commit comments

Comments
 (0)