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

Unified Diff: lib/unittest/unittest.dart

Issue 10662022: Unit test filtering. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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 | « lib/unittest/config.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/unittest/unittest.dart
===================================================================
--- lib/unittest/unittest.dart (revision 9065)
+++ lib/unittest/unittest.dart (working copy)
@@ -214,6 +214,12 @@
TestCase _soloTest;
/**
+ * If set, then only tests whose descriptions match this regexp pattern
+ * will be run.
+ */
+String _filter = null;
+
+/**
* (Deprecated) Evaluates the [function] and validates that it throws an
* exception. If [callback] is provided, then it will be invoked with the
* thrown exception. The callback may do any validation it wants. In addition,
@@ -242,6 +248,22 @@
}
/**
+ * Sets the regexp pattern filter which constrains which tests to run
+ * based on their descriptions.
+ */
+void setFilter(String filter) {
Siggi Cherem (dart-lang) 2012/06/25 21:40:59 use a setter instead: String set filter(String va
+ if (filter == '') filter = null;
+ _filter = filter;
+}
+
+/**
+ * Gets the regexp pattern filter which constrains which tests to run
+ * based on their descriptions.
+ */
+String getFilter() {
Siggi Cherem (dart-lang) 2012/06/25 21:40:59 use a getter instead: String get filter => _filte
+ return _filter;
+}
+/**
* Creates a new test case with the given description and body. The
* description will include the descriptions of any surrounding group()
* calls.
@@ -641,6 +663,10 @@
if (_soloTest != null) {
_tests = _tests.filter((t) => t == _soloTest);
}
+ if (_filter != null) {
Siggi Cherem (dart-lang) 2012/06/25 21:40:59 To simplify the API, I'm inclined to just make _fi
+ RegExp re = new RegExp(_filter);
+ _tests = _tests.filter((t) => re.hasMatch(t.description));
+ }
_config.onStart();
« no previous file with comments | « lib/unittest/config.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698