You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2013/03/16 01:21:19 UTC

svn commit: r1457177 - /incubator/mesos/trunk/src/tests/environment.cpp

Author: benh
Date: Sat Mar 16 00:21:19 2013
New Revision: 1457177

URL: http://svn.apache.org/r1457177
Log:
Fixed a bug where a filter specified via --gtest_filter (or
GTEST_FILTER) was not properly included in the filter we construct
based on the environment.

Review: https://reviews.apache.org/r/9973

Modified:
    incubator/mesos/trunk/src/tests/environment.cpp

Modified: incubator/mesos/trunk/src/tests/environment.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/environment.cpp?rev=1457177&r1=1457176&r2=1457177&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/environment.cpp (original)
+++ incubator/mesos/trunk/src/tests/environment.cpp Sat Mar 16 00:21:19 2013
@@ -102,23 +102,28 @@ static bool enable(const ::testing::Test
 // N.B. This MUST be done _before_ invoking RUN_ALL_TESTS.
 Environment::Environment()
 {
-  // First we split the current filter into positive and negative
-  // components (which are separated by a '-').
+  // First we split the current filter into enabled and disabled tests
+  // (which are separated by a '-').
   const string& filter = ::testing::GTEST_FLAG(filter);
-  string positive;
-  string negative;
+  string enabled;
+  string disabled;
 
   size_t dash = filter.find('-');
   if (dash != string::npos) {
-    positive = filter.substr(0, dash);
-    negative = filter.substr(dash + 1);
+    enabled = filter.substr(0, dash);
+    disabled = filter.substr(dash + 1);
   } else {
-    positive = filter;
+    enabled = filter;
   }
 
   // Use universal filter if not specified.
-  if (positive.empty()) {
-    positive = "*";
+  if (enabled.empty()) {
+    enabled = "*";
+  }
+
+  // Ensure disabled tests end with ":" separator before we add more.
+  if (!disabled.empty() && !strings::endsWith(disabled, ":")) {
+    disabled += ":";
   }
 
   // Construct the filter string to handle system or platform specific tests.
@@ -130,16 +135,16 @@ Environment::Environment()
 
       if (!enable(*testCase->GetTestInfo(j))) {
         // Append 'TestCase.TestName:'.
-        negative.append(testInfo->test_case_name());
-        negative.append(".");
-        negative.append(testInfo->name());
-        negative.append(":");
+        disabled.append(testInfo->test_case_name());
+        disabled.append(".");
+        disabled.append(testInfo->name());
+        disabled.append(":");
       }
     }
   }
 
   // Now update the gtest flag.
-  ::testing::GTEST_FLAG(filter) = positive + "-" + negative;
+  ::testing::GTEST_FLAG(filter) = enabled + "-" + disabled;
 }