Skip to content

Commit

Permalink
Merge pull request #1750 from treyturner/feat/CaseInsensitiveIgnoreTag
Browse files Browse the repository at this point in the history
Evaluate @ignore tags case insensitively
  • Loading branch information
ptrthomas authored Aug 31, 2021
2 parents bfaf500 + b657677 commit a91b4af
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
9 changes: 9 additions & 0 deletions karate-core/src/main/java/com/intuit/karate/StringUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,15 @@ public static void removeIgnoreKeyCase(Map<String, ?> map, String name) {
}
}

public static boolean containsIgnoreCase(List<String> list, String str) {
for (String i : list) {
if (i.equalsIgnoreCase(str)) {
return true;
}
}
return false;
}

public static String throwableToString(Throwable t) {
try(final StringWriter sw = new StringWriter();
final PrintWriter pw = new PrintWriter(sw, true)) {
Expand Down
2 changes: 1 addition & 1 deletion karate-core/src/main/java/com/intuit/karate/core/Tags.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public Tags(Collection<Tag> in) {
}

public boolean evaluate(String tagSelector, String karateEnv) {
if (tags.contains(Tag.IGNORE)) {
if (StringUtils.containsIgnoreCase(tags, Tag.IGNORE)) {
return false;
}
Values envValues = valuesFor(Tag.ENV);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,12 @@ void testWrappedLinesEstimate() {
StringUtils.wrappedLinesEstimate("", 2));
}

@Test
void testContainsIgnoreCase() {
List<String> list = Arrays.asList("foo", "bar");
assertTrue(StringUtils.containsIgnoreCase(list, "foo"));
assertTrue(StringUtils.containsIgnoreCase(list, "Foo"));
assertFalse(StringUtils.containsIgnoreCase(list, "baz"));
}

}

0 comments on commit a91b4af

Please sign in to comment.