Skip to content

Commit

Permalink
write packaging test runner script alongside tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andyb-elastic committed Apr 4, 2018
1 parent 249d57a commit 8dee0e6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class FileContentsTask extends DefaultTask {
@Input
Object contents

@Input
boolean executable = false

/**
* The file to be built. Takes any objecct and coerces to a file.
*/
Expand All @@ -47,5 +50,6 @@ class FileContentsTask extends DefaultTask {
void setContents() {
file = file as File
file.text = contents.toString()
file.setExecutable(executable)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,13 @@ class VagrantTestPlugin implements Plugin<Project> {
from project.configurations[PACKAGING_TEST_CONFIGURATION]
}

Task createTestRunnerScript = project.tasks.create('createTestRunnerScript', FileContentsTask) {
dependsOn copyPackagingTests
file "${testsDir}/run-tests.sh"
contents "java -cp \"*\" org.junit.runner.JUnitCore ${-> project.extensions.esvagrant.testClass}"
executable true
}

Task createVersionFile = project.tasks.create('createVersionFile', FileContentsTask) {
dependsOn copyPackagingArchives
file "${archivesDir}/version"
Expand Down Expand Up @@ -224,8 +231,8 @@ class VagrantTestPlugin implements Plugin<Project> {

Task vagrantSetUpTask = project.tasks.create('setupPackagingTest')
vagrantSetUpTask.dependsOn 'vagrantCheckVersion'
vagrantSetUpTask.dependsOn copyPackagingArchives, copyPackagingTests, createVersionFile, createUpgradeFromFile
vagrantSetUpTask.dependsOn copyBatsTests, copyBatsUtils
vagrantSetUpTask.dependsOn copyPackagingArchives, copyPackagingTests, createTestRunnerScript, createVersionFile,
createUpgradeFromFile, copyBatsTests, copyBatsUtils
}

private static void createPackagingTestTask(Project project) {
Expand Down Expand Up @@ -389,7 +396,7 @@ class VagrantTestPlugin implements Plugin<Project> {
environmentVars vagrantEnvVars
dependsOn up, setupPackagingTest
finalizedBy halt
args '--command', "java -cp \"\$PACKAGING_TESTS/*\" org.junit.runner.JUnitCore ${-> project.extensions.esvagrant.testClass}"
args '--command', "cd \$PACKAGING_TESTS && ./run-tests.sh"
}

TaskExecutionAdapter groovyPackagingReproListener = createReproListener(project, javaPackagingTest.path)
Expand Down

0 comments on commit 8dee0e6

Please sign in to comment.