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

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: match full name 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
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..4860e5415566c4fa5582f8d1cbbf333148fdf169 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,60 @@ public class JsTestSuiteBase {
}
private class TestFilter {
- RegExp regexp;
+ List<RegExp> pos;
+ List<RegExp> neg;
+
TestFilter(String filter) {
- if (filter != null) regexp = RegExp.compile(filter);
+ pos = new ArrayList<RegExp>();
+ neg = new ArrayList<RegExp>();
+
+ if (filter == null) return;
+
+ int begin = 0;
+ filter = filter + ":";
+ for (int i = 0; i < filter.length(); i++) {
cjhopman 2015/03/31 17:55:40 how about just split on "-" and then split each si
wychen 2015/03/31 18:26:49 Done.
+ if (filter.charAt(i) == ':' || filter.charAt(i) == '-') {
+ if (begin != i) {
+ Boolean isNeg = false;
cjhopman 2015/03/31 17:55:40 Doesn't this need to be initialized outside the lo
wychen 2015/03/31 18:26:49 isNeg is used to tell whether the current segment
+
+ if (filter.charAt(begin) == '-') {
+ isNeg = true;
+ begin++;
+ }
+ String q = filter.substring(begin, i);
+ q = q.replace(".", "\\.");
+ q = q.replace("*", ".*");
+ q = q.replace("?", ".");
+ RegExp r = RegExp.compile("^" + q + "$");
+ if (isNeg) {
+ neg.add(r);
+ } else {
+ pos.add(r);
+ }
+ }
+ if (filter.charAt(i) == ':') {
+ begin = i + 1;
+ } else {
+ begin = i;
+ }
+ }
+ }
}
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;
}
}

Powered by Google App Engine
This is Rietveld 408576698