package com.perforce.workshop.tjuricek.p4oauth
import org.gradle.api.DefaultTask
/**
* This provides basic handles to the background test server process.
*
* It should be spawned (and detached) then stopped later.
*/
abstract class TestServerTask extends DefaultTask {
boolean isRunning() {
if (pidFile.exists()) {
logger.info("checking if process is running using `ps aux`")
def pid = pidFile.text.trim()
def proc = "ps aux".execute()
proc.waitFor()
if (proc.exitValue() != 0) {
throw new IllegalStateException("ps aux failed with exit code "
+ proc.exitValue() + "\n" + proc.errorStream.text)
}
def psOut = proc.inputStream.text
logger.info("output of ps: " + psOut)
return psOut.contains(pid)
}
return false;
}
File getTestServerDir() {
return project.file("${project.buildDir}/test-server")
}
File getPidFile() {
return new File(testServerDir, "pid")
}
}
#
Change
User
Description
Committed
#1
9138
tjuricek
Added a "test server" with startTestServer and stopTestServer gradle tasks.
The test server isn't 100% complete, but the gradle tasks should be. This is to be used to drive tests forward via a web browser.