Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(485)

Unified Diff: javatests/org/chromium/distiller/JsTestSuiteBase.java

Issue 1047853004: Use gtest_filter syntax in jstest filter (Closed) Base URL: git@github.com:chromium/dom-distiller.git@master
Patch Set: address comments Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build.xml ('k') | javatests/org/chromium/distiller/JsTestSuiteBaseTest.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: javatests/org/chromium/distiller/JsTestSuiteBase.java
diff --git a/javatests/org/chromium/distiller/JsTestSuiteBase.java b/javatests/org/chromium/distiller/JsTestSuiteBase.java
index e3fbb094920c1f27b9894877ce9dddcbaeafb6ff..ff6fbd94bba7fee604b9f814ac67a490166915db 100644
--- a/javatests/org/chromium/distiller/JsTestSuiteBase.java
+++ b/javatests/org/chromium/distiller/JsTestSuiteBase.java
@@ -8,6 +8,8 @@ import com.google.gwt.core.client.JavaScriptException;
import com.google.gwt.regexp.shared.RegExp;
import com.google.gwt.user.client.Window;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
@@ -125,14 +127,56 @@ public class JsTestSuiteBase {
}
private class TestFilter {
- RegExp regexp;
+ private final List<RegExp> pos;
+ private final List<RegExp> neg;
+
+ private RegExp convert(String q) {
+ // This is a simplified conversion, and doesn't handle all
+ // possible glob strings correctly.
+ q = q.replace(".", "\\.");
+ q = q.replace("*", ".*");
+ q = q.replace("?", ".");
+ return RegExp.compile("^" + q + "$");
+ }
+
TestFilter(String filter) {
- if (filter != null) regexp = RegExp.compile(filter);
+ pos = new ArrayList<RegExp>();
+ neg = new ArrayList<RegExp>();
+
+ if (filter == null) return;
+
+ String[] segments = filter.split("-");
+ if (segments.length > 2) {
+ LogUtil.logToConsole("[ERROR] filter \"" + filter + "\" is malformed.");
+ }
+ for (int i = 0; i < segments.length; i++) {
+ String[] filters = segments[i].split(":");
+ for (int j = 0; j < filters.length; j++) {
+ if (filters[j].length() == 0) continue;
+ RegExp r = convert(filters[j]);
+ if (i == 0) {
+ pos.add(r);
+ } else {
+ neg.add(r);
+ }
+ }
+ }
}
public boolean test(String className, String methodName) {
- if (regexp == null) return true;
- return regexp.test(className + "." + methodName);
+ boolean ans = false;
+ if (pos.size() == 0) ans = true;
+ for (int i = 0; i < pos.size(); i++) {
+ if (pos.get(i).test(className + "." + methodName)) {
+ ans = true;
+ }
+ }
+ for (int i = 0; i < neg.size(); i++) {
+ if (neg.get(i).test(className + "." + methodName)) {
+ ans = false;
+ }
+ }
+ return ans;
}
}
« no previous file with comments | « build.xml ('k') | javatests/org/chromium/distiller/JsTestSuiteBaseTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698