diff --git a/src/calibre/debug.py b/src/calibre/debug.py index 12cfec619c..dab247f3fc 100644 --- a/src/calibre/debug.py +++ b/src/calibre/debug.py @@ -103,7 +103,10 @@ Everything after the -- is passed to the script. 'calibre-debug -r "Plugin name" -- file1 --option1\n' 'Everything after the -- will be passed to the plugin as arguments.')) parser.add_option('-t', '--run-test', help=_( - 'Run the named test(s)')) + 'Run the named test(s). Use the special value "all" to run all tests.' + ' If the test name starts with a period it is assumed to be a module name.' + ' If the test name starts with @ it is assumed to be a category name.' + )) parser.add_option('--diff', action='store_true', default=False, help=_( 'Run the calibre diff tool. For example:\n' 'calibre-debug --diff file1 file2')) diff --git a/src/calibre/utils/run_tests.py b/src/calibre/utils/run_tests.py index 76f2b3eb43..508e38fe09 100644 --- a/src/calibre/utils/run_tests.py +++ b/src/calibre/utils/run_tests.py @@ -302,8 +302,17 @@ def find_tests(which_tests=None, exclude_tests=None): def run_test(test_name, verbosity=4, buffer=False): # calibre-debug -t test_name - tests = find_tests() - tests = filter_tests_by_name(tests, test_name) + which_tests = None + if test_name.startswith('@'): + which_tests = test_name[1:], + tests = find_tests(which_tests) + if test_name != 'all': + if test_name.startswith('.'): + tests = filter_tests_by_module(tests, test_name[1:]) + elif test_name.startswith('@'): + pass + else: + tests = filter_tests_by_name(tests, test_name) if not tests._tests: raise SystemExit(f'No test named {test_name} found') run_cli(tests, verbosity, buffer=buffer)