def testSetCpv(self): """ Test the clone via constructor. """ ebuilds = { "dev-libs/A-1": {"IUSE": "static-libs"}, "dev-libs/B-1": {"IUSE": "static-libs"}, } env_files = { "A" : ("USE=\"static-libs\"",) } package_env = ( "dev-libs/A A", ) eprefix = normalize_path(tempfile.mkdtemp()) playground = None try: user_config_dir = os.path.join(eprefix, USER_CONFIG_PATH) os.makedirs(user_config_dir) with io.open(os.path.join(user_config_dir, "package.env"), mode='w', encoding=_encodings['content']) as f: for line in package_env: f.write(line + "\n") env_dir = os.path.join(user_config_dir, "env") os.makedirs(env_dir) for k, v in env_files.items(): with io.open(os.path.join(env_dir, k), mode='w', encoding=_encodings['content']) as f: for line in v: f.write(line + "\n") playground = ResolverPlayground(eprefix=eprefix, ebuilds=ebuilds) settings = config(clone=playground.settings) result = playground.run(["=dev-libs/A-1"]) pkg, existing_node = result.depgraph._select_package( playground.eroot, Atom("=dev-libs/A-1")) settings.setcpv(pkg) self.assertTrue("static-libs" in settings["PORTAGE_USE"].split()) # Test bug #522362, where a USE=static-libs package.env # setting leaked from one setcpv call to the next. pkg, existing_node = result.depgraph._select_package( playground.eroot, Atom("=dev-libs/B-1")) settings.setcpv(pkg) self.assertTrue("static-libs" not in settings["PORTAGE_USE"].split()) finally: if playground is None: shutil.rmtree(eprefix) else: playground.cleanup()
def testClone(self): """ Test the clone via constructor. """ ebuilds = {"dev-libs/A-1": {}} playground = ResolverPlayground(ebuilds=ebuilds) try: settings = config(clone=playground.settings) result = playground.run(["=dev-libs/A-1"]) pkg, existing_node = result.depgraph._select_package(playground.eroot, "=dev-libs/A-1") settings.setcpv(pkg) # clone after setcpv tests deepcopy of LazyItemsDict settings2 = config(clone=settings) finally: playground.cleanup()
def testClone(self): """ Test the clone via constructor. """ ebuilds = { "dev-libs/A-1": {}, } playground = ResolverPlayground(ebuilds=ebuilds) try: settings = config(clone=playground.settings) result = playground.run(["=dev-libs/A-1"]) pkg, existing_node = result.depgraph._select_package( playground.eroot, Atom("=dev-libs/A-1")) settings.setcpv(pkg) # clone after setcpv tests deepcopy of LazyItemsDict settings2 = config(clone=settings) finally: playground.cleanup()
def testUseExpandIncremental(self): profiles = ( ( "base", { "eapi": ("5", ), "parent": ("..", ), "make.defaults": ( 'INPUT_DEVICES="keyboard mouse"', 'PYTHON_TARGETS="python2_7 python3_3"', ('USE_EXPAND="INPUT_DEVICES PYTHON_TARGETS ' 'VIDEO_CARDS"'), ), }, ), ( "default/linux", { "eapi": ("5", ), "make.defaults": ('VIDEO_CARDS="dummy fbdev v4l"', ) }, ), ( "default/linux/x86", { "eapi": ("5", ), "make.defaults": ( # Test negative incremental for bug 530222. 'PYTHON_TARGETS="-python3_3"', ), "parent": ("../../../base", "../../../mixins/python/3.4", ".."), }, ), ( "mixins/python/3.4", { "eapi": ("5", ), "make.defaults": ('PYTHON_TARGETS="python3_4"', ) }, ), ) # USE_EXPAND variable settings in make.conf will cause # profile settings for the same variable to be discarded # (non-incremental behavior). PMS does not govern make.conf # behavior. user_config = {"make.conf": ('VIDEO_CARDS="intel"', )} ebuilds = { "x11-base/xorg-drivers-1.15": { "EAPI": "5", "IUSE": ("input_devices_keyboard input_devices_mouse " "videos_cards_dummy video_cards_fbdev " "video_cards_v4l video_cards_intel"), }, "sys-apps/portage-2.2.14": { "EAPI": "5", "IUSE": ("python_targets_python2_7 " "python_targets_python3_3 python_targets_python3_4"), }, } package_expected_use = ( ( "x11-base/xorg-drivers-1.15", ( "input_devices_keyboard", "input_devices_mouse", "video_cards_intel", ), ), ( "sys-apps/portage-2.2.14", ("python_targets_python2_7", "python_targets_python3_4"), ), ) playground = ResolverPlayground(debug=False, ebuilds=ebuilds, user_config=user_config) try: repo_dir = playground.settings.repositories.get_location_for_name( "test_repo") profile_root = os.path.join(repo_dir, "profiles") for p, data in profiles: prof_path = os.path.join(profile_root, p) ensure_dirs(prof_path) for k, v in data.items(): with io.open( os.path.join(prof_path, k), mode="w", encoding=_encodings["repo.content"], ) as f: for line in v: f.write("%s\n" % line) # The config must be reloaded in order to account # for the above profile customizations. playground.reload_config() depgraph = playground.run(["=x11-base/xorg-drivers-1.15"]).depgraph settings = config(clone=playground.settings) for cpv, expected_use in package_expected_use: pkg, existing_node = depgraph._select_package( playground.eroot, Atom("=" + cpv)) settings.setcpv(pkg) expected = frozenset(expected_use) got = frozenset(settings["PORTAGE_USE"].split()) self.assertEqual(got, expected, "%s != %s" % (got, expected)) finally: playground.cleanup()
def testUseExpandIncremental(self): profiles = ( ( 'base', { "eapi": ("5",), "parent": ("..",), "make.defaults": ( "INPUT_DEVICES=\"keyboard mouse\"", "PYTHON_TARGETS=\"python2_7 python3_3\"", ("USE_EXPAND=\"INPUT_DEVICES PYTHON_TARGETS " "VIDEO_CARDS\""), ) } ), ( 'default/linux', { "eapi": ("5",), "make.defaults": ( "VIDEO_CARDS=\"dummy fbdev v4l\"", ) } ), ( 'default/linux/x86', { "eapi": ("5",), "make.defaults": ( # Test negative incremental for bug 530222. "PYTHON_TARGETS=\"-python3_3\"", ), "parent": ("../../../base", "../../../mixins/python/3.4", ".." ) } ), ( 'mixins/python/3.4', { "eapi": ("5",), "make.defaults": ( "PYTHON_TARGETS=\"python3_4\"", ) } ), ) # USE_EXPAND variable settings in make.conf will cause # profile settings for the same variable to be discarded # (non-incremental behavior). PMS does not govern make.conf # behavior. user_config = { "make.conf" : ( "VIDEO_CARDS=\"intel\"", ) } ebuilds = { "x11-base/xorg-drivers-1.15": { "EAPI": "5", "IUSE": ("input_devices_keyboard input_devices_mouse " "videos_cards_dummy video_cards_fbdev " "video_cards_v4l video_cards_intel") }, "sys-apps/portage-2.2.14": { "EAPI": "5", "IUSE": ("python_targets_python2_7 " "python_targets_python3_3 python_targets_python3_4") }, } package_expected_use = ( ("x11-base/xorg-drivers-1.15", ("input_devices_keyboard", "input_devices_mouse", "video_cards_intel",)), ("sys-apps/portage-2.2.14", ("python_targets_python2_7", "python_targets_python3_4")) ) playground = ResolverPlayground(debug=False, ebuilds=ebuilds, user_config=user_config) try: repo_dir = (playground.settings.repositories. get_location_for_name("test_repo")) profile_root = os.path.join(repo_dir, "profiles") for p, data in profiles: prof_path = os.path.join(profile_root, p) ensure_dirs(prof_path) for k, v in data.items(): with io.open(os.path.join(prof_path, k), mode="w", encoding=_encodings["repo.content"]) as f: for line in v: f.write("%s\n" % line) # The config must be reloaded in order to account # for the above profile customizations. playground.reload_config() depgraph = playground.run( ["=x11-base/xorg-drivers-1.15"]).depgraph settings = config(clone=playground.settings) for cpv, expected_use in package_expected_use: pkg, existing_node = depgraph._select_package( playground.eroot, Atom("=" + cpv)) settings.setcpv(pkg) expected = frozenset(expected_use) got = frozenset(settings["PORTAGE_USE"].split()) self.assertEqual(got, expected, "%s != %s" % (got, expected)) finally: playground.cleanup()