blob: 1514c9b6d4c086afc994ceb1862fe56b5b8b08fb [file] [log] [blame]
Ben Murdoch097c5b22016-05-18 11:27:45 +01001#!/usr/bin/env python
2# Copyright 2015 The Chromium Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6# pylint: disable=protected-access
7
8import logging
9import sys
10import unittest
11import unittest_util
12
13
14class FilterTestNamesTest(unittest.TestCase):
15
16 possible_list = ["Foo.One",
17 "Foo.Two",
18 "Foo.Three",
19 "Bar.One",
20 "Bar.Two",
21 "Bar.Three",
22 "Quux.One",
23 "Quux.Two",
24 "Quux.Three"]
25
26 def testMatchAll(self):
27 x = unittest_util.FilterTestNames(self.possible_list, "*")
28 self.assertEquals(x, self.possible_list)
29
30 def testMatchPartial(self):
31 x = unittest_util.FilterTestNames(self.possible_list, "Foo.*")
32 self.assertEquals(x, ["Foo.One", "Foo.Two", "Foo.Three"])
33
34 def testMatchFull(self):
35 x = unittest_util.FilterTestNames(self.possible_list, "Foo.Two")
36 self.assertEquals(x, ["Foo.Two"])
37
38 def testMatchTwo(self):
39 x = unittest_util.FilterTestNames(self.possible_list, "Bar.*:Foo.*")
40 self.assertEquals(x, ["Bar.One",
41 "Bar.Two",
42 "Bar.Three",
43 "Foo.One",
44 "Foo.Two",
45 "Foo.Three"])
46
47 def testMatchWithNegative(self):
48 x = unittest_util.FilterTestNames(self.possible_list, "Bar.*:Foo.*-*.Three")
49 self.assertEquals(x, ["Bar.One",
50 "Bar.Two",
51 "Foo.One",
52 "Foo.Two"])
53
54 def testMatchOverlapping(self):
55 x = unittest_util.FilterTestNames(self.possible_list, "Bar.*:*.Two")
56 self.assertEquals(x, ["Bar.One",
57 "Bar.Two",
58 "Bar.Three",
59 "Foo.Two",
60 "Quux.Two"])
61
62
63if __name__ == '__main__':
64 logging.getLogger().setLevel(logging.DEBUG)
65 unittest.main(verbosity=2)