def test_do_install_dir(self): installer = Installer.fromYaml(config, Cache(wd), "linux", "x86_64") action = { "install_dir": str(wd / "test_do_install_dir") } installer.do_install_dir(action) assert installer.symbols["INSTALL_DIR"] == str(wd / "test_do_install_dir")
def do_install(self, args): """ Install a package based on a descriptor YAML """ installdir = args.dir if installdir is None: installdir = "install" installdir = str(pathlib.Path(installdir).resolve()) installer = Installer.fromYaml(self.configpath(args), self.cache, get_platforms(), "x86" if args.x32 else get_arches()) installer.set_cache_only(args.cache_only) installer.set_recache(args.recache) if args.cache_local_file is not None: installer.set_from_local_file(args.cache_local_file) installer.set_cache_only(True) installer.install(args.package, args.version, args.base_url, installdir) if args.output is not None: logger.debug(f"Copying downloaded file to {args.output}") shutil.copy2(installer.get_installer_file(), args.output)
def test_do_cbdep(self): rmtree(wd, ignore_errors=True) wd.mkdir() assert config installer = Installer.fromYaml(config, Cache(wd), "linux", "x86_64") installer.do_cbdep({"cbdep": "analytics-jars", "version": "7.0.2-6512", "install_dir": str(wd/"test_do_cbdep")}) assert md5(open(wd/"test_do_cbdep"/"analytics-jars-7.0.2-6512"/"cbas-install-7.0.2.jar", "rb").read()).hexdigest() == "3436fda4756c9aed996a6ad2ed9ddb30"
def test___del__(self): installer = Installer.fromYaml(config, Cache(wd), "linux", "x86_64") tempdir = Path(installer.temp_dir) tempdir.mkdir(exist_ok=True) assert tempdir.exists() del installer assert tempdir.exists() == False
def test_wrong_platform_install(self): clear_wd() installer = Installer.fromYaml(config, Cache(wd), wrong_platform_package["platform"], "x86_64") with pytest.raises(SystemExit) as e: installer.install(wrong_platform_package["name"], wrong_platform_package["version"], wrong_platform_package.get("base_url", ""), wd/"install") assert e.type == SystemExit assert e.value.code == 1
def test_handle_fixed_dir(self): rmtree(wd, ignore_errors=True) wd.mkdir() installer = Installer.fromYaml(config, Cache(wd), "linux", "x86_64") installer.symbols["foo"] = "bar" installer.handle_fixed_dir({ "fixed_dir": str(wd/"missing") }) assert installer.handle_fixed_dir({ "fixed_dir": str(wd/"missing") }) == False (wd/"present").touch() assert installer.handle_fixed_dir({ "fixed_dir": str(wd/"present") }) == True
def test_set_from_local_file(self): installer = Installer.fromYaml(config, Cache(wd), "linux", "x86_64") Path("/tmp/bar").touch() installer.set_recache(True) installer.set_from_local_file("/tmp/bar") assert installer.recache == False with pytest.raises(SystemExit) as e: installer.set_from_local_file("/tmp/barbaz") assert e.type == SystemExit assert e.value.code == 1
def test_working_install(self, caplog, package): caplog.set_level(logging.DEBUG) clear_wd() logger.info(f"Testing package '{package}'") installer = Installer.fromYaml(config, Cache(wd), package["platform"], package.get("arch", plat.get_arches())) installer.install(package["name"], package["version"], package.get("base_url", ""), wd/"install") fn = wd / package["hash"][0:2] / package["hash"] / package.get("filename", f"{package['name']}-{package['version']}.tar.gz") logger.debug(f" Checking for downloaded file '{fn}'") assert fn.is_file() install_dir = Path(package.get("install_dir", f"{package['name']}-{package['version']}")) if not install_dir.is_absolute(): install_dir = wd / "install" / install_dir logger.debug(f" Checking for install dir '{install_dir}'") assert install_dir.is_dir() final_filename = package.get("final_file", None) if final_filename is not None: logger.debug(f" Checking for final file '{final_filename}'") assert (install_dir / final_filename).is_file() rmtree(install_dir, ignore_errors=True)
def do_install(self, args): """ Install a package based on a descriptor YAML """ yamlfile = args.config_file if yamlfile is None: if getattr(sys, 'frozen', False): # running in a bundle mydir = pathlib.Path(sys._MEIPASS) else: # running live mydir = pathlib.Path.home() yamlfile = str(mydir / "cbdep.config") installdir = args.dir if installdir is None: # QQQ installdir = "install" installdir = str(pathlib.Path(installdir).resolve()) installer = Installer.fromYaml(yamlfile, self.cache, args.platform) installer.install(args.package, args.version, args.x32, installdir)
def test_handle_set_env(self): installer = Installer.fromYaml(config, Cache(wd), "linux", "x86_64") installer.symbols["foo"] = "bar" os.environ["test_handle_set_env"] = "" installer.handle_set_env({ "test_handle_set_env": "xxx" }) assert os.environ["test_handle_set_env"] == "xxx"
def test_templatize(self): installer = Installer.fromYaml(config, Cache(wd), "linux", "x86_64") installer.symbols["ALPHA"] = "ABC" installer.symbols["NUMERIC"] = "123" assert installer.templatize("${ALPHA}-${NUMERIC}") == "ABC-123"
def test_get_installer_file(self): installer = Installer.fromYaml(config, Cache(wd), "linux", "x86_64") installer.installer_file = "foo" assert installer.get_installer_file() == "foo"
def test_recache(self): installer = Installer.fromYaml(config, Cache(wd), "linux", "x86_64") installer.set_recache(False) assert installer.recache == False installer.set_recache(True) assert installer.recache == True
def test_set_cache_only(self): installer = Installer.fromYaml(config, Cache(wd), "linux", "x86_64") installer.set_cache_only(False) assert installer.cache_only == False installer.set_cache_only(True) assert installer.cache_only == True
def test_copy(self): installer = Installer.fromYaml(config, Cache(wd), "linux", "x86_64") assert type(installer.copy()) == Installer