refactor: introduce lightmode in parallel test runner
This commit is contained in:
parent
c2dbae3ece
commit
ee864dac12
2 changed files with 13 additions and 5 deletions
|
|
@ -370,6 +370,7 @@ def run_tests(
|
|||
)
|
||||
@click.option("--use-orchestrator", is_flag=True, help="Use orchestrator to run parallel tests")
|
||||
@click.option("--dry-run", is_flag=True, default=False, help="Dont actually run tests")
|
||||
@click.option("--lightmode", is_flag=True, default=False, help="Skips all before test setup")
|
||||
@pass_context
|
||||
def run_parallel_tests(
|
||||
context: CliCtxObj,
|
||||
|
|
@ -379,6 +380,7 @@ def run_parallel_tests(
|
|||
with_coverage=False,
|
||||
use_orchestrator=False,
|
||||
dry_run=False,
|
||||
lightmode=False,
|
||||
):
|
||||
from traceback_with_variables import activate_by_import
|
||||
|
||||
|
|
@ -399,6 +401,7 @@ def run_parallel_tests(
|
|||
build_number=build_number,
|
||||
total_builds=total_builds,
|
||||
dry_run=dry_run,
|
||||
lightmode=lightmode,
|
||||
)
|
||||
mode = "Orchestrator" if use_orchestrator else "Parallel"
|
||||
banner = f"""
|
||||
|
|
|
|||
|
|
@ -29,12 +29,13 @@ TEST_WEIGHT_OVERRIDES = {
|
|||
|
||||
|
||||
class ParallelTestRunner:
|
||||
def __init__(self, app, site, build_number=1, total_builds=1, dry_run=False):
|
||||
def __init__(self, app, site, build_number=1, total_builds=1, dry_run=False, lightmode=False):
|
||||
self.app = app
|
||||
self.site = site
|
||||
self.build_number = frappe.utils.cint(build_number) or 1
|
||||
self.total_builds = frappe.utils.cint(total_builds)
|
||||
self.dry_run = dry_run
|
||||
self.lightmode = lightmode
|
||||
self.test_file_list = []
|
||||
self.total_test_weight = 0
|
||||
self.test_result = None
|
||||
|
|
@ -56,8 +57,9 @@ class ParallelTestRunner:
|
|||
toggle_test_mode(True)
|
||||
frappe.clear_cache()
|
||||
frappe.utils.scheduler.disable_scheduler()
|
||||
_decorate_all_methods_and_functions_with_type_checker()
|
||||
self.before_test_setup()
|
||||
if not self.lightmode:
|
||||
_decorate_all_methods_and_functions_with_type_checker()
|
||||
self.before_test_setup()
|
||||
|
||||
def before_test_setup(self):
|
||||
start_time = time.monotonic()
|
||||
|
|
@ -103,9 +105,12 @@ class ParallelTestRunner:
|
|||
frappe.set_user("Administrator")
|
||||
path, filename = file_info
|
||||
module = self.get_module(path, filename)
|
||||
from frappe.deprecation_dumpster import compat_preload_test_records_upfront
|
||||
|
||||
compat_preload_test_records_upfront([(module, path, filename)])
|
||||
if not self.lightmode:
|
||||
from frappe.deprecation_dumpster import compat_preload_test_records_upfront
|
||||
|
||||
compat_preload_test_records_upfront([(module, path, filename)])
|
||||
|
||||
test_suite = unittest.TestSuite()
|
||||
module_test_cases = unittest.TestLoader().loadTestsFromModule(module)
|
||||
test_suite.addTest(module_test_cases)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue