mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-30 00:51:02 +00:00
165f8af8c5
This feature allows us to group test cases into logical groups (categories), and to only run a subset of test cases based on these categories. Each test-case can have a new method getCategories(self): which returns a list of strings that are the categories to which the test case belongs. If a test-case does not provide its own categories, we will look for categories in the class that contains the test case. If that fails too, the default implementation looks for a .category file, which contains a comma separated list of strings. The test suite will recurse look for .categories up until the top level directory (which we guarantee will have an empty .category file). The driver dotest.py has a new --category <foo> option, which can be repeated, and specifies which categories of tests you want to run. (example: ./dotest.py --category objc --category expression) All tests that do not belong to any specified category will be skipped. Other filtering options still exist and should not interfere with category filtering. A few tests have been categorized. Feel free to categorize others, and to suggest new categories that we could want to use. All categories need to be validly defined in dotest.py, or the test suite will refuse to run when you use them as arguments to --category. In the end, failures will be reported on a per-category basis, as well as in the usual format. This is the very first stage of this feature. Feel free to chime in with ideas for improvements! llvm-svn: 164403
37 lines
918 B
Python
37 lines
918 B
Python
"""An example unittest copied from python tutorial."""
|
|
|
|
import random
|
|
import unittest
|
|
import traceback
|
|
|
|
class SequenceFunctionsTestCase(unittest.TestCase):
|
|
|
|
def setUp(self):
|
|
#traceback.print_stack()
|
|
self.seq = range(10)
|
|
|
|
def tearDown(self):
|
|
#traceback.print_stack()
|
|
pass
|
|
|
|
def test_shuffle(self):
|
|
# make sure the shuffled sequence does not lose any elements
|
|
random.shuffle(self.seq)
|
|
self.seq.sort()
|
|
self.assertEqual(self.seq, range(10))
|
|
|
|
def test_choice(self):
|
|
element = random.choice(self.seq)
|
|
self.assertTrue(element in self.seq)
|
|
|
|
def test_sample(self):
|
|
self.assertRaises(ValueError, random.sample, self.seq, 20)
|
|
for element in random.sample(self.seq, 5):
|
|
self.assertTrue(element in self.seq)
|
|
|
|
def getCategories(self):
|
|
return []
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|