Skip to content

Commit b79c104

Browse files
committed
[TEST] packaging: code review fixes
* Removes unnecessary tasks for creating packaging directories inside the gradle build directory * Take an explicit task path to be reproduced when creating reproduction listeners * Make more clear the intent behind adding the empty groovy packaging test
1 parent fcd5279 commit b79c104

File tree

1 file changed

+6
-22
lines changed

1 file changed

+6
-22
lines changed

buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -157,15 +157,9 @@ class VagrantTestPlugin implements Plugin<Project> {
157157

158158
private static void createPrepareVagrantTestEnvTask(Project project) {
159159
File packagingDir = new File(project.buildDir, PACKAGING_CONFIGURATION)
160-
Task createPackagingDirTask = project.tasks.create('creatingPackagingDir')
161-
createPackagingDirTask.outputs.dir(packagingDir)
162-
createPackagingDirTask.doLast {
163-
packagingDir.mkdirs()
164-
}
165160

166161
File archivesDir = new File(packagingDir, 'archives')
167162
Copy copyPackagingArchives = project.tasks.create('copyPackagingArchives', Copy) {
168-
dependsOn createPackagingDirTask
169163
into archivesDir
170164
from project.configurations[PACKAGING_CONFIGURATION]
171165
}
@@ -183,22 +177,14 @@ class VagrantTestPlugin implements Plugin<Project> {
183177
}
184178

185179
File batsDir = new File(packagingDir, BATS)
186-
Task createBatsDirsTask = project.tasks.create('createBatsDirs')
187-
createBatsDirsTask.outputs.dir batsDir
188-
createBatsDirsTask.doLast {
189-
batsDir.mkdirs()
190-
}
191-
192180
Copy copyBatsTests = project.tasks.create('copyBatsTests', Copy) {
193-
dependsOn createBatsDirsTask
194181
into "${batsDir}/tests"
195182
from {
196183
"${project.extensions.esvagrant.batsDir}/tests"
197184
}
198185
}
199186

200187
Copy copyBatsUtils = project.tasks.create('copyBatsUtils', Copy) {
201-
dependsOn createBatsDirsTask
202188
into "${batsDir}/utils"
203189
from {
204190
"${project.extensions.esvagrant.batsDir}/utils"
@@ -376,7 +362,7 @@ class VagrantTestPlugin implements Plugin<Project> {
376362
finalizedBy halt
377363
}
378364

379-
TaskExecutionAdapter batsPackagingReproListener = createReproListener(project)
365+
TaskExecutionAdapter batsPackagingReproListener = createReproListener(project, batsPackagingTest.path)
380366
batsPackagingTest.doFirst {
381367
project.gradle.addListener(batsPackagingReproListener)
382368
}
@@ -387,14 +373,12 @@ class VagrantTestPlugin implements Plugin<Project> {
387373
packagingTest.dependsOn(batsPackagingTest)
388374
}
389375

376+
// This task doesn't do anything yet. In the future it will execute a jar containing tests on the vm
390377
Task groovyPackagingTest = project.tasks.create("vagrant${boxTask}#groovyPackagingTest")
391378
groovyPackagingTest.dependsOn(up)
392379
groovyPackagingTest.finalizedBy(halt)
393-
groovyPackagingTest.doLast {
394-
// no op
395-
}
396380

397-
TaskExecutionAdapter groovyPackagingReproListener = createReproListener(project)
381+
TaskExecutionAdapter groovyPackagingReproListener = createReproListener(project, groovyPackagingTest.path)
398382
groovyPackagingTest.doFirst {
399383
project.gradle.addListener(groovyPackagingReproListener)
400384
}
@@ -413,7 +397,7 @@ class VagrantTestPlugin implements Plugin<Project> {
413397
finalizedBy halt
414398
args '--command', PLATFORM_TEST_COMMAND + " -Dtests.seed=${-> project.testSeed}"
415399
}
416-
TaskExecutionAdapter platformReproListener = createReproListener(project)
400+
TaskExecutionAdapter platformReproListener = createReproListener(project, platform.path)
417401
platform.doFirst {
418402
project.gradle.addListener(platformReproListener)
419403
}
@@ -426,13 +410,13 @@ class VagrantTestPlugin implements Plugin<Project> {
426410
}
427411
}
428412

429-
private static TaskExecutionAdapter createReproListener(Project project) {
413+
private static TaskExecutionAdapter createReproListener(Project project, String reproTaskPath) {
430414
return new TaskExecutionAdapter() {
431415
@Override
432416
void afterExecute(Task task, TaskState state) {
433417
final String gradlew = Os.isFamily(Os.FAMILY_WINDOWS) ? "gradlew" : "./gradlew"
434418
if (state.failure != null) {
435-
println "REPRODUCE WITH: ${gradlew} ${task.path} -Dtests.seed=${project.testSeed} "
419+
println "REPRODUCE WITH: ${gradlew} ${reproTaskPath} -Dtests.seed=${project.testSeed} "
436420
}
437421
}
438422
}

0 commit comments

Comments
 (0)