Skip to content

Commit

Permalink
build: Make it easier to manually run GWT tests from the IDE (deephav…
Browse files Browse the repository at this point in the history
…en#5725)

Summary from the new task's description:

Test wiring to run either unit or integration tests with a manual
browser and an already-running server. This makes it easier to run a
tests repeatedly, either one at a time or as a class/suite, without
paying to start/stop selenium and deephaven each time. The port will
remain constant at 8888 each run to let breakpoints continue to work
across repeated runs.
 
To use this, first start a server on port 10000 with anonymous access
enabled. Then, either select a test in IntelliJ to run using the
manualGwtTest task, or invoke from the command line with info logging
enabled and a specific test selected, e.g.:

./gradlew :web-client-api:manualGwtTest --info --tests
io.deephaven.web.client.api.NullValueTestGwt

Click the URL that is printed out to run the test in your browser, or
refresh an existing browser window.

Co-authored-by: Mike Bender <[email protected]>
  • Loading branch information
niloc132 and mofojed authored Jul 11, 2024
1 parent db5eb8e commit d7afa8e
Showing 1 changed file with 39 additions and 4 deletions.
43 changes: 39 additions & 4 deletions web/client-api/client-api.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ artifacts {
}

def gwtUnitTest = tasks.register('gwtUnitTest', Test) { t ->
t.group = 'verification'
t.systemProperties = [
'gwt.args': ['-runStyle HtmlUnit',
'gwt.args': ['-sourceLevel auto',
'-runStyle HtmlUnit',
'-ea',
'-style PRETTY',
"-war ${layout.buildDirectory.dir('unitTest-war').get().asFile.absolutePath}"
Expand Down Expand Up @@ -137,19 +139,20 @@ def stopSelenium = project.tasks.register('stopSelenium', DockerRemoveContainer)
}

def gwtIntegrationTest = tasks.register('gwtIntegrationTest', Test) { t ->
t.group = 'verification'
t.dependsOn(deephavenDocker.portTask, seleniumHealthy)
t.finalizedBy(deephavenDocker.endTask, stopSelenium)
doFirst {
t.doFirst {
def webdriverUrl = "http://localhost:${seleniumPort}/"
t.systemProperty('gwt.args', ["-runStyle io.deephaven.web.junit.RunStyleRemoteWebDriver:${webdriverUrl}?firefox",
t.systemProperty('gwt.args', ['-sourceLevel auto',
"-runStyle io.deephaven.web.junit.RunStyleRemoteWebDriver:${webdriverUrl}?firefox",
'-ea',
'-style PRETTY',
"-setProperty dh.server=http://${deephavenDocker.containerName.get()}:10000",
"-war ${layout.buildDirectory.dir('integrationTest-war').get().asFile.absolutePath}"
].join(' '))
t.classpath += tasks.getByName('gwtCompile').src
}
t.finalizedBy(deephavenDocker.endTask)
t.systemProperties = [
'gwt.persistentunitcachedir':layout.buildDirectory.dir('integrationTest-unitCache').get().asFile.absolutePath,
'webdriver.test.host':'host.docker.internal',
Expand All @@ -159,6 +162,38 @@ def gwtIntegrationTest = tasks.register('gwtIntegrationTest', Test) { t ->
t.scanForTestClasses = false
}

tasks.register('manualGwtTest', Test) {t ->
t.group = 'verification'
t.description = '''Test wiring to run either unit or integration tests with a manual browser and an already-running server.
This makes it easier to run a tests repeatedly, either one at a time or as a class/suite, without
paying to start/stop selenium and deephaven each time. The port will remain constant at 8888 each
run to let breakpoints continue to work across repeated runs.
To use this, first start a server on port 10000 with anonymous access enabled. Then, either select
a test in IntelliJ to run using the manualGwtTest task, or invoke from the command line with info
logging enabled and a specific test selected, e.g.:
./gradlew :web-client-api:manualGwtTest --info --tests io.deephaven.web.client.api.NullValueTestGwt
Click the URL that is printed out to run the test in your browser, or refresh an existing browser window.'''
t.doFirst {
t.systemProperty 'gwt.args', ['-port 8888',
'-sourceLevel auto',
'-runStyle Manual:1',
'-ea',
'-style PRETTY',
'-setProperty dh.server=http://localhost:10000',
'-setProperty compiler.useSourceMaps=true',
"-war ${layout.buildDirectory.dir('manualTest-war').get().asFile.absolutePath}"
].join(' ')
t.classpath += tasks.getByName('gwtCompile').src
}
t.systemProperties = [
'gwt.persistentunitcachedir':layout.buildDirectory.dir('integrationTest-unitCache').get().asFile.absolutePath,
]
t.useJUnit()
t.scanForTestClasses = false
}

tasks.named('check').configure {
dependsOn(gwtUnitTest, gwtIntegrationTest)
}
Expand Down

0 comments on commit d7afa8e

Please sign in to comment.