Created
May 6, 2020 12:38
-
-
Save Mahoney/fa80ea5c7819777848a976bd61956b47 to your computer and use it in GitHub Desktop.
Run xvfb around gradle tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plugins { | |
kotlin("jvm") | |
id("com.github.johnrengelman.processes") version "0.5.0" | |
} | |
val handle: Property<com.github.jengelman.gradle.plugins.processes.ProcessHandle> = project.objects.property() | |
val startXvfb by tasks.registering { | |
val processHandle = project.procs.fork(closureOf<ExecSpec> { | |
commandLine("/opt/X11/bin/Xvfb", ":99", "-ac") | |
}) | |
handle.set(processHandle) | |
} | |
val stopXvfb by tasks.registering { | |
handle.orNull?.abort() | |
} | |
val test by tasks.existing(Test::class) { | |
dependsOn(startXvfb) | |
environment["DISPLAY"] = ":99" | |
finalizedBy(stopXvfb) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment