Skip to content

Commit

Permalink
use TestExceptionFormat to drive the stacktrace reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
maiflai committed Jul 20, 2016
1 parent a8739c3 commit 06ad7bc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
13 changes: 7 additions & 6 deletions src/main/groovy/com/github/maiflai/ScalaTestAction.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import org.gradle.api.GradleException
import org.gradle.api.internal.file.FileResolver
import org.gradle.api.reporting.DirectoryReport
import org.gradle.api.tasks.testing.Test
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.gradle.api.tasks.util.PatternSet
import org.gradle.logging.ConsoleRenderer
Expand Down Expand Up @@ -102,14 +103,14 @@ class ScalaTestAction implements Action<Test> {

static String exceptions(Test t) {
if (t.testLogging.showExceptions) {
if (t.testLogging.showCauses) {
'F'
} else {
'S'
switch (t.testLogging.exceptionFormat) {
case TestExceptionFormat.FULL:
return 'F'
case TestExceptionFormat.SHORT:
return 'S'
}
} else {
''
}
return ''
}

static String durations = 'D'
Expand Down
3 changes: 2 additions & 1 deletion src/main/groovy/com/github/maiflai/ScalaTestPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import org.gradle.api.Project
import org.gradle.api.plugins.JavaPlugin
import org.gradle.api.plugins.scala.ScalaPlugin
import org.gradle.api.tasks.testing.Test
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.gradle.api.tasks.util.PatternSet

Expand All @@ -26,7 +27,7 @@ class ScalaTestPlugin implements Plugin<Project> {
new JacocoTestAction(),
new ScalaTestAction()
]
test.testLogging.showCauses = false
test.testLogging.exceptionFormat = TestExceptionFormat.SHORT
test.extensions.add(ScalaTestAction.TAGS, new PatternSet())
List<String> suites = []
test.extensions.add(ScalaTestAction.SUITES, suites)
Expand Down
16 changes: 15 additions & 1 deletion src/test/groovy/com/github/maiflai/ScalaTestActionTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package com.github.maiflai

import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.gradle.process.internal.JavaExecAction
import org.gradle.testfixtures.ProjectBuilder
import org.hamcrest.CoreMatchers
import org.hamcrest.Description
import org.hamcrest.Matcher
import org.hamcrest.TypeSafeMatcher
Expand Down Expand Up @@ -82,6 +82,20 @@ class ScalaTestActionTest {
assertThat(commandLine(test), hasOutput('oD'))
}

@Test
public void fullStackTraces() throws Exception {
Task test = testTask()
test.testLogging.exceptionFormat = TestExceptionFormat.FULL
assertThat(commandLine(test), hasOutput('oDF'))
}

@Test
public void shortStackTraces() throws Exception {
Task test = testTask()
test.testLogging.exceptionFormat = TestExceptionFormat.SHORT
assertThat(commandLine(test), hasOutput('oDS'))
}

@Test
public void maxHeapSizeIsAdded() throws Exception {
Task test = testTask()
Expand Down

0 comments on commit 06ad7bc

Please sign in to comment.