summaryrefslogtreecommitdiff
path: root/deps/v8/build/util/lib/common/unittest_util_test.py
blob: 1514c9b6d4c086afc994ceb1862fe56b5b8b08fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python
# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# pylint: disable=protected-access

import logging
import sys
import unittest
import unittest_util


class FilterTestNamesTest(unittest.TestCase):

  possible_list = ["Foo.One",
                   "Foo.Two",
                   "Foo.Three",
                   "Bar.One",
                   "Bar.Two",
                   "Bar.Three",
                   "Quux.One",
                   "Quux.Two",
                   "Quux.Three"]

  def testMatchAll(self):
    x = unittest_util.FilterTestNames(self.possible_list, "*")
    self.assertEquals(x, self.possible_list)

  def testMatchPartial(self):
    x = unittest_util.FilterTestNames(self.possible_list, "Foo.*")
    self.assertEquals(x, ["Foo.One", "Foo.Two", "Foo.Three"])

  def testMatchFull(self):
    x = unittest_util.FilterTestNames(self.possible_list, "Foo.Two")
    self.assertEquals(x, ["Foo.Two"])

  def testMatchTwo(self):
    x = unittest_util.FilterTestNames(self.possible_list, "Bar.*:Foo.*")
    self.assertEquals(x, ["Bar.One",
                          "Bar.Two",
                          "Bar.Three",
                          "Foo.One",
                          "Foo.Two",
                          "Foo.Three"])

  def testMatchWithNegative(self):
    x = unittest_util.FilterTestNames(self.possible_list, "Bar.*:Foo.*-*.Three")
    self.assertEquals(x, ["Bar.One",
                          "Bar.Two",
                          "Foo.One",
                          "Foo.Two"])

  def testMatchOverlapping(self):
    x = unittest_util.FilterTestNames(self.possible_list, "Bar.*:*.Two")
    self.assertEquals(x, ["Bar.One",
                          "Bar.Two",
                          "Bar.Three",
                          "Foo.Two",
                          "Quux.Two"])


if __name__ == '__main__':
  logging.getLogger().setLevel(logging.DEBUG)
  unittest.main(verbosity=2)