Skip to content

Commit

Permalink
Merge pull request #2171 from shasts/fix/trim-space-tests-only
Browse files Browse the repository at this point in the history
improvement: trim spaces when filtering the only tests that should be run
  • Loading branch information
tgodzik authored Oct 6, 2023
2 parents a1775b8 + fbf16aa commit 240095a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion frontend/src/main/scala/bloop/testing/TestInternals.scala
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ object TestInternals {
* @return A function that determines whether a test should be run given its FQCN.
*/
def parseFilters(filters: List[String]): String => Boolean = {
val (exclusionFilters, inclusionFilters) = filters.partition(_.startsWith("-"))
val (exclusionFilters, inclusionFilters) = filters.map(_.trim).partition(_.startsWith("-"))
val inc = inclusionFilters.map(toPattern)
val exc = exclusionFilters.map(f => toPattern(f.tail))

Expand Down
11 changes: 11 additions & 0 deletions frontend/src/test/scala/bloop/TestFilterSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,15 @@ class TestFilterSpec {
assertTrue("The filter should match.", filter(input1))
assertFalse("The filter shouldn't match.", filter(input2))
}

@Test
def testFilterShouldTrimWhiteSpace: Unit = {
val input0 = "foo.hello.world"
val input1 = "foo.something.world"
// Space at the ends should be ignored
val patterns = " foo.hello.world" :: "foo.something.world " :: Nil
val filter = TestInternals.parseFilters(patterns)
assertTrue("The filter should match.", filter(input0))
assertTrue("The filter should match.", filter(input1))
}
}

0 comments on commit 240095a

Please sign in to comment.