From be43cc25dbe983fc0ac688db2358bae2c3cbfe08 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 4 Jul 2022 20:37:20 +0530 Subject: [PATCH] Make a dedicated entry point in calibre-debug for running tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #1677 (One difference: using the new run_test() I see all the debug output …) --- src/calibre/debug.py | 7 +++++++ src/calibre/utils/run_tests.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/calibre/debug.py b/src/calibre/debug.py index ad0c665f81..0ae1cbdd37 100644 --- a/src/calibre/debug.py +++ b/src/calibre/debug.py @@ -102,6 +102,8 @@ Everything after the -- is passed to the script. 'Run a plugin that provides a command line interface. For example:\n' '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)')) parser.add_option('--diff', action='store_true', default=False, help=_( 'Run the calibre diff tool. For example:\n' 'calibre-debug --diff file1 file2')) @@ -313,6 +315,11 @@ def main(args=sys.argv): prints(_('No plugin named %s found')%opts.run_plugin) raise SystemExit(1) plugin.cli_main([plugin.name] + args[1:]) + elif opts.run_test: + from calibre.utils.run_tests import run_test + from calibre.constants import debug + debug(False) + run_test(opts.run_test) elif opts.diff: from calibre.gui2.tweak_book.diff.main import main main(['calibre-diff'] + args[1:]) diff --git a/src/calibre/utils/run_tests.py b/src/calibre/utils/run_tests.py index 14f2ed3a01..76f2b3eb43 100644 --- a/src/calibre/utils/run_tests.py +++ b/src/calibre/utils/run_tests.py @@ -301,7 +301,7 @@ def find_tests(which_tests=None, exclude_tests=None): def run_test(test_name, verbosity=4, buffer=False): - # calibre-debug -c "from calibre.utils.run_tests import *; import sys; run_test(sys.argv[-1])" some_test_name + # calibre-debug -t test_name tests = find_tests() tests = filter_tests_by_name(tests, test_name) if not tests._tests: