Skip to content

Commit

Permalink
Support for jpy integration junit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
niloc132 committed May 18, 2021
1 parent f02fa07 commit 51137a9
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
44 changes: 44 additions & 0 deletions py/jpy-integration/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,50 @@ Task pythonToJava = tasks.create 'unittestPythonToJava', {
}

if (!PyEnv.pythonEnabled(project)) {
Closure<TaskProvider<Task>> gradleTestInDocker = { String taskName, SourceSet sourceSet ->

def gradleWrapper = tasks.register("${taskName}GradleInit", Wrapper.class) { wrapper ->
wrapper.scriptFile "${buildDir}/template-project/gradlew"
wrapper.jarFile "${buildDir}/template-project/gradle/wrapper/gradle-wrapper.jar"
}
return Docker.registerDockerTask(project, taskName) {
copyIn {
dependsOn gradleWrapper
from ("${buildDir}/template-project") {
into 'project'
}
from(project.file('src/javaToPython/build.gradle.template')) {
into 'project'
rename { file -> 'build.gradle' }
}
from (sourceSet.runtimeClasspath) {
into 'classpath'
}
from (sourceSet.output.getClassesDirs()) {
into 'classes'
}
}
dockerfile {
// base image with default java, python, wheels
from 'deephaven/runtime-base'

// set up the project
copyFile 'project', '/project'
workingDir '/project'
// run once with no actual classes, so that gradle is preinstalled and cached
runCommand '/project/gradlew'
copyFile 'classpath', '/classpath'
copyFile 'classes', '/classes'
}
entrypoint = ['/project/gradlew', 'test', '--info']
containerOutPath = '/project/build/test-results/test/'
copyOut {
into "${buildDir}/test-results/${taskName}"
}
}
}
testJavaToPython.dependsOn gradleTestInDocker('java-to-python-test', sourceSets.javaToPython)

// Task testTask = venvTest.javaTest(project, "java-to-python-test-${pv.name}", installWheels, sourceSets.javaToPython)
// testJavaToPython.dependsOn testTask

Expand Down
18 changes: 18 additions & 0 deletions py/jpy-integration/src/javaToPython/build.gradle.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
plugins {
id 'java-library'
}

// Classpath is already built, just need to pass to the test task
test.classpath = fileTree('/classpath/').plus(files('/classpath'))
test.testClassesDirs = files('/classes')

test.systemProperties([
'jpy.jpyLib':'/usr/local/lib/python3.7/dist-packages/jpy.cpython-37m-x86_64-linux-gnu.so',
'jpy.jdlLib':'/usr/local/lib/python3.7/dist-packages/jdl.cpython-37m-x86_64-linux-gnu.so',
'jpy.pythonLib':'/usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0',
// Cleaning up on a dedicated thread has some issues when there is frequent starting
// and stopping of the python virtual environment. We'll rely on cleaning up inline
// when necessary.
'PyObject.cleanup_on_thread':'false',
// 'jpy.debug':'true'
])

0 comments on commit 51137a9

Please sign in to comment.