WALA/com.ibm.wala.cast.test/build.gradle
Ben Liblit a7cef8e77a Declare a task's outputs, enabling incremental build and caching
This specific task runs an external command, and we consider the task
successful if that command exits without error.  We don't actually
examine the stdout or stderr of the command being run.

However, it is still useful to log the stdout and stderr to a file,
and to declare that file to be the output of the task.  Otherwise, the
task has no declared outputs at all.  A task with no outputs is
ineligible for caching and is always considered to be out-of-date.

squash! Declare a task's outputs, enabling incremental build and caching
2018-08-04 04:29:59 -05:00

128 lines
3.2 KiB
Groovy

plugins {
id 'com.github.hauner.jarTest'
id 'cpp'
id 'eclipse'
id 'edu.wpi.first.GradleJni' version '0.2.1'
}
eclipse.project.natures 'org.eclipse.pde.PluginNature'
prepareIntelliJIDEA.dependsOn jarTest
sourceSets.test.java.srcDirs = ['harness-src/java']
dependencies {
testCompile(
'junit:junit:4.12',
project(':com.ibm.wala.cast'),
project(':com.ibm.wala.core'),
project(':com.ibm.wala.util'),
project(configuration: 'testArchives', path: ':com.ibm.wala.core.tests'),
)
}
def currentJvm = org.gradle.internal.jvm.Jvm.current()
def addCastRpath(currentJvm, targetPlatform, linker) {
switch (targetPlatform.operatingSystem.name) {
case 'linux':
case 'osx':
[
// TODO: compute path on following line from 'cast' library properties somehow
"${project(':com.ibm.wala.cast').buildDir}/libs/cast/shared",
// TODO: compute paths on following lines from 'jdk' library properties somehow
"${currentJvm.javaHome}/jre/lib/amd64/server",
"${currentJvm.javaHome}/jre/lib/server",
].each { linker.args "-Wl,-rpath,$it" }
}
}
model {
components {
xlator_test(JniNativeLibrarySpec) {
javaCompileTasks << compileTestJava
sources.cpp {
source {
srcDirs = ['harness-src/c']
include 'smoke.cpp'
}
['cast', 'jdk'].each {
lib project: ':com.ibm.wala.cast', library: it
}
}
binaries {
withType(StaticLibraryBinarySpec) {
buildable = false
}
withType(SharedLibraryBinarySpec) {
addCastRpath(currentJvm, targetPlatform, linker)
}
}
}
smoke_main(NativeExecutableSpec) {
sources.cpp {
source {
srcDirs = ['harness-src/c']
include 'smoke_main.cpp'
}
['cast', 'jdk'].each {
lib project: ':com.ibm.wala.cast', library: it
}
}
binaries.all {
addCastRpath(currentJvm, targetPlatform, linker)
}
}
}
tasks {
test {
def lib = linkXlator_testSharedLibrary
dependsOn lib
systemProperty 'java.library.path', lib.destinationDirectory.get().asFile
}
checkSmoke_main(Exec) {
// main executable to run for test
def executableBinary = $.binaries.smoke_mainExecutable
executable executableBinary.executableFile
dependsOn executableBinary
def pathElements = [$.binaries.test.getClassesDir()]
// implementations of native methods
def library = $.binaries.xlator_testSharedLibrary
dependsOn library
pathElements << library.sharedLibraryFile.parent
// "primordial.txt" resource loaded during test
def coreResources = project(':com.ibm.wala.core').processResources
dependsOn coreResources
pathElements << coreResources.destinationDir
// additional supporting Java class files
['cast', 'core', 'util'].each {
def compileJava = project(":com.ibm.wala.$it").compileJava
dependsOn compileJava
pathElements << compileJava.destinationDir
}
// all combined as a colon-delimited path list
args pathElements.join(':')
// log output to file, although we don't validate it
final def outFile = file("$temporaryDir/stdout-and-stderr.log")
outputs.file outFile
doFirst {
final def fileStream = new FileOutputStream(outFile)
standardOutput fileStream
errorOutput fileStream
}
}
check.dependsOn checkSmoke_main
}
}