Example #1
0
def GetTestRunFilterArg(args, test_run):
    """ Merges json file filters with cmdline filters using
      test_filter.InitializeFilterFromArgs
  """

    # Convert cmdline filters to test-filter style
    filter_string = test_filter.InitializeFilterFromArgs(args)

    # Only add inclusion filters if there's not already one specified, since
    # they would conflict, see test_filter.ConflictingPositiveFiltersException.
    if not test_filter.HasPositivePatterns(filter_string):
        includes = test_run.get("includes", [])
        filter_string = test_filter.AppendPatternsToFilter(
            filter_string, positive_patterns=[i["match"] for i in includes])

    excludes = test_run.get("excludes", [])
    filter_string = test_filter.AppendPatternsToFilter(
        filter_string, negative_patterns=[e["match"] for e in excludes])

    if args.skip_expected_failures:
        filter_string = test_filter.AppendPatternsToFilter(
            filter_string, negative_patterns=GetExpectedFailures())

    if filter_string:
        return [TEST_FILTER_OPT + '=' + filter_string]
    else:
        return []
Example #2
0
 def testHasBoth(self):
     expected = True
     actual = test_filter.HasPositivePatterns('positive-negative')
     self.assertEqual(actual, expected)
Example #3
0
 def testEmpty(self):
     expected = False
     actual = test_filter.HasPositivePatterns('')
     self.assertEqual(actual, expected)
Example #4
0
 def testHasOnlyNegative(self):
     expected = False
     actual = test_filter.HasPositivePatterns('-negative')
     self.assertEqual(actual, expected)
Example #5
0
 def testHasOnlyPositive(self):
     expected = True
     actual = test_filter.HasPositivePatterns('positive')
     self.assertEquals(actual, expected)