diff --git a/build.gradle b/build.gradle index 5afffe64..416698c2 100644 --- a/build.gradle +++ b/build.gradle @@ -292,35 +292,88 @@ 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", + workingDir INTEGRATION_TEST_DIRECTORY_GRADLE_PLUGIN + commandLine "./gradlew", "clean", "htmlSanityCheck", "-PhtmlSanityCheckVersion=${project.version}", "--scan" } 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' ) /* diff --git a/integration-test/cli/.gitkeep b/integration-test/cli/.gitkeep new file mode 100644 index 00000000..e69de29b