ziggy/script-plugins/test.gradle

118 lines
3.9 KiB
Groovy

test {
systemProperty "java.library.path", "$outsideDir/lib"
maxHeapSize = "1024m"
// Avoid the warning "OpenJDK 64-Bit Server VM warning: Sharing is
// only supported for boot loader classes because bootstrap
// classpath has been appended". See
// https://github.com/mockito/mockito/issues/3111.
jvmArgs(['-Xshare:off'])
testLogging {
events "failed", "skipped"
}
useJUnit {
// If a code coverage report that incudes the integration tests is desired, then comment
// out the IntegrationTestCategory line and uncomment the RunByNameTestCategory line. When
// the JaCoCo issue described below is resolved, then delete this comment.
// excludeCategories 'gov.nasa.ziggy.RunByNameTestCategory'
excludeCategories 'gov.nasa.ziggy.IntegrationTestCategory'
}
// Use "gradle -P traceTests test" to show test order.
if (project.hasProperty("traceTests")) {
afterTest { desc, result ->
logger.quiet "${desc.className}.${desc.name}: ${result.resultType}"
}
}
}
// Execute tests marked with @Category(IntegrationTestCategory.class).
task integrationTest(type: Test) {
testClassesDirs = testing.suites.test.sources.output.classesDirs
classpath = testing.suites.test.sources.runtimeClasspath
systemProperty "log4j2.configurationFile", "$rootDir/etc/log4j2.xml"
systemProperty "ziggy.logfile", "$buildDir/build.log"
systemProperty "java.library.path", "$outsideDir/lib"
testLogging {
events "failed", "skipped"
}
useJUnit {
includeCategories 'gov.nasa.ziggy.IntegrationTestCategory'
excludeCategories 'gov.nasa.ziggy.FlakyTestCategory'
excludeCategories 'gov.nasa.ziggy.RunByNameTestCategory'
}
jvmArgs(['-Xshare:off'])
}
check.dependsOn integrationTest
cleanTest.dependsOn cleanIntegrationTest
// Execute tests marked with @Category(FlakyTestCategory.class).
task flakyTest(type: Test) {
testClassesDirs = testing.suites.test.sources.output.classesDirs
classpath = testing.suites.test.sources.runtimeClasspath
systemProperty "log4j2.configurationFile", "$rootDir/etc/log4j2.xml"
systemProperty "ziggy.logfile", "$buildDir/build.log"
systemProperty "java.library.path", "$outsideDir/lib"
useJUnit {
includeCategories 'gov.nasa.ziggy.FlakyTestCategory'
}
jvmArgs(['-Xshare:off'])
}
check.dependsOn flakyTest
cleanTest.dependsOn cleanFlakyTest
// Execute tests marked with @Category(RunByNameTestCategory.class).
// These tests are typically run explicitly with the --tests option
// since they don't play well with others. For example:
// gradle runByNameTests --tests *RmiInterProcessCommunicationTest
task runByNameTest(type: Test) {
testClassesDirs = testing.suites.test.sources.output.classesDirs
classpath = testing.suites.test.sources.runtimeClasspath
systemProperty "log4j2.configurationFile", "$rootDir/etc/log4j2.xml"
systemProperty "ziggy.logfile", "$buildDir/build.log"
systemProperty "java.library.path", "$outsideDir/lib"
useJUnit {
includeCategories 'gov.nasa.ziggy.RunByNameTestCategory'
}
jvmArgs(['-Xshare:off'])
}
/**
* testprog is used to test external process control. testprog has the
* advantage over something like /bin/true that it can run for a specified
* wall clock time, crash and return different error codes.
*/
task generateTestProg(type: Exec) {
def binDir = file("$buildDir/bin")
inputs.file "$projectDir/src/test/cpp/ExternalProcess/Makefile"
inputs.file "$projectDir/src/test/cpp/ExternalProcess/testprog.cpp"
outputs.file "$binDir/testprog"
workingDir = "$projectDir/src/test/cpp/ExternalProcess"
commandLine = [ "sh", "-c", "make -e" ]
System.setProperty("OUTDIR", "$binDir")
logging.captureStandardOutput LogLevel.INFO
}
compileTestJava.dependsOn generateTestProg
clean.doLast() {
file("$projectDir/src/test/cpp/ExternalProcess/testprog.o").delete()
}