From d7b543de403c9c573ab35d0c9588e4aa0774490a Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Thu, 20 Mar 2014 15:23:53 +0300 Subject: runtest.py: Simplify test discovery code (and show where unittests are) --- runtest.py | 51 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 20 deletions(-) (limited to 'runtest.py') diff --git a/runtest.py b/runtest.py index eee88dc5..902b2a32 100755 --- a/runtest.py +++ b/runtest.py @@ -643,6 +643,9 @@ if python3incompatibilities: tests = [] +unittests = [] +endtests = [] + def find_Tests_py(directory): """ Look for unit tests """ result = [] @@ -674,30 +677,20 @@ def find_py(directory): result.append(os.path.join(dirpath, fname)) return sorted(result) -if args: - for a in args: - for path in glob.glob(a): - if os.path.isdir(path): - if path[:3] == 'src': - for p in find_Tests_py(path): - tests.append(p) - elif path[:4] == 'test': - for p in find_py(path): - tests.append(p) - else: - tests.append(path) -elif testlistfile: +if testlistfile: tests = open(testlistfile, 'r').readlines() tests = [x for x in tests if x[0] != '#'] tests = [x[:-1] for x in tests] tests = [x.strip() for x in tests] -elif options.all: - # Find all of the SCons functional tests in the local directory - # tree. This is anything under the 'src' subdirectory that ends - # with 'Tests.py', or any Python script (*.py) under the 'test' - # subdirectory. +else: + testpaths = [] + + # Each test path specifies a test file, or a directory to search for + # SCons tests. SCons code layout assumes that any file under the 'src' + # subdirectory that ends with 'Tests.py' is a unit test, and Python + # script (*.py) under the 'test' subdirectory an end-to-end test. # # Note that there are some tests under 'src' that *begin* with # 'test_', but they're packaging and installation tests, not @@ -705,8 +698,26 @@ elif options.all: # still be executed by hand, though, and are routinely executed # by the Aegis packaging build to make sure that we're building # things correctly.) - tests.extend(find_Tests_py('src')) - tests.extend(find_py('test')) + + if options.all: + testpaths = ['src', 'test'] + elif args: + testpaths = args + + for tp in testpaths: + for path in glob.glob(tp): + if os.path.isdir(path): + if path.endswith('src'): + for p in find_Tests_py(path): + unittests.append(p) + elif path.endswith('test'): + for p in find_py(path): + endtests.append(p) + else: + tests.append(path) + + tests.extend(unittests) + tests.extend(endtests) tests.sort() if not tests: -- cgit v1.2.1