From f9d4890b9dd13cc6c4ac3426e2e4beca0da79705 Mon Sep 17 00:00:00 2001 From: fuzzyray Date: Mon, 15 Nov 2010 19:07:39 +0000 Subject: [PATCH] Merge genscripts revision 481 svn path=/trunk/gentoolkit/; revision=847 --- pym/gentoolkit/equery/depends.py | 8 +++- pym/gentoolkit/equery/has.py | 9 +--- pym/gentoolkit/package.py | 4 +- pym/gentoolkit/test/eclean/distsupport.py | 2 +- pym/gentoolkit/test/eclean/test_search.py | 54 ++++++++++++++++------- pym/gentoolkit/test/equery/test_init.py | 2 +- setup.py | 20 ++++++--- 7 files changed, 65 insertions(+), 34 deletions(-) diff --git a/pym/gentoolkit/equery/depends.py b/pym/gentoolkit/equery/depends.py index cab23d1..9e5d8de 100644 --- a/pym/gentoolkit/equery/depends.py +++ b/pym/gentoolkit/equery/depends.py @@ -40,6 +40,8 @@ QUERY_OPTS = { class DependPrinter(object): """Output L{gentoolkit.dependencies.Dependencies} objects.""" def __init__(self, verbose=True): + self.verbose = verbose + if verbose: self.print_fn = self.print_verbose else: @@ -62,7 +64,7 @@ class DependPrinter(object): def print_quiet(indent, cpv, use_conditional, depatom): """Quietly prints a subset set of dep strings.""" - pp.uprint(indent + pp.cpv(cpv)) + pp.uprint(indent + cpv) def format_depend(self, dep, dep_is_displayed): """Format a dependency for printing. @@ -71,6 +73,10 @@ class DependPrinter(object): @param dep: the dependency to display """ + # Don't print blank lines + if dep_is_displayed and not self.verbose: + return + depth = getattr(dep, 'depth', 0) indent = " " * depth mdep = dep.matching_dep diff --git a/pym/gentoolkit/equery/has.py b/pym/gentoolkit/equery/has.py index e40a766..9ea5f77 100644 --- a/pym/gentoolkit/equery/has.py +++ b/pym/gentoolkit/equery/has.py @@ -40,9 +40,6 @@ QUERY_OPTS = { "env_var": None } -AUXDBKEYS = set(auxdbkeys) -AUXDBKEYS.difference_update(['UNUSED_0{0}'.format(x) for x in range(6)]) - # ========= # Functions # ========= @@ -70,11 +67,7 @@ def print_help(with_description=True): (" TMPL", "a format template using (see man page):") ))) - print(" " * 24, ', '.join(pp.emph(x) for x in FORMAT_TMPL_VARS)) - print() - print(pp.command("env_var")) - print("", ', '.join(pp.emph(x) for x in AUXDBKEYS)) - print(" other env_vars provided by eclasses may be available") +# print(" " * 24, ', '.join(pp.emph(x) for x in FORMAT_TMPL_VARS)) def query_in_env(query, env_var, pkg): diff --git a/pym/gentoolkit/package.py b/pym/gentoolkit/package.py index 70f05d6..a4031a3 100644 --- a/pym/gentoolkit/package.py +++ b/pym/gentoolkit/package.py @@ -143,7 +143,7 @@ class Package(CPV): def environment(self, envvars, prefer_vdb=True, fallback=True): """Returns one or more of the predefined environment variables. - Available envvars are: + Some available envvars are: ---------------------- BINPKGMD5 COUNTER FEATURES LICENSE SRC_URI CATEGORY CXXFLAGS HOMEPAGE PDEPEND USE @@ -319,7 +319,7 @@ class Package(CPV): def use_status(self): """Returns the USE flags active for installation.""" - iuse, final_flags = get_flags(slef.cpv, final_setting=True) + iuse, final_flags = get_flags(self.cpv, final_setting=True) return final_flags def parsed_contents(self): diff --git a/pym/gentoolkit/test/eclean/distsupport.py b/pym/gentoolkit/test/eclean/distsupport.py index ab81f7f..3a4b011 100644 --- a/pym/gentoolkit/test/eclean/distsupport.py +++ b/pym/gentoolkit/test/eclean/distsupport.py @@ -343,7 +343,7 @@ Exclude= {'packages': { def get_props(cpvs): props = {} for cpv in cpvs: - props[cpv] = PROPS[cpv] + props[cpv] = PROPS[cpv].copy() return props class Dbapi(object): diff --git a/pym/gentoolkit/test/eclean/test_search.py b/pym/gentoolkit/test/eclean/test_search.py index 28bd7c6..328c543 100644 --- a/pym/gentoolkit/test/eclean/test_search.py +++ b/pym/gentoolkit/test/eclean/test_search.py @@ -267,7 +267,7 @@ class TestFetchRestricted(unittest.TestCase): cpvs.append('app-portage/deprecated-pkg-1.0.0') pkgs, deprecated = self.target_class._fetch_restricted(None, cpvs) self.record_results('fetch_restricted2', pkgs, deprecated) - self.test_results("test_fetch_restricted") + self.check_results("test_fetch_restricted") def test_unrestricted(self): @@ -279,16 +279,20 @@ class TestFetchRestricted(unittest.TestCase): cpvs.append('app-portage/deprecated-pkg-1.0.0') pkgs, deprecated = self.target_class._unrestricted(None, cpvs) self.record_results('unrestricted2', pkgs, deprecated) - self.test_results("test_unrestricted") + self.check_results("test_unrestricted") - def test_results(self, test_name): + def check_results(self, test_name): print("\nChecking results for %s,............" %test_name) for key in sorted(self.results): testdata = self.testdata[key] results = self.results[key] for item in sorted(testdata): - #print("comparing %s, %s" %(key, item)) + if sorted(results[item]) == sorted(testdata[item]): + test = "OK" + else: + test = "FAILED" + print("comparing %s, %s" %(key, item), test) self.failUnlessEqual(sorted(testdata[item]), sorted(results[item]), "\n%s: %s %s data does not match\nresult=" %(test_name, key, item) +\ str(results[item]) + "\ntestdata=" + str(testdata[item])) @@ -301,6 +305,10 @@ class TestFetchRestricted(unittest.TestCase): } + def tearDown(self): + del self.portdb, self.vardb + + class TestNonDestructive(unittest.TestCase): """Tests eclean.search.DistfilesSearch._non_destructive and _destructive functions, with addition useage tests of fetch_restricted() and _unrestricted() @@ -311,13 +319,12 @@ class TestNonDestructive(unittest.TestCase): props=PROPS, cp_list=[], name="FAKE VARDB") self.portdb = Dbapi(cp_all=[], cpv_all=CPVS[:4], props=get_props(CPVS[:4]), cp_list=[], name="FAKE PORTDB") + print(self.portdb) # set a fetch restricted pkg self.portdb._props[CPVS[0]]["RESTRICT"] = 'fetch' self.callback_data = [] - self.output = self.output = OutputSimulator(self.callback) + self.output = OutputSimulator(self.callback) self.target_class = DistfilesSearch(self.output.einfo, self.portdb, self.vardb) - self.target_class.portdb = self.portdb - self.target_class.portdb = self.portdb search.exclDictExpand = self.exclDictExpand self.exclude = parseExcludeFile(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'distfiles.exclude'), self.output.einfo) #print(self.callback_data) @@ -346,8 +353,8 @@ class TestNonDestructive(unittest.TestCase): 'deprecated': { }, 'pkgs': { - 'sys-auth/consolekit-0.4.1': 'http://www.freedesktop.org/software/ConsoleKit/dist/ConsoleKit-0.4.1.tar.bz2', 'sys-apps/devicekit-power-014': 'http://hal.freedesktop.org/releases/DeviceKit-power-014.tar.gz', + 'sys-auth/consolekit-0.4.1': 'http://www.freedesktop.org/software/ConsoleKit/dist/ConsoleKit-0.4.1.tar.bz2', 'media-libs/sdl-pango-0.1.2': 'mirror://sourceforge/sdlpango/SDL_Pango-0.1.2.tar.gz http://zarb.org/~gc/t/SDL_Pango-0.1.2-API-adds.patch' }, 'output': [ @@ -485,15 +492,20 @@ class TestNonDestructive(unittest.TestCase): fetch_restricted=False, pkgs_=None) self.record_results('non_destructive1', pkgs, deprecated) + pkgs = None + deprecated = None self.callback_data = [] self.vardb._cpv_all=CPVS[:3] self.vardb._props=get_props(CPVS[:3]) self.portdb._cpv_all=CPVS[:] self.portdb._props=get_props(CPVS) + self.target_class.installed_cpvs = None pkgs, deprecated = self.target_class._non_destructive(destructive=True, fetch_restricted=True, pkgs_=None) self.record_results('non_destructive2', pkgs, deprecated) + pkgs = None + deprecated = None self.callback_data = [] self.vardb._cpv_all=CPVS[:2] self.vardb._props=get_props(CPVS[:2]) @@ -505,19 +517,27 @@ class TestNonDestructive(unittest.TestCase): pkgs, deprecated = self.target_class._non_destructive(destructive=True, fetch_restricted=True, pkgs_=pkgs) self.record_results('non_destructive3', pkgs, deprecated) - self.test_results("test_non_destructive") + self.check_results("test_non_destructive") - def test_results(self, test_name): + def check_results(self, test_name): print("\nChecking results for %s,............" %test_name) for key in sorted(self.results): testdata = self.testdata[key] results = self.results[key] for item in sorted(testdata): - #print("comparing %s, %s" %(key, item)) + if sorted(results[item]) == sorted(testdata[item]): + test = "OK" + else: + test = "FAILED" + print("comparing %s, %s..." %(key, item), test) + if test == "FAILED": + print("", sorted(results[item]), "\n", sorted(testdata[item])) self.failUnlessEqual(sorted(testdata[item]), sorted(results[item]), - "\n%s: %s %s data does not match\nresult=" %(test_name, key, item) +\ - str(results[item]) + "\ntestdata=" + str(testdata[item])) + "\n%s: %s, %s data does not match\n" + %(test_name, key, item) + \ + "result=" + str(results[item]) + "\ntestdata=" + str(testdata[item]) + ) def record_results(self, test, pkgs, deprecated): @@ -563,7 +583,7 @@ class TestNonDestructive(unittest.TestCase): pkgs, deprecated = self.target_class._destructive(package_names=False, exclude=self.exclude, pkgs_=None, installed_included=False ) self.record_results('destructive4', pkgs, deprecated) - self.test_results("test_destructive") + self.check_results("test_destructive") self.callback_data = [] self.vardb._cpv_all=CPVS[:3] @@ -575,7 +595,11 @@ class TestNonDestructive(unittest.TestCase): pkgs, deprecated = self.target_class._destructive(package_names=False, exclude=self.exclude, pkgs_=None, installed_included=False ) self.record_results('destructive5', pkgs, deprecated) - self.test_results("test_destructive") + self.check_results("test_destructive") + + + def tearDown(self): + del self.portdb, self.vardb class TestRemoveProtected(unittest.TestCase): diff --git a/pym/gentoolkit/test/equery/test_init.py b/pym/gentoolkit/test/equery/test_init.py index 31da635..996cade 100644 --- a/pym/gentoolkit/test/equery/test_init.py +++ b/pym/gentoolkit/test/equery/test_init.py @@ -17,7 +17,7 @@ class TestEqueryInit(unittest.TestCase): def test_expand_module_name(self): # Test that module names are properly expanded name_map = { - 'a': 'has', + #'a': 'has', 'b': 'belongs', 'c': 'changes', 'k': 'check', diff --git a/setup.py b/setup.py index b643914..55cb3bd 100755 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ cwd = os.getcwd() try: from portage.const import EPREFIX except ImportError: - EPREFIX='' + EPREFIX='/' # Bash files that need `VERSION=""` subbed, relative to this dir: @@ -95,13 +95,20 @@ def load_test(): return test - packages = [ str('.'.join(root.split(os.sep)[1:])) for root, dirs, files in os.walk('pym/gentoolkit') if '__init__.py' in files ] +test_data = { + 'gentoolkit': [ + 'test/eclean/Packages', + 'test/eclean/testdistfiles.tar.gz', + 'test/eclean/distfiles.exclude' + ] +} + core.setup( name='gentoolkit', version=__version__, @@ -115,12 +122,13 @@ core.setup( % __version__, package_dir={'': 'pym'}, packages=packages, + package_data = test_data, scripts=(glob('bin/*')), data_files=( - (EPREFIX + '/etc/env.d', ['data/99gentoolkit-env']), - (EPREFIX + '/etc/revdep-rebuild', ['data/revdep-rebuild/99revdep-rebuild']), - (EPREFIX + '/etc/eclean', glob('data/eclean/*')), - (EPREFIX + '/usr/share/man/man1', glob('man/*')) + (os.path.join(EPREFIX, 'etc/env.d'), ['data/99gentoolkit-env']), + (os.path.join(EPREFIX, 'etc/revdep-rebuild'), ['data/revdep-rebuild/99revdep-rebuild']), + (os.path.join(EPREFIX, 'etc/eclean'), glob('data/eclean/*')), + (os.path.join(EPREFIX, 'usr/share/man/man1'), glob('man/*')), ), cmdclass={ 'test': load_test(), -- 2.26.2