def find_tests(which_tests=None): ans = [] a = ans.append def ok(x): return not which_tests or x in which_tests if ok('build'): from calibre.test_build import find_tests a(find_tests()) if ok('srv'): from calibre.srv.tests.main import find_tests a(find_tests()) if ok('db'): from calibre.db.tests.main import find_tests a(find_tests()) if ok('polish'): from calibre.ebooks.oeb.polish.tests.main import find_tests a(find_tests()) if ok('opf'): from calibre.ebooks.metadata.opf2 import suite a(suite()) from calibre.ebooks.metadata.opf3_test import suite a(suite()) if ok('css'): from tinycss.tests.main import find_tests a(find_tests()) from calibre.ebooks.oeb.normalize_css import test_normalization a(test_normalization(return_tests=True)) from calibre.ebooks.css_transform_rules import test a(test(return_tests=True)) from css_selectors.tests import find_tests a(find_tests()) if ok('docx'): from calibre.ebooks.docx.fields import test_parse_fields a(test_parse_fields(return_tests=True)) from calibre.ebooks.docx.writer.utils import test_convert_color a(test_convert_color(return_tests=True)) if ok('cfi'): from calibre.ebooks.epub.cfi.tests import find_tests a(find_tests()) if ok('matcher'): from calibre.utils.matcher import test a(test(return_tests=True)) if ok('icu'): from calibre.utils.icu_test import find_tests a(find_tests()) if ok('smartypants'): from calibre.utils.smartypants import run_tests a(run_tests(return_tests=True)) if ok('misc'): from calibre.ebooks.metadata.tag_mapper import find_tests a(find_tests()) from calibre.utils.shared_file import find_tests a(find_tests()) tests = unittest.TestSuite(ans) return tests
def run(self, opts): from calibre.utils.run_tests import run_cli, filter_tests_by_name, remove_tests_by_name tests = find_tests(which_tests=frozenset(opts.test_module), exclude_tests=frozenset(opts.exclude_test_module)) if opts.test_name: tests = filter_tests_by_name(tests, *opts.test_name) if opts.exclude_test_name: tests = remove_tests_by_name(tests, *opts.exclude_test_name) run_cli(tests, verbosity=opts.test_verbosity)
def find_tests(which_tests=None): ans = [] a = ans.append def ok(x): return not which_tests or x in which_tests if ok('build'): from calibre.test_build import find_tests a(find_tests()) if ok('polish'): from calibre.ebooks.oeb.polish.tests.main import find_tests a(find_tests()) if ok('opf'): from calibre.ebooks.metadata.opf2 import suite a(suite()) from calibre.ebooks.metadata.opf3_test import suite a(suite()) if ok('css'): from tinycss.tests.main import find_tests a(find_tests()) from calibre.ebooks.oeb.normalize_css import test_normalization a(test_normalization(return_tests=True)) from calibre.ebooks.css_transform_rules import test a(test(return_tests=True)) from css_selectors.tests import find_tests a(find_tests()) if ok('docx'): from calibre.ebooks.docx.fields import test_parse_fields a(test_parse_fields(return_tests=True)) from calibre.ebooks.docx.writer.utils import test_convert_color a(test_convert_color(return_tests=True)) if ok('cfi'): from calibre.ebooks.epub.cfi.tests import find_tests a(find_tests()) a(test(return_tests=True)) if ok('ebooks'): from calibre.ebooks.metadata.rtf import find_tests a(find_tests()) if ok('misc'): from calibre.ebooks.metadata.tag_mapper import find_tests a(find_tests()) from calibre.ebooks.metadata.author_mapper import find_tests a(find_tests()) # a(unittest.defaultTestLoader.loadTestsFromTestCase(TestImports)) tests = unittest.TestSuite(ans) return tests
def run(self, opts): if opts.under_sanitize and 'CALIBRE_EXECED_UNDER_SANITIZE' not in os.environ: if 'libasan' not in os.environ.get('LD_PRELOAD', ''): os.environ['LD_PRELOAD'] = os.path.abspath(subprocess.check_output('gcc -print-file-name=libasan.so'.split()).decode('utf-8').strip()) os.environ['CALIBRE_EXECED_UNDER_SANITIZE'] = '1' os.environ['ASAN_OPTIONS'] = 'detect_leaks=0' os.environ['PYCRYPTODOME_DISABLE_DEEPBIND'] = '1' # https://github.com/Legrandin/pycryptodome/issues/558 self.info(f'Re-execing with LD_PRELOAD={os.environ["LD_PRELOAD"]}') sys.stdout.flush() os.execl('setup.py', *sys.argv) from calibre.utils.run_tests import ( filter_tests_by_name, remove_tests_by_name, run_cli ) tests = find_tests(which_tests=frozenset(opts.test_module), exclude_tests=frozenset(opts.exclude_test_module)) if opts.test_name: tests = filter_tests_by_name(tests, *opts.test_name) if opts.exclude_test_name: tests = remove_tests_by_name(tests, *opts.exclude_test_name) run_cli(tests, verbosity=opts.test_verbosity)
def run(self, opts): if opts.under_sanitize and 'libasan' not in os.environ.get( 'LD_PRELOAD', ''): os.environ['LD_PRELOAD'] = os.path.abspath( subprocess.check_output( 'gcc -print-file-name=libasan.so'.split()).decode( 'utf-8').strip()) os.environ['ASAN_OPTIONS'] = 'detect_leaks=0' self.info(f'Re-execing with LD_PRELOAD={os.environ["LD_PRELOAD"]}') sys.stdout.flush() os.execl('setup.py', *sys.argv) from calibre.utils.run_tests import (filter_tests_by_name, remove_tests_by_name, run_cli) tests = find_tests(which_tests=frozenset(opts.test_module), exclude_tests=frozenset(opts.exclude_test_module)) if opts.test_name: tests = filter_tests_by_name(tests, *opts.test_name) if opts.exclude_test_name: tests = remove_tests_by_name(tests, *opts.exclude_test_name) run_cli(tests, verbosity=opts.test_verbosity)
def find_tests(which_tests=None, exclude_tests=None): ans = [] a = ans.append def ok(x): return (not which_tests or x in which_tests) and (not exclude_tests or x not in exclude_tests) if ok('build'): from calibre.test_build import find_tests a(find_tests()) if ok('srv'): from calibre.srv.tests.main import find_tests a(find_tests()) if ok('db'): from calibre.db.tests.main import find_tests a(find_tests()) if ok('polish'): from calibre.ebooks.oeb.polish.tests.main import find_tests a(find_tests()) if ok('opf'): from calibre.ebooks.metadata.opf2 import suite a(suite()) from calibre.ebooks.metadata.opf3_test import suite a(suite()) if ok('css'): from tinycss.tests.main import find_tests a(find_tests()) from calibre.ebooks.oeb.normalize_css import test_normalization a(test_normalization(return_tests=True)) from calibre.ebooks.css_transform_rules import test a(test(return_tests=True)) from css_selectors.tests import find_tests a(find_tests()) if ok('docx'): from calibre.ebooks.docx.fields import test_parse_fields a(test_parse_fields(return_tests=True)) from calibre.ebooks.docx.writer.utils import test_convert_color a(test_convert_color(return_tests=True)) if ok('cfi'): from calibre.ebooks.epub.cfi.tests import find_tests a(find_tests()) if ok('matcher'): from calibre.utils.matcher import test a(test(return_tests=True)) if ok('icu'): from calibre.utils.icu_test import find_tests a(find_tests()) if ok('smartypants'): from calibre.utils.smartypants import run_tests a(run_tests(return_tests=True)) if ok('ebooks'): from calibre.ebooks.metadata.rtf import find_tests a(find_tests()) from calibre.ebooks.metadata.html import find_tests a(find_tests()) from calibre.ebooks.pdf.test_html_writer import find_tests a(find_tests()) from calibre.utils.xml_parse import find_tests a(find_tests()) from calibre.gui2.viewer.annotations import find_tests a(find_tests()) if ok('misc'): from calibre.ebooks.metadata.tag_mapper import find_tests a(find_tests()) from calibre.ebooks.metadata.author_mapper import find_tests a(find_tests()) from calibre.utils.shared_file import find_tests a(find_tests()) from calibre.utils.test_lock import find_tests a(find_tests()) from calibre.utils.search_query_parser_test import find_tests a(find_tests()) from calibre.utils.html2text import find_tests a(find_tests()) from calibre.library.comments import find_tests a(find_tests()) from calibre.ebooks.compression.palmdoc import find_tests a(find_tests()) from calibre.gui2.viewer.convert_book import find_tests a(find_tests()) from calibre.utils.hyphenation.test_hyphenation import find_tests a(find_tests()) if iswindows: from calibre.utils.windows.wintest import find_tests a(find_tests()) a(unittest.defaultTestLoader.loadTestsFromTestCase(TestImports)) if ok('dbcli'): from calibre.db.cli.tests import find_tests a(find_tests()) tests = unittest.TestSuite(ans) return tests
def find_tests(which_tests=None): ans = [] a = ans.append def ok(x): return not which_tests or x in which_tests if ok('build'): from calibre.test_build import find_tests a(find_tests()) if ok('srv'): from calibre.srv.tests.main import find_tests a(find_tests()) if ok('db'): from calibre.db.tests.main import find_tests a(find_tests()) if ok('polish'): from calibre.ebooks.oeb.polish.tests.main import find_tests a(find_tests()) if ok('opf'): from calibre.ebooks.metadata.opf2 import suite a(suite()) from calibre.ebooks.metadata.opf3_test import suite a(suite()) if ok('css'): from tinycss.tests.main import find_tests a(find_tests()) from calibre.ebooks.oeb.normalize_css import test_normalization a(test_normalization(return_tests=True)) from calibre.ebooks.css_transform_rules import test a(test(return_tests=True)) from css_selectors.tests import find_tests a(find_tests()) if ok('docx'): from calibre.ebooks.docx.fields import test_parse_fields a(test_parse_fields(return_tests=True)) from calibre.ebooks.docx.writer.utils import test_convert_color a(test_convert_color(return_tests=True)) if ok('cfi'): from calibre.ebooks.epub.cfi.tests import find_tests a(find_tests()) if ok('matcher'): from calibre.utils.matcher import test a(test(return_tests=True)) if ok('icu'): from calibre.utils.icu_test import find_tests a(find_tests()) if ok('smartypants'): from calibre.utils.smartypants import run_tests a(run_tests(return_tests=True)) if ok('ebooks'): from calibre.ebooks.metadata.rtf import find_tests a(find_tests()) if ok('misc'): from calibre.ebooks.metadata.tag_mapper import find_tests a(find_tests()) from calibre.ebooks.metadata.author_mapper import find_tests a(find_tests()) from calibre.utils.shared_file import find_tests a(find_tests()) from calibre.utils.test_lock import find_tests a(find_tests()) from calibre.utils.search_query_parser_test import find_tests a(find_tests()) from calibre.utils.html2text import find_tests a(find_tests()) from calibre.library.comments import find_tests a(find_tests()) from calibre.ebooks.compression.palmdoc import find_tests a(find_tests()) a(unittest.defaultTestLoader.loadTestsFromTestCase(TestImports)) if ok('dbcli'): from calibre.db.cli.tests import find_tests a(find_tests()) tests = unittest.TestSuite(ans) return tests
def run(self, opts): from calibre.utils.run_tests import run_cli, filter_tests_by_name tests = find_tests(which_tests=frozenset(opts.test_module)) if opts.test_name: tests = filter_tests_by_name(tests, *opts.test_name) run_cli(tests, verbosity=opts.test_verbosity)