From fbf16aae7aa113b053720881996959894f55a145 Mon Sep 17 00:00:00 2001 From: Shajahan Palayil Date: Fri, 6 Oct 2023 11:38:07 +0200 Subject: [PATCH] improvement: trim spaces when filtering the only tests that should be run --- .../src/main/scala/bloop/testing/TestInternals.scala | 2 +- frontend/src/test/scala/bloop/TestFilterSpec.scala | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/frontend/src/main/scala/bloop/testing/TestInternals.scala b/frontend/src/main/scala/bloop/testing/TestInternals.scala index cda7346ae9..9637a519eb 100644 --- a/frontend/src/main/scala/bloop/testing/TestInternals.scala +++ b/frontend/src/main/scala/bloop/testing/TestInternals.scala @@ -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)) diff --git a/frontend/src/test/scala/bloop/TestFilterSpec.scala b/frontend/src/test/scala/bloop/TestFilterSpec.scala index 626feab62a..d0dfe952d0 100644 --- a/frontend/src/test/scala/bloop/TestFilterSpec.scala +++ b/frontend/src/test/scala/bloop/TestFilterSpec.scala @@ -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)) + } }