From 620aad2dfc9ad0b71b41f694532f7307b090608c Mon Sep 17 00:00:00 2001 From: Alexander Kozlovsky Date: Wed, 1 Dec 2021 12:27:28 +0100 Subject: [PATCH 1/2] Make --core and --gui-test-mode separate flags with all combinations possible --- src/run_tribler.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/run_tribler.py b/src/run_tribler.py index bdb5b321e8d..7663654ccb8 100644 --- a/src/run_tribler.py +++ b/src/run_tribler.py @@ -23,18 +23,12 @@ # pylint: disable=import-outside-toplevel, ungrouped-imports -class RunMode(Enum): - CORE_ONLY = auto() - GUI_TEST_MODE = auto() - - class RunTriblerArgsParser(argparse.ArgumentParser): def __init__(self, *args, **kwargs): kwargs['description'] = 'Run Tribler BitTorrent client' super().__init__(*args, **kwargs) - mode = self.add_mutually_exclusive_group() - mode.add_argument('--core', action='store_const', dest='mode', const=RunMode.CORE_ONLY) - mode.add_argument('--gui-test-mode', action='store_const', dest='mode', const=RunMode.GUI_TEST_MODE) + self.add_argument('--core', action="store_true") + self.add_argument('--gui-test-mode', action="store_true") def init_sentry_reporter(): @@ -83,11 +77,11 @@ def init_boot_logger(): api_key = os.environ.get('CORE_API_KEY') # Check whether we need to start the core or the user interface - if parsed_args.mode in (RunMode.CORE_ONLY, RunMode.GUI_TEST_MODE): + if parsed_args.core: from tribler_core.check_os import should_kill_other_tribler_instances should_kill_other_tribler_instances(root_state_dir) - logger.info('Running in "core" mode') + logger.info('Running Core' + ' in gui_test_mode' if parsed_args.gui_test_mode else '') load_logger_config('tribler-core', root_state_dir) # Check if we are already running a Tribler instance @@ -99,8 +93,7 @@ def init_boot_logger(): version_history = VersionHistory(root_state_dir) state_dir = version_history.code_version.directory try: - start_core.start_tribler_core(api_port, api_key, state_dir, - gui_test_mode=parsed_args.mode == RunMode.GUI_TEST_MODE) + start_core.start_tribler_core(api_port, api_key, state_dir, gui_test_mode=parsed_args.gui_test_mode) finally: logger.info('Remove lock file') process_checker.remove_lock_file() @@ -109,7 +102,7 @@ def init_boot_logger(): import tribler_gui from tribler_gui.utilities import get_translator - logger.info('Running in "normal" mode') + logger.info('Running GUI' + ' in gui_test_mode' if parsed_args.gui_test_mode else '') # Workaround for macOS Big Sur, see https://github.com/Tribler/tribler/issues/5728 if sys.platform == "darwin": From 8e14be389613a4b22eb0dea062c0aaea56b37cf8 Mon Sep 17 00:00:00 2001 From: Alexander Kozlovsky Date: Wed, 1 Dec 2021 14:53:38 +0100 Subject: [PATCH 2/2] Fix running GUI tests --- src/tribler-gui/tribler_gui/tests/test_gui.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tribler-gui/tribler_gui/tests/test_gui.py b/src/tribler-gui/tribler_gui/tests/test_gui.py index ae4cbbc2bfa..352104e1af8 100644 --- a/src/tribler-gui/tribler_gui/tests/test_gui.py +++ b/src/tribler-gui/tribler_gui/tests/test_gui.py @@ -42,7 +42,7 @@ def window(tmpdir_factory): QSettings(), root_state_dir, api_key=api_key, - core_args=[str(RUN_TRIBLER_PY.absolute()), '--gui-test-mode'], + core_args=[str(RUN_TRIBLER_PY.absolute()), '--core', '--gui-test-mode'], ) # pylint: disable=W0621 app.set_activation_window(window) QTest.qWaitForWindowExposed(window)