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

Commit

Permalink
Add qa filter support (#1)
Browse files Browse the repository at this point in the history
* docs: Analytics addition to readme (Flank#987)

* Added inital analytics template for team review

* Added analytics.md file

* Re-worked the wording as per discussion

* Release notes updated

* Fixes to wording, typos and recommendations as per pull request

* Update and rename analytics.md to error_monitoring.md

* Update README.md

* Update error_monitoring.md

* Update README.md

* Update error_monitoring.md

* Update error_monitoring.md

* Update release_notes.md

* Update README.md

Co-authored-by: Michael Wright <michael.wright@gogoapps.io>
Co-authored-by: bootstraponline <code@bootstraponline.com>

* Add filter_qa support in test-targets

Co-authored-by: Michael Wright <slooxied@gmail.com>
Co-authored-by: Michael Wright <michael.wright@gogoapps.io>
Co-authored-by: bootstraponline <code@bootstraponline.com>
  • Loading branch information
4 people authored Aug 17, 2020
1 parent df0c9ed commit b472912
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- [#988](https://github.com/Flank/flank/pull/988) Add versions description command for ios and android. ([adamfilipow92](https://github.com/adamfilipow92))
- [#969](https://github.com/Flank/flank/pull/969) Add locales description command for ios and android. ([adamfilipow92](https://github.com/adamfilipow92))
- [#989](https://github.com/Flank/flank/pull/989) CI changes: Check if valid title is used in PR. ([piotradamczyk5](https://github.com/piotradamczyk5))
- [#987](https://github.com/Flank/flank/pull/987) Flank Error Monitoring readme addition ([sloox](https://github.com/Sloox))
-

## v20.08.1
Expand Down
15 changes: 14 additions & 1 deletion test_runner/src/main/kotlin/ftl/filter/TestFilters.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ object TestFilters {
private const val ARGUMENT_TEST_FILE = "testFile"
private const val ARGUMENT_NOT_TEST_FILE = "notTestFile"

private const val ARGUMENT_ONLY_QA = "filter_qa"

private val FILTER_ARGUMENT by lazy {

val pattern = listOf(
Expand All @@ -56,7 +58,8 @@ object TestFilters {
ARGUMENT_TEST_PACKAGE,
ARGUMENT_NOT_TEST_PACKAGE,
ARGUMENT_TEST_FILE,
ARGUMENT_NOT_TEST_FILE
ARGUMENT_NOT_TEST_FILE,
ARGUMENT_ONLY_QA
).joinToString("|")

Pattern.compile("""($pattern)\s+(.+)""")
Expand Down Expand Up @@ -110,6 +113,7 @@ object TestFilters {
ARGUMENT_TEST_FILE -> fromTestFile(args)
ARGUMENT_NOT_TEST_FILE -> not(fromTestFile(args))
ARGUMENT_TEST_SIZE -> withSize(args)
ARGUMENT_ONLY_QA -> onlyQA()
else -> throw FlankConfigurationError("Filtering option $command not supported")
}
}
Expand Down Expand Up @@ -155,6 +159,15 @@ object TestFilters {
isAnnotation = true
)

private fun onlyQA(): TestFilter = TestFilter(
describe = "onlyQA",
shouldRun = { testMethod ->
val className = testMethod.testName.split("#").first()
val simpleName = className.split(".").last()
simpleName.startsWith("QA") && simpleName.endsWith("Test")
}
)

private fun not(filter: TestFilter): TestFilter = TestFilter(
describe = "not (${filter.describe})",
shouldRun = { testMethod ->
Expand Down
3 changes: 2 additions & 1 deletion test_runner/src/main/kotlin/ftl/run/DumpShards.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import ftl.run.model.AndroidMatrixTestShards
import ftl.run.platform.android.getAndroidMatrixShards
import ftl.util.FlankConfigurationError
import ftl.util.obfuscatePrettyPrinter
import java.io.File
import java.nio.file.Files
import java.nio.file.Paths

Expand Down Expand Up @@ -51,7 +52,7 @@ private fun saveShardChunks(
Paths.get(shardFilePath),
getGson(obfuscatedOutput).toJson(shards).toByteArray()
)
println("Saved $size shards to $shardFilePath")
println("Saved $size shards to ${File(shardFilePath).absolutePath}")
}

private fun getGson(obfuscatedOutput: Boolean) = if (obfuscatedOutput) obfuscatePrettyPrinter else prettyPrint
Expand Down
10 changes: 10 additions & 0 deletions test_runner/src/test/kotlin/ftl/filter/TestFiltersTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ val WITH_SMALL_ANNOTATION = TestMethod("whatever.Foo#testName", listOf(TestAnnot
val WITHOUT_LARGE_ANNOTATION = TestMethod("whatever.Foo#testName", emptyList())
val WITHOUT_MEDIUM_ANNOTATION = TestMethod("whatever.Foo#testName", emptyList())
val WITHOUT_SMALL_ANNOTATION = TestMethod("whatever.Foo#testName", emptyList())
val QA_TEST = TestMethod("whatever.QAIntroTest", emptyList())
val NON_QA_TEST = TestMethod("whatever.IntroTest", emptyList())
const val TEST_FILE = "src/test/kotlin/ftl/filter/fixtures/dummy-tests-file.txt"
const val TEST_FILE_2 = "src/test/kotlin/ftl/filter/fixtures/exclude-tests.txt"
private const val IGNORE_ANNOTATION = "org.junit.Ignore"
Expand Down Expand Up @@ -130,6 +132,14 @@ class TestFiltersTest {
assertThat(filter.shouldRun(WITHOUT_FOO_ANNOTATION)).isFalse()
}

@Test
fun testFilteringOnlyQA() {
val filter = fromTestTargets(listOf("filter_qa true"))

assertThat(filter.shouldRun(QA_TEST)).isTrue()
assertThat(filter.shouldRun(NON_QA_TEST)).isFalse()
}

@Test
fun testFilteringBySizeLarge() {
val filter = fromTestTargets(listOf("size large"))
Expand Down

0 comments on commit b472912

Please sign in to comment.