Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
Increased to 0.4, improved error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
sglahn authored and elmarx committed Nov 27, 2018
1 parent b477e9d commit 1067c5f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ dependencies {
}

group = 'org.rewedigital'
version = '0.3'
version = '0.4'

gradlePlugin {
plugins {
Expand Down
2 changes: 1 addition & 1 deletion example-project/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ buildscript {
mavenLocal()
mavenCentral()
}
dependencies { classpath('org.rewedigital:frost:0.2') }
dependencies { classpath('org.rewedigital:frost:0.4') }
}
apply plugin: "org.rewedigital.frost"

Expand Down
24 changes: 16 additions & 8 deletions src/main/groovy/org/rewedigital/frost/tasks/FrostRunTask.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import org.gradle.api.logging.Logging
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.TaskAction
import org.rewedigital.frost.browsers.Browser
import org.rewedigital.frost.util.FrostException
import org.rewedigital.frost.util.Util
import org.yaml.snakeyaml.Yaml

Expand All @@ -30,6 +31,11 @@ class FrostRunTask extends DefaultTask {
new File(project.buildDir, "test-results/frost")
}

@OutputDirectory
def getReportDirectory() {
Util.composeOutputDirectory(project)
}

@TaskAction
def action() {
def workingDirectory = Util.workingDirectory(project)
Expand All @@ -50,10 +56,13 @@ class FrostRunTask extends DefaultTask {

try {
executeTestSuites(ports)
} catch (Exception e) {
} catch (FrostException e) {
e.failures.each { browser, exception ->
LOG.error("There were failing tests in ${browser.toString().toLowerCase()}. " +
"See the report at: ${getTestReportDirectory()}/${browser.toString().toLowerCase()}/tests/report.html")
}
def errorMessage = "Test execution failed."
if (project.extensions[EXTENSION_NAME].failBuildOnErrors) {
LOG.quiet(errorMessage)
throw new GradleException(errorMessage, e)
} else {
LOG.warn(errorMessage)
Expand All @@ -73,7 +82,7 @@ class FrostRunTask extends DefaultTask {
def testsDescription = testGroups ? "test groups: '${testGroups}'" : 'ALL tests'
LOG.info("Executing Test Suites ({}) ...", testsDescription)
File testSuitesDirectory = Util.testSuitesDirectory(project)
Exception lastException = null
def failures = [:]

def testSuiteStarters = []
Util.getBrowsers(project).each { Browser browser ->
Expand All @@ -84,8 +93,7 @@ class FrostRunTask extends DefaultTask {
def reportsDirectoryName = "${getTestReportDirectory()}/${browser.browserId}/${testSuitesDirectory.name}"
executeTestSuitesOnSpecificBrowser(testSuitesDirectory, reportsDirectoryName, seleniumDriverUrl, browser.browserId, testGroups, recursive)
} catch (Exception e) {
lastException = e
LOG.warn("Test suite execution failed: {}", e.getMessage())
failures.put(browser, e)
}
})
testSuiteStarters << thread
Expand All @@ -94,8 +102,8 @@ class FrostRunTask extends DefaultTask {
testSuiteStarters.each { it.start() }
testSuiteStarters.each { it.join(TESTSUITE_TIMEOUT_MILLIS) }

if (lastException != null) {
throw lastException
if (failures.size() > 0) {
throw new FrostException(failures)
}
}

Expand Down Expand Up @@ -126,7 +134,7 @@ class FrostRunTask extends DefaultTask {
cmd << "-Dgalen.default.browser=${browser}"
}

Util.executeSynchronously(cmd, "test__${browser}")
Util.executeSynchronously(cmd, "test__${browser}", getReportDirectory())
}

private void waitUntilServiceIsReady(port) {
Expand Down
10 changes: 10 additions & 0 deletions src/main/groovy/org/rewedigital/frost/util/FrostException.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.rewedigital.frost.util

class FrostException extends Exception {

def failures = [:]

FrostException(failures) {
this.failures = failures
}
}

0 comments on commit 1067c5f

Please sign in to comment.