Skip to content

Commit

Permalink
WIP Add integration test for CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
ascheman committed Jan 27, 2024
1 parent bc6f6ed commit aa5a73f
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 10 deletions.
82 changes: 72 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ configure(subprojects) {
implementation platform(libs.groovy.bom)
implementation 'org.codehaus.groovy:groovy'

implementation platform (libs.slf4j.bom)
implementation platform(libs.slf4j.bom)

testImplementation platform (libs.spock)
testImplementation platform(libs.spock)
testImplementation "org.spockframework:spock-core"
testImplementation "org.spockframework:spock-junit4"

Expand All @@ -68,7 +68,7 @@ configure(subprojects) {
maven {
name = 'myLocalRepositoryForFullIntegrationTests'
//noinspection GrDeprecatedAPIUsage
url = new File (project.parent.buildDir, "maven-repo")
url = new File(project.parent.buildDir, "maven-repo")
}
mavenLocal()
}
Expand All @@ -83,26 +83,88 @@ configure(subprojects) {
// apply plugin: 'codenarc'
}

tasks.register("integrationTest") {
group("Verification")
description("Run overall integration tests")
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
workingDir INTEGRATION_TEST_DIRECTORY_GRADLE_PLUGIN
commandLine "./gradlew", "clean", "htmlSanityCheck", "-PhtmlSanityCheckVersion=${project.version}"
}
logger.debug "Script output: $result"
final File testIndex = new File(INTEGRATION_TEST_DIRECTORY, "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()
}
}
integrationTest.dependsOn(
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")
}
integrationTest.dependsOn(
'integrationTestGradlePlugin',
'integrationTestCli'
)

/*
* Copyright Gernot Starke and aim42 contributors.
Expand Down
Empty file added integration-test/cli/.gitkeep
Empty file.

0 comments on commit aa5a73f

Please sign in to comment.