-
Notifications
You must be signed in to change notification settings - Fork 304
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Escape regex-relevant characters in test filter (#5745)
Go tests can contain arbitrary characters because they're not tied to a symbol name in a source file. Accordingly, they may contain characters which have special meaning for regexes. Because the Go test runner interprets this flag as a regex, we need to escape these. Without this, running a single test from the gutter, Bazel will exit 0 and look happy, but it won't have actually run the test (which perhaps would have failed if it had run).
- Loading branch information
1 parent
0ef2bef
commit 4fa29cf
Showing
3 changed files
with
48 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...tests/unittests/com/google/idea/blaze/golang/run/producers/GoTestContextProviderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.google.idea.blaze.golang.run.producers; | ||
|
||
import com.google.idea.blaze.base.BlazeTestCase; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.JUnit4; | ||
|
||
import static com.google.common.truth.Truth.assertThat; | ||
|
||
@RunWith(JUnit4.class) | ||
public class GoTestContextProviderTest extends BlazeTestCase { | ||
@Test | ||
public void testRegexifyTestFilter() { | ||
String regexified = GoTestContextProvider.regexifyTestFilter("Test/with/subtest(good \\ or \\ bad)"); | ||
assertThat(regexified).isEqualTo("^Test/with/subtest\\(good \\\\ or \\\\ bad\\)$"); | ||
} | ||
} |