Skip to content

Commit

Permalink
Add junit report confiugs (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewTPage authored Aug 27, 2020
1 parent eaeba74 commit 4cd3729
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 4 deletions.
14 changes: 14 additions & 0 deletions buildSrc/src/main/java/com/osacky/flank/gradle/FladleConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -224,4 +224,18 @@ interface FladleConfig {
*/
@get:Input
val outputStyle: Property<String>

/**
* Flank provides two ways for parsing junit xml results.
* New way uses google api instead of merging xml files, but can generate slightly different output format.
* This flag allows fallback for legacy xml junit results parsing
*/
@get:Input
var legacyJunitResult: Boolean

/**
* Enables creating an additional local junit result on local storage with failure nodes on passed flaky tests.
*/
@get:Input
var fullJunitResult: Boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,7 @@ data class FladleConfigImpl(
override var roboScript: String?,
override var roboDirectives: List<List<String>>,
override var testTimeout: String,
override var outputStyle: Property<String>
override var outputStyle: Property<String>,
override var legacyJunitResult: Boolean,
override var fullJunitResult: Boolean
) : FladleConfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import javax.inject.Inject
open class FlankGradleExtension @Inject constructor(objects: ObjectFactory) : FladleConfig {
@get:Input
val flankCoordinates: Property<String> = objects.property(String::class.java).convention("com.github.flank:flank")

@get:Input
val flankVersion: Property<String> = objects.property(String::class.java).convention("20.08.3")
// Project id is automatically discovered by default. Use this to override the project id.
Expand Down Expand Up @@ -102,6 +103,10 @@ open class FlankGradleExtension @Inject constructor(objects: ObjectFactory) : Fl

override val outputStyle: Property<String> = objects.property<String>().convention("single")

override var legacyJunitResult: Boolean = false

override var fullJunitResult: Boolean = false

@Internal
val configs: NamedDomainObjectContainer<FladleConfigImpl> = objects.domainObjectContainer(FladleConfigImpl::class.java) {
FladleConfigImpl(
Expand Down Expand Up @@ -141,7 +146,9 @@ open class FlankGradleExtension @Inject constructor(objects: ObjectFactory) : Fl
roboScript = roboScript,
roboDirectives = roboDirectives,
testTimeout = testTimeout,
outputStyle = objects.property<String>().convention(outputStyle)
outputStyle = objects.property<String>().convention(outputStyle),
legacyJunitResult = legacyJunitResult,
fullJunitResult = fullJunitResult
)
}

Expand Down
4 changes: 4 additions & 0 deletions buildSrc/src/main/java/com/osacky/flank/gradle/YamlWriter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ internal class YamlWriter {
val smartFlankDisableUpload = config.smartFlankDisableUpload
val localResultsDir = config.localResultsDir.orNull
val testTargetsAlwaysRun = config.testTargetsAlwaysRun
val legacyJunitResult = config.legacyJunitResult
val fullJunitResult = config.fullJunitResult

appendln("flank:")

Expand Down Expand Up @@ -96,6 +98,8 @@ internal class YamlWriter {
}
}

appendln(" legacy-junit-result: $legacyJunitResult")
appendln(" full-junit-result: $fullJunitResult")
appendln(" output-style: ${config.outputStyle.get()}")
}

Expand Down
66 changes: 66 additions & 0 deletions buildSrc/src/test/java/com/osacky/flank/gradle/YamlWriterTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ class YamlWriterTest {
ignore-failed-tests: false
disable-sharding: false
smart-flank-disable-upload: false
legacy-junit-result: false
full-junit-result: false
output-style: single
""".trimIndent() + '\n' // Dunno why this needs to be here to make the tests pass.
)
Expand Down Expand Up @@ -255,6 +257,8 @@ class YamlWriterTest {
ignore-failed-tests: false
disable-sharding: false
smart-flank-disable-upload: false
legacy-junit-result: false
full-junit-result: false
output-style: single
""".trimIndent() + '\n'
)
Expand All @@ -271,6 +275,8 @@ class YamlWriterTest {
" ignore-failed-tests: false\n" +
" disable-sharding: false\n" +
" smart-flank-disable-upload: false\n" +
" legacy-junit-result: false\n" +
" full-junit-result: false\n" +
" output-style: single\n",
yamlWriter.writeFlankProperties(extension)
)
Expand All @@ -289,6 +295,8 @@ class YamlWriterTest {
" ignore-failed-tests: false\n" +
" disable-sharding: false\n" +
" smart-flank-disable-upload: false\n" +
" legacy-junit-result: false\n" +
" full-junit-result: false\n" +
" output-style: single\n",
yamlWriter.writeFlankProperties(extension)
)
Expand All @@ -307,6 +315,8 @@ class YamlWriterTest {
" ignore-failed-tests: false\n" +
" disable-sharding: false\n" +
" smart-flank-disable-upload: false\n" +
" legacy-junit-result: false\n" +
" full-junit-result: false\n" +
" output-style: single\n",
yamlWriter.writeFlankProperties(extension)
)
Expand All @@ -325,6 +335,8 @@ class YamlWriterTest {
" ignore-failed-tests: false\n" +
" disable-sharding: false\n" +
" smart-flank-disable-upload: false\n" +
" legacy-junit-result: false\n" +
" full-junit-result: false\n" +
" output-style: single\n",
yamlWriter.writeFlankProperties(extension)
)
Expand All @@ -342,6 +354,8 @@ class YamlWriterTest {
" ignore-failed-tests: false\n" +
" disable-sharding: false\n" +
" smart-flank-disable-upload: false\n" +
" legacy-junit-result: false\n" +
" full-junit-result: false\n" +
" output-style: single\n",
yamlWriter.writeFlankProperties(extension)
)
Expand All @@ -360,6 +374,8 @@ class YamlWriterTest {
" ignore-failed-tests: false\n" +
" disable-sharding: false\n" +
" smart-flank-disable-upload: false\n" +
" legacy-junit-result: false\n" +
" full-junit-result: false\n" +
" output-style: single\n",
yamlWriter.writeFlankProperties(extension)
)
Expand All @@ -380,6 +396,8 @@ class YamlWriterTest {
" ignore-failed-tests: false\n" +
" disable-sharding: false\n" +
" smart-flank-disable-upload: false\n" +
" legacy-junit-result: false\n" +
" full-junit-result: false\n" +
" output-style: single\n",
yamlWriter.writeFlankProperties(extension)
)
Expand Down Expand Up @@ -529,6 +547,8 @@ class YamlWriterTest {
" ignore-failed-tests: false\n" +
" disable-sharding: false\n" +
" smart-flank-disable-upload: false\n" +
" legacy-junit-result: false\n" +
" full-junit-result: false\n" +
" output-style: single\n",
yamlWriter.writeFlankProperties(extension)
)
Expand Down Expand Up @@ -602,6 +622,8 @@ class YamlWriterTest {
" ignore-failed-tests: false\n" +
" disable-sharding: false\n" +
" smart-flank-disable-upload: false\n" +
" legacy-junit-result: false\n" +
" full-junit-result: false\n" +
" output-style: single\n",
yamlWriter.writeFlankProperties(extension)
)
Expand All @@ -621,6 +643,8 @@ class YamlWriterTest {
" ignore-failed-tests: false\n" +
" disable-sharding: false\n" +
" smart-flank-disable-upload: false\n" +
" legacy-junit-result: false\n" +
" full-junit-result: false\n" +
" output-style: single\n",
yamlWriter.writeFlankProperties(extension)
)
Expand All @@ -641,6 +665,8 @@ class YamlWriterTest {
" ignore-failed-tests: false\n" +
" disable-sharding: false\n" +
" smart-flank-disable-upload: false\n" +
" legacy-junit-result: false\n" +
" full-junit-result: false\n" +
" output-style: single\n",
yamlWriter.writeFlankProperties(extension)
)
Expand Down Expand Up @@ -721,6 +747,8 @@ class YamlWriterTest {
" ignore-failed-tests: false\n" +
" disable-sharding: false\n" +
" smart-flank-disable-upload: false\n" +
" legacy-junit-result: false\n" +
" full-junit-result: false\n" +
" output-style: single\n",
yamlWriter.writeFlankProperties(extension)
)
Expand All @@ -739,6 +767,8 @@ class YamlWriterTest {
" ignore-failed-tests: false\n" +
" disable-sharding: false\n" +
" smart-flank-disable-upload: false\n" +
" legacy-junit-result: false\n" +
" full-junit-result: false\n" +
" output-style: single\n"
)
}
Expand Down Expand Up @@ -778,6 +808,8 @@ class YamlWriterTest {
ignore-failed-tests: false
disable-sharding: false
smart-flank-disable-upload: false
legacy-junit-result: false
full-junit-result: false
output-style: single
""".trimIndent() + '\n'
)
Expand All @@ -795,6 +827,8 @@ class YamlWriterTest {
ignore-failed-tests: false
disable-sharding: false
smart-flank-disable-upload: false
legacy-junit-result: false
full-junit-result: false
output-style: single
""".trimIndent()

Expand Down Expand Up @@ -891,6 +925,38 @@ class YamlWriterTest {
assertTrue(properties.contains(" output-style: single"))
}

@Test
fun writeLegacyJunitResult() {
val properties = emptyExtension {
legacyJunitResult = true
}.toFlankProperties()

assertTrue(properties.contains(" legacy-junit-result: true"))
}

@Test
fun missingLegacyJunitResult() {
val properties = emptyExtension().toFlankProperties()

assertTrue(properties.contains(" legacy-junit-result: false"))
}

@Test
fun writeFullJunitResult() {
val properties = emptyExtension {
fullJunitResult = true
}.toFlankProperties()

assertTrue(properties.contains(" full-junit-result: true"))
}

@Test
fun missingFullJunitResult() {
val properties = emptyExtension().toFlankProperties()

assertTrue(properties.contains(" full-junit-result: false"))
}

@Test
fun writeClientDetails() {
val properties = emptyExtension {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class AutoConfigureFladleTest {
"""
> Task :android-project:printYml
gcloud:
app: [0-9a-zA-Z\/]*/android-project/build/outputs/apk/debug/android-project-debug.apk
test: [0-9a-zA-Z\/]*/android-project/build/outputs/apk/androidTest/debug/android-project-debug-androidTest.apk
app: [0-9a-zA-Z\/_]*/android-project/build/outputs/apk/debug/android-project-debug.apk
test: [0-9a-zA-Z\/_]*/android-project/build/outputs/apk/androidTest/debug/android-project-debug-androidTest.apk
device:
- model: Pixel2
version: 26
Expand All @@ -77,6 +77,9 @@ class AutoConfigureFladleTest {
ignore-failed-tests: false
disable-sharding: false
smart-flank-disable-upload: false
legacy-junit-result: false
full-junit-result: false
output-style: single
""".trimIndent()
)
}
Expand Down
10 changes: 10 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ fladle {
["text", "field1", "my text"],
]
outputStyle = 'multi'
legacyJunitResult = false
fullJunitResult = false
}
```

Expand Down Expand Up @@ -375,3 +377,11 @@ Default value is single.
``` kotlin
outputStyle.set("single")
```

### legacyJunitResult
Flank provides two ways for parsing junit xml results.
New way uses google api instead of merging xml files, but can generate slightly different output format.
This flag allows fallback for legacy xml junit results parsing

### fullJunitResult
Enables creating an additional local junit result on local storage with failure nodes on passed flaky tests.

0 comments on commit 4cd3729

Please sign in to comment.