diff --git a/tests/large/test_baseinstaller.py b/tests/large/test_baseinstaller.py index d64b4551..cd07c21c 100644 --- a/tests/large/test_baseinstaller.py +++ b/tests/large/test_baseinstaller.py @@ -112,6 +112,32 @@ def test_default_install(self): self.child.sendline() self.wait_and_close() + def test_default_path_install(self): + """Install base installer from scratch test case in default path""" + self.child = spawn_process(self.command('{} base base-framework -f'.format(UMAKE))) + self.expect_and_no_warn(r"\[I Accept.*\]") # ensure we have a license question + self.child.sendline("a") + self.expect_and_no_warn("Installation done", timeout=self.TIMEOUT_INSTALL_PROGRESS) + self.wait_and_close() + + # we have an installed launcher, added to the launcher + self.assertTrue(self.launcher_exists_and_is_pinned(self.desktop_filename)) + self.assert_exec_exists() + self.assert_icon_exists() + self.assert_exec_link_exists() + + # launch it, send SIGTERM and check that it exits fine + proc = subprocess.Popen(self.command_as_list(self.exec_path), stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL) + self.check_and_kill_process([self.JAVAEXEC, self.installed_path], wait_before=self.TIMEOUT_START) + self.assertEqual(proc.wait(self.TIMEOUT_STOP), 143) + + # ensure that it's detected as installed: + self.child = spawn_process(self.command('{} base base-framework'.format(UMAKE))) + self.expect_and_no_warn(r"Base Framework is already installed.*\[.*\] ") + self.child.sendline() + self.wait_and_close() + def test_no_license_accept(self): """We don't accept the license (default)""" self.child = spawn_process(self.command('{} base base-framework'.format(UMAKE))) diff --git a/tests/small/test_frameworks_loader.py b/tests/small/test_frameworks_loader.py index cfb853d2..b87e3ccf 100644 --- a/tests/small/test_frameworks_loader.py +++ b/tests/small/test_frameworks_loader.py @@ -296,13 +296,15 @@ def test_parse_category_and_framework_run_correct_framework(self): args.destdir = None args.framework = "framework-b" args.accept_license = False + args.force = False args.remove = False with patch.object(self.CategoryHandler.categories[args.category].frameworks["framework-b"], "setup")\ as setup_call: self.CategoryHandler.categories[args.category].run_for(args) - self.assertTrue(setup_call.called) - self.assertEqual(setup_call.call_args, call(install_path=None, auto_accept_license=False)) + self.assertEqual(setup_call.call_args, call(force_defaults=False, + install_path=None, + auto_accept_license=False)) def test_parse_no_framework_run_default_for_category(self): """Parsing category will run default framework""" @@ -311,12 +313,15 @@ def test_parse_no_framework_run_default_for_category(self): args.destdir = None args.framework = None args.accept_license = False + args.force = False args.remove = False with patch.object(self.CategoryHandler.categories[args.category].frameworks["framework-a"], "setup")\ as setup_call: self.CategoryHandler.categories[args.category].run_for(args) self.assertTrue(setup_call.called) - self.assertEqual(setup_call.call_args, call(install_path=None, auto_accept_license=False)) + self.assertEqual(setup_call.call_args, call(force_defaults=False, + install_path=None, + auto_accept_license=False)) def test_parse_category_and_framework_run_correct_remove_framework(self): """Parsing category and framework with --remove run remove on right category and framework""" @@ -376,6 +381,7 @@ def test_parse_category_and_framework_cannot_install_not_installable_but_install args.destdir = None args.framework = "framework-r-installed-not-installable" args.accept_license = False + args.force = False args.remove = False self.assertRaises(BaseException, self.CategoryHandler.categories[args.category].run_for, args) @@ -401,13 +407,16 @@ def test_parse_category_and_framework_get_accept_license_arg(self): args.destdir = None args.framework = "framework-b" args.accept_license = True + args.force = False args.remove = False with patch.object(self.CategoryHandler.categories[args.category].frameworks["framework-b"], "setup")\ as setup_call: self.CategoryHandler.categories[args.category].run_for(args) self.assertTrue(setup_call.called) - self.assertEqual(setup_call.call_args, call(install_path=None, auto_accept_license=True)) + self.assertEqual(setup_call.call_args, call(force_defaults=False, + install_path=None, + auto_accept_license=True)) def test_uninstantiable_framework(self): """A uninstantiable framework isn't loaded""" diff --git a/umake/frameworks/__init__.py b/umake/frameworks/__init__.py index 4d825406..29ece6cc 100644 --- a/umake/frameworks/__init__.py +++ b/umake/frameworks/__init__.py @@ -302,7 +302,8 @@ def install_framework_parser(self, parser): help=_("Remove framework if installed")) this_framework_parser.add_argument('--dry-run', dest="dry_run", action="store_true", help=_("Fetch only the url, then exit.")) - + this_framework_parser.add_argument('-f', '--force', action="store_true", + help=_("Force install with defaults")) if self.expect_license: this_framework_parser.add_argument('--accept-license', dest="accept_license", action="store_true", help=_("Accept license without prompting")) @@ -329,7 +330,8 @@ def run_for(self, args): dry_run = True self.setup(install_path=install_path, auto_accept_license=auto_accept_license, - dry_run=dry_run) + dry_run=dry_run, + force_defaults=args.force) class MainCategory(BaseCategory): diff --git a/umake/frameworks/baseinstaller.py b/umake/frameworks/baseinstaller.py index fd00199a..4cfde173 100644 --- a/umake/frameworks/baseinstaller.py +++ b/umake/frameworks/baseinstaller.py @@ -101,7 +101,8 @@ def is_installed(self): logger.debug("{} is installed".format(self.name)) return True - def setup(self, install_path=None, auto_accept_license=False, dry_run=False): + def setup(self, install_path=None, auto_accept_license=False, dry_run=False, force_defaults=False): + self.force_defaults = force_defaults self.arg_install_path = install_path self.auto_accept_license = auto_accept_license self.dry_run = dry_run @@ -110,7 +111,7 @@ def setup(self, install_path=None, auto_accept_license=False, dry_run=False): # first step, check if installed or dry_run if self.dry_run: self.download_provider_page() - elif self.is_installed: + elif self.is_installed and not self.force_defaults: UI.display(YesNo("{} is already installed on your system, do you want to reinstall " "it anyway?".format(self.name), self.reinstall, UI.return_main_screen)) else: @@ -162,6 +163,10 @@ def confirm_path(self, path_dir=""): """Confirm path dir""" if not path_dir: + if self.force_defaults: + path_dir = self.install_path + self.set_installdir_to_clean() + return logger.debug("No installation path provided. Requesting one.") UI.display(InputText("Choose installation path:", self.confirm_path, self.install_path)) return