mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-25 09:39:25 +01:00
test-runner: extend -S option
The -S/--sub-tests option allows the user to specify a test file from inside an autotest. Inside this file there may also be many test functions. This option is being extended to allow running a single test function inside a test file. For example: * Runs all test functions inside connection_test.py * ./test-runner -A some_test -S connection_test * Runs only connection_test.py test_connect_success() * ./test-runner -A some_test -S connection_test.test_connect_success
This commit is contained in:
parent
42fe6c5a15
commit
fd43a3938f
@ -1139,6 +1139,13 @@ def start_test(ctx, subtests, rqueue):
|
|||||||
|
|
||||||
# Iterating through each python test file
|
# Iterating through each python test file
|
||||||
for test in subtest:
|
for test in subtest:
|
||||||
|
limit_funcs = []
|
||||||
|
|
||||||
|
if ctx.args.sub_tests:
|
||||||
|
for i in ctx.args.sub_tests:
|
||||||
|
if len(i.split('.')) == 2:
|
||||||
|
limit_funcs.append(i.split('.')[1])
|
||||||
|
|
||||||
# Iterating through individual test functions inside a
|
# Iterating through individual test functions inside a
|
||||||
# Test() class. Due to the nature of unittest we have
|
# Test() class. Due to the nature of unittest we have
|
||||||
# to jump through some hoops to set up the test class
|
# to jump through some hoops to set up the test class
|
||||||
@ -1164,21 +1171,29 @@ def start_test(ctx, subtests, rqueue):
|
|||||||
result = TestResult()
|
result = TestResult()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
skip = len(limit_funcs) > 0 and func not in limit_funcs
|
||||||
|
|
||||||
# Set up class only on first test
|
# Set up class only on first test
|
||||||
if index == 0:
|
if index == 0:
|
||||||
dbg("%s\n\t%s RUNNING" % (file, str(func)), end='')
|
if not skip:
|
||||||
|
dbg("%s\n\t%s RUNNING" % (file, str(func)), end='')
|
||||||
t.setUpClass()
|
t.setUpClass()
|
||||||
else:
|
else:
|
||||||
dbg("\t%s RUNNING" % str(func), end='')
|
if not skip:
|
||||||
|
dbg("\t%s RUNNING" % str(func), end='')
|
||||||
|
|
||||||
sys.__stdout__.flush()
|
sys.__stdout__.flush()
|
||||||
|
|
||||||
# Run test (setUp/tearDown run automatically)
|
if not skip:
|
||||||
result = t()
|
# Run test (setUp/tearDown run automatically)
|
||||||
|
result = t()
|
||||||
|
|
||||||
# Tear down class only on last test
|
# Tear down class only on last test
|
||||||
if index == len(tlist) - 1:
|
if index == len(tlist) - 1:
|
||||||
t.tearDownClass()
|
t.tearDownClass()
|
||||||
|
|
||||||
|
if skip:
|
||||||
|
continue
|
||||||
except unittest.SkipTest as e:
|
except unittest.SkipTest as e:
|
||||||
result.skipped.append(t)
|
result.skipped.append(t)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -1256,9 +1271,13 @@ def pre_test(ctx, test, copied):
|
|||||||
pruned = []
|
pruned = []
|
||||||
|
|
||||||
for s in subtests:
|
for s in subtests:
|
||||||
# Allow test name both with and without the extension
|
file = s
|
||||||
if s in ctx.args.sub_tests or os.path.splitext(s)[0] in ctx.args.sub_tests:
|
# Handle <file>.<test function> format
|
||||||
pruned.append(s)
|
if '.' in s:
|
||||||
|
file = s.split('.')[0] + '.py'
|
||||||
|
|
||||||
|
if file == s:
|
||||||
|
pruned.append(file)
|
||||||
|
|
||||||
subtests = pruned
|
subtests = pruned
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user