2019-10-31 13:31:07 -05:00
|
|
|
#!/usr/bin/env python3
|
2017-08-17 07:38:42 +02:00
|
|
|
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
import unittest
|
|
|
|
import importlib
|
|
|
|
import argparse
|
|
|
|
|
|
|
|
|
2022-08-10 03:25:31 -04:00
|
|
|
def discover_tests(directory, callback):
|
2017-08-17 07:38:42 +02:00
|
|
|
do_insert = True
|
|
|
|
for _f in os.listdir(directory):
|
|
|
|
f = "%s/%s" % (directory, _f)
|
|
|
|
if os.path.isdir(f):
|
2022-08-10 03:25:31 -04:00
|
|
|
discover_tests(f, callback)
|
2017-08-17 07:38:42 +02:00
|
|
|
continue
|
|
|
|
if not os.path.isfile(f):
|
|
|
|
continue
|
|
|
|
if do_insert:
|
|
|
|
sys.path.insert(0, directory)
|
|
|
|
do_insert = False
|
|
|
|
if not _f.startswith("test_") or not _f.endswith(".py"):
|
|
|
|
continue
|
|
|
|
name = "".join(f.split("/")[-1].split(".")[:-1])
|
|
|
|
module = importlib.import_module(name)
|
|
|
|
for name, cls in module.__dict__.items():
|
|
|
|
if not isinstance(cls, type):
|
|
|
|
continue
|
|
|
|
if not issubclass(cls, unittest.TestCase):
|
|
|
|
continue
|
2018-06-24 22:49:55 +02:00
|
|
|
if name == "VppTestCase" or name.startswith("Template"):
|
2017-08-17 07:38:42 +02:00
|
|
|
continue
|
|
|
|
for method in dir(cls):
|
|
|
|
if not callable(getattr(cls, method)):
|
|
|
|
continue
|
|
|
|
if method.startswith("test_"):
|
|
|
|
callback(_f, cls, method)
|
|
|
|
|
|
|
|
|
|
|
|
def print_callback(file_name, cls, method):
|
|
|
|
print("%s.%s.%s" % (file_name, cls.__name__, method))
|