This is an automated email from the git hooks/post-receive script. eugene-guest pushed a commit to annotated tag OpenBSD in repository testng.
commit d6250d6c4f4a7fab0f0b1ab0d8fa050d708d6563 Author: Vladislav Rassokhin <[email protected]> Date: Sun Nov 23 01:09:06 2014 +0300 Minor refactoring in MethodGroupsHelper --- .../org/testng/internal/MethodGroupsHelper.java | 55 +++++++++++++++------- 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/testng/internal/MethodGroupsHelper.java b/src/main/java/org/testng/internal/MethodGroupsHelper.java index 11cb668..622a122 100644 --- a/src/main/java/org/testng/internal/MethodGroupsHelper.java +++ b/src/main/java/org/testng/internal/MethodGroupsHelper.java @@ -254,34 +254,57 @@ public class MethodGroupsHelper { ITestNGMethod method, ITestNGMethod[] methods, String groupRegexp) { - boolean foundGroup = false; - List<ITestNGMethod> vResult = Lists.newArrayList(); - Pattern groupPattern = PATTERN_CACHE.get(groupRegexp); - if (groupPattern == null) { - groupPattern = Pattern.compile(groupRegexp); - PATTERN_CACHE.put(groupRegexp, groupPattern); + ITestNGMethod[] found = findMethodsThatBelongToGroup(methods, groupRegexp); + + if (found.length == 0) { + method.setMissingGroup(groupRegexp); } + + return found; + } + + /** + * @param methods list of methods to search + * @param groupRegexp regex representing the group + * + * @return all the methods that belong to the group specified by the regular + * expression groupRegExp. methods[] is the list of all the methods we + * are choosing from. + */ + protected static ITestNGMethod[] findMethodsThatBelongToGroup(ITestNGMethod[] methods, String groupRegexp) + { + List<ITestNGMethod> vResult = Lists.newArrayList(); + final Pattern pattern = getPattern(groupRegexp); for (ITestNGMethod tm : methods) { String[] groups = tm.getGroups(); for (String group : groups) { - Pair<String, String> cacheKey = Pair.create(groupRegexp, group); - Boolean match = MATCH_CACHE.get(cacheKey); - if (match == null) { - match = groupPattern.matcher(group).matches(); - MATCH_CACHE.put(cacheKey, match); - } + Boolean match = isMatch(pattern, group); if (match) { vResult.add(tm); - foundGroup = true; } } } - if (!foundGroup) { - method.setMissingGroup(groupRegexp); + return vResult.toArray(new ITestNGMethod[vResult.size()]); + } + + private static Boolean isMatch(Pattern pattern, String group) { + Pair<String, String> cacheKey = Pair.create(pattern.pattern(), group); + Boolean match = MATCH_CACHE.get(cacheKey); + if (match == null) { + match = pattern.matcher(group).matches(); + MATCH_CACHE.put(cacheKey, match); } + return match; + } - return vResult.toArray(new ITestNGMethod[vResult.size()]); + private static Pattern getPattern(String groupRegexp) { + Pattern groupPattern = PATTERN_CACHE.get(groupRegexp); + if (groupPattern == null) { + groupPattern = Pattern.compile(groupRegexp); + PATTERN_CACHE.put(groupRegexp, groupPattern); + } + return groupPattern; } -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/testng.git _______________________________________________ pkg-java-commits mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-java-commits

