File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -159,15 +159,19 @@ ${listToString(testTargets)}
159159 }
160160}
161161
162- fun filterTests (validTestMethods : List <String >, testTargets : List <String >): List <String > {
163- if (testTargets .isEmpty()) {
162+ fun filterTests (validTestMethods : List <String >, testTargetsRgx : List <String >): List <String > {
163+ if (testTargetsRgx .isEmpty()) {
164164 return validTestMethods
165165 }
166166
167167 return validTestMethods.filter { test ->
168- testTargets.forEach { target ->
169- if (test.matches(target.toRegex())) {
170- return @filter true
168+ testTargetsRgx.forEach { target ->
169+ try {
170+ if (test.matches(target.toRegex())) {
171+ return @filter true
172+ }
173+ } catch (e: Exception ) {
174+ throw IllegalArgumentException (" Invalid regex: $target " , e)
171175 }
172176 }
173177
Original file line number Diff line number Diff line change @@ -626,6 +626,11 @@ IosArgs
626626 " ClassFourTest/testFour"
627627 )
628628
629+ @Test(expected = IllegalArgumentException ::class )
630+ fun `invalid regex filter throws custom exception` () {
631+ filterTests(listOf (" test" ), testTargetsRgx = listOf (" *." ))
632+ }
633+
629634 @Test
630635 fun filterTests_emptyFilter () {
631636 val tests = getValidTestsSample()
You can’t perform that action at this time.
0 commit comments