Skip to content

Commit

Permalink
#318 Add integration test for CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
ascheman committed Aug 21, 2024
1 parent 15db70c commit 56c0380
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 12 deletions.
77 changes: 65 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -271,34 +271,87 @@ sonar {
}

tasks.register("integrationTestOnly") {
group("Verification")
description("Run overall integration tests (no publish)")
final String INTEGRATION_TEST_DIRECTORY = "integration-test"
final String INTEGRATION_TEST_DIRECTORY_GRADLE_PLUGIN = "${INTEGRATION_TEST_DIRECTORY}/gradle-plugin"
final String INTEGRATION_TEST_DIRECTORY_CLI = "${INTEGRATION_TEST_DIRECTORY}/cli"
static void cleanBuild(String baseDirectory) {
File integrationTestBuildDir = new File("${baseDirectory}/${Project.DEFAULT_BUILD_DIR_NAME}")
if (integrationTestBuildDir.exists()) {
integrationTestBuildDir.eachFileRecurse { file ->
file.delete()
}
integrationTestBuildDir.deleteDir()
}
assert !integrationTestBuildDir.exists()
}

final String INTEGRATION_TEST_DIRECTORY = "integration-test/gradle-plugin"
tasks.register("integrationTestGradlePlugin") {
group("Verification")
description("Run gradle-plugin integration tests")

doLast {
def result = exec {
workingDir INTEGRATION_TEST_DIRECTORY
commandLine System.getProperty("os.name") ==~ /Windows.*/ ? "gradlew.bat" : "./gradlew", "clean", "htmlSanityCheck", "-PhtmlSanityCheckVersion=${project.version}"
workingDir INTEGRATION_TEST_DIRECTORY_GRADLE_PLUGIN
commandLine "./gradlew", "clean", "htmlSanityCheck", "-PhtmlSanityCheckVersion=${project.version}"
}
logger.debug "Script output: $result"
File integrationTestDirectory = file(INTEGRATION_TEST_DIRECTORY)
final File testIndex = new File(integrationTestDirectory, "build/reports/index.html")
final File testIndex = new File(INTEGRATION_TEST_DIRECTORY_GRADLE_PLUGIN, "${Project.DEFAULT_BUILD_DIR_NAME}/reports/index.html")
assert testIndex.exists()
}
}
integrationTestOnly.mustRunAfter(
integrationTestGradlePlugin.dependsOn(
':htmlSanityCheck-core:publishAllPublicationsToMyLocalRepositoryForFullIntegrationTestsRepository',
':htmlSanityCheck-gradle-plugin:publishAllPublicationsToMyLocalRepositoryForFullIntegrationTestsRepository'
)
tasks.register("cleanIntegrationTestGradlePlugin", Delete) {
group("Build")
description("Deletes the result directory from gradle-plugin integration tests")

doLast {
cleanBuild INTEGRATION_TEST_DIRECTORY_GRADLE_PLUGIN
}
}
clean.dependsOn cleanIntegrationTestGradlePlugin

tasks.register("integrationTestCli") {
group("Verification")
description("Run CLI integration tests")

final String BUILD_REPORTS_DIRECTORY = "${Project.DEFAULT_BUILD_DIR_NAME}/reports"

doLast {
def result = exec {
workingDir INTEGRATION_TEST_DIRECTORY_CLI
new File(BUILD_REPORTS_DIRECTORY).mkdirs()
commandLine "../../htmlSanityCheck-cli/${Project.DEFAULT_BUILD_DIR_NAME}/install/hsc/bin/hsc", "-r", BUILD_REPORTS_DIRECTORY, "../common/src/test/resources"
}
logger.debug "Script output: ${result}"
final File testIndex = new File(INTEGRATION_TEST_DIRECTORY_CLI, "${BUILD_REPORTS_DIRECTORY}/index.html")
assert testIndex.exists()
}
}
integrationTestCli.dependsOn(
':htmlSanityCheck-cli:installDist'
)
tasks.register("cleanIntegrationTestCli", Delete) {
group("Build")
description("Deletes the result directory from CLI integration tests")

doLast {
cleanBuild INTEGRATION_TEST_DIRECTORY_CLI
}
}
//noinspection GroovyAssignabilityCheck
clean.dependsOn cleanIntegrationTestCli
integrationTestCli.dependsOn cleanIntegrationTestCli

tasks.register("integrationTest") {
group("Verification")
description("Run overall integration tests (and publish first)")
description("Run overall integration tests")
}
integrationTest.dependsOn(
':htmlSanityCheck-core:publishAllPublicationsToMyLocalRepositoryForFullIntegrationTestsRepository',
':htmlSanityCheck-gradle-plugin:publishAllPublicationsToMyLocalRepositoryForFullIntegrationTestsRepository',
'integrationTestOnly'
'integrationTestGradlePlugin',
'integrationTestCli'
)

/*
Expand Down
Empty file added integration-test/cli/.gitkeep
Empty file.

0 comments on commit 56c0380

Please sign in to comment.