[gentoo-commits] proj/layman:gsoc2014 commit in: layman/tests/testfiles/, layman/tests/
commit: ed2a37d75c74798b13f103f4ba8ead414d43f306 Author: Devan Franchini twitch153 AT gentoo DOT org AuthorDate: Sun Aug 10 22:35:22 2014 + Commit: Devan Franchini twitch153 AT gentoo DOT org CommitDate: Fri Aug 15 21:42:41 2014 + URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=ed2a37d7 Adds Squashfs overlay external tests --- layman/tests/external.py| 168 ++-- layman/tests/testfiles/layman-test.squashfs | Bin 0 - 4096 bytes 2 files changed, 107 insertions(+), 61 deletions(-) diff --git a/layman/tests/external.py b/layman/tests/external.py index b773fda..21ad029 100755 --- a/layman/tests/external.py +++ b/layman/tests/external.py @@ -129,6 +129,113 @@ class AddDeleteEnableDisableFromDB(unittest.TestCase): self.assertTrue(success) +# Tests archive overlay types (squashfs, tar) +# http://bugs.gentoo.org/show_bug.cgi?id=304547 +class ArchiveAddRemoveSync(unittest.TestCase): + +def _create_squashfs_overlay(self): +repo_name = 'squashfs-test-overlay' +squashfs_source_path = os.path.join(HERE, 'testfiles', 'layman-test.squashfs') + +# Duplicate test squashfs (so we can delete it after testing) +(_, temp_squashfs_path) = tempfile.mkstemp() +shutil.copyfile(squashfs_source_path, temp_squashfs_path) + +# Write overlay collection XML +xml_text = '''\ +?xml version=1.0 encoding=UTF-8? +repositories xmlns= version=1.0 + repo quality=experimental status=unofficial +name%(repo_name)s/name +descriptionXXX/description +owner + emailf...@example.org/email +/owner +source type=squashfsfile://%(temp_squashfs_url)s/source + /repo +/repositories +'''\ +% { +'temp_squashfs_url': urllib.pathname2url(temp_squashfs_path), +'repo_name': repo_name + } +print(xml_text) +return xml_text, repo_name, temp_squashfs_path + + +def _create_tar_overlay(self): +repo_name = 'tar-test-overlay' +tar_source_path = os.path.join(HERE, 'testfiles', 'layman-test.tar.bz2') + +# Duplicate test tarball (so we can delete it after testing) +(_, temp_tarball_path) = tempfile.mkstemp() +shutil.copyfile(tar_source_path, temp_tarball_path) + +# Write overlay collection XML +xml_text = '''\ +?xml version=1.0 encoding=UTF-8? +repositories xmlns= version=1.0 + repo quality=experimental status=unofficial +name%(repo_name)s/name +descriptionXXX/description +owner + emailf...@example.org/email +/owner +source type=tarfile://%(temp_tarball_url)s/source + /repo +/repositories +'''\ +% { +'temp_tarball_url': urllib.pathname2url(temp_tarball_path), +'repo_name': repo_name + } +print(xml_text) +return xml_text, repo_name, temp_tarball_path + + +def test(self): +for archive in ('squashfs', 'tar'): +xml_text, repo_name, temp_archive_path = getattr(self, +_create_%(archive)s_overlay % +{'archive': archive})() + +(fd, temp_collection_path) = tempfile.mkstemp() +with os.fdopen(fd, 'w') as f: +f.write(xml_text) + +# Make playground directory +temp_dir_path = tempfile.mkdtemp() + +# Make DB from it +config = BareConfig() +# Necessary for all mountable overlay types +layman_inst = LaymanAPI(config=config) +db = DbBase(config, [temp_collection_path]) + +specific_overlay_path = os.path.join(temp_dir_path, repo_name) +o = db.select(repo_name) + +# Actual testcase +o.add(temp_dir_path) +self.assertTrue(os.path.exists(specific_overlay_path)) +# (1/2) Sync with source available +o.sync(temp_dir_path) +self.assertTrue(os.path.exists(specific_overlay_path)) +os.unlink(temp_archive_path) +try: +# (2/2) Sync with source _not_ available +o.sync(temp_dir_path) +except: +pass +self.assertTrue(os.path.exists(specific_overlay_path)) +o.delete(temp_dir_path) +self.assertFalse(os.path.exists(specific_overlay_path)) + +# Cleanup +os.unlink(temp_collection_path) +os.rmdir(temp_dir_path) + + class CLIArgs(unittest.TestCase): def test(self): @@ -547,67 +654,6 @@ class RemoteDBCache(unittest.TestCase): shutil.rmtree(tmpdir) -# http://bugs.gentoo.org/show_bug.cgi?id=304547 -class TarAddRemoveSync(unittest.TestCase): -def test(self): -repo_name = 'tar-test-overlay' -tar_source_path = os.path.join(HERE, 'testfiles', 'layman-test.tar.bz2') - -#
[gentoo-commits] proj/layman:gsoc2014 commit in: layman/tests/testfiles/, layman/overlays/, layman/, doc/, layman/tests/
commit: be9e55df8c896cd8d7a4093fd8e440cf8c79c2b6 Author: Devan Franchini twitch153 AT gentoo DOT org AuthorDate: Tue Jun 10 22:12:35 2014 + Commit: Brian Dolbec brian.dolbec AT gmail DOT com CommitDate: Sun Jun 15 00:36:39 2014 + URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=be9e55df Replaces subpath with branch In favor of a more widely used varaible, the subpath variable has been replaced with branch. In preparation for branch support in overlay.xml files. layman.8.txt: An example of an overlay.xml with a branch in it has been added for users along with pointers to using the variable. --- doc/layman.8.txt | 31 +++ layman/api.py| 2 +- layman/overlays/bzr.py | 2 +- layman/overlays/cvs.py | 20 ++-- layman/overlays/darcs.py | 2 +- layman/overlays/g_common.py | 2 +- layman/overlays/g_sorcery.py | 2 +- layman/overlays/git.py | 3 ++- layman/overlays/mercurial.py | 2 +- layman/overlays/overlay.py | 25 + layman/overlays/rsync.py | 2 +- layman/overlays/svn.py | 2 +- layman/overlays/tar.py | 31 --- layman/tests/external.py | 3 ++- layman/tests/testfiles/subpath-1.xml | 4 ++-- layman/tests/testfiles/subpath-2.xml | 4 ++-- 16 files changed, 74 insertions(+), 63 deletions(-) diff --git a/doc/layman.8.txt b/doc/layman.8.txt index fa75fac..0819570 100644 --- a/doc/layman.8.txt +++ b/doc/layman.8.txt @@ -445,6 +445,37 @@ Example 1. An example overlays.xml file /repositories --- +Example 2. An example overlays.xml file with a branch + +--- +?xml version=1.0 encoding=UTF-8? +!DOCTYPE repositories SYSTEM /dtd/repositories.dtd +repositories xmlns= version=1.0 +repo quality=experimental status=official +namehardened-development/name +descriptionDevelopment Overlay for Hardened Gcc 4.x Toolchain/description + homepagehttp://git.overlays.gentoo.org/gitweb/?p=proj/hardened-dev.git;a=summary/homepage +owner type=project + emailharde...@gentoo.org/email +/owner +source type=gitgit://git.overlays.gentoo.org/proj/hardened-dev.git/source +branchuclibc/branch + feedhttp://git.overlays.gentoo.org/gitweb/?p=proj/hardened-dev.git;a=atom/feed +/repo +/repositories + +Users can specify a branch for an overlay, given one actually exists. +This logic is applicable to CVS overlays as well and the branch variable +is comparable to specifying a subpath for a CVS repository. + +VCS types where the use of branch is supported is as follows:: +- CVS +- Tar +- Git +- Mercurial +However, for CVS and Tar overlays, the branch will be treated as a subpath. +If you use the branch variable with any other overlay types aside from the ones +listed, it will be ignored. ADDING AN OVERLAY LOCALLY ~ diff --git a/layman/api.py b/layman/api.py index 1d50adf..a86970f 100755 --- a/layman/api.py +++ b/layman/api.py @@ -236,7 +236,7 @@ class LaymanAPI(object): 'irc': overlay.irc, 'description': overlay.description, 'feeds': overlay.feeds, -'sources': [(e.src, e.type, e.subpath) \ +'sources': [(e.src, e.type, e.branch) \ for e in overlay.sources], #'src_uris': [e.src for e in overlay.sources], 'src_uris': overlay.source_uris(), diff --git a/layman/overlays/bzr.py b/layman/overlays/bzr.py index 162ba40..ea3e787 100644 --- a/layman/overlays/bzr.py +++ b/layman/overlays/bzr.py @@ -47,7 +47,7 @@ class BzrOverlay(OverlaySource): super(BzrOverlay, self).__init__(parent, config, _location, ignore) -self.subpath = None +self.branch = None def _fix_bzr_source(self, source): ''' diff --git a/layman/overlays/cvs.py b/layman/overlays/cvs.py index bf54921..a8c6abb 100644 --- a/layman/overlays/cvs.py +++ b/layman/overlays/cvs.py @@ -47,25 +47,9 @@ class CvsOverlay(OverlaySource): def __init__(self, parent, config, _location, ignore = 0): super(CvsOverlay, self).__init__(parent, config, _location, ignore) -self.subpath = None +self.branch = None -def __eq__(self, other): -res = super(CvsOverlay, self).__eq__(other) \ -and self.subpath == other.subpath -return res - -def __ne__(self, other): -return not self.__eq__(other) - -# overrider -def to_xml_hook(self, repo_elem): -if self.subpath: -_subpath = ET.Element('subpath') -_subpath.text = self.subpath -repo_elem.append(_subpath) -del _subpath -
[gentoo-commits] proj/layman:gsoc2014 commit in: layman/tests/
commit: d161e4fb9e41cdc841adb40b86ab6cbb5b01a0a2 Author: Devan Franchini twitch153 AT gentoo DOT org AuthorDate: Thu Jun 12 21:39:26 2014 + Commit: Brian Dolbec brian.dolbec AT gmail DOT com CommitDate: Sun Jun 15 00:36:41 2014 + URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=d161e4fb external.py: Adds py3 compatibility to tests Adds py3 urllib imports, print function updates, and implicit utf-8 decoding of test strings. --- layman/tests/external.py | 14 +- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/layman/tests/external.py b/layman/tests/external.py index 82825e2..5882270 100755 --- a/layman/tests/external.py +++ b/layman/tests/external.py @@ -15,11 +15,15 @@ # '''Runs external (non-doctest) test cases.''' -import unittest import os -import tempfile import shutil -import urllib +import tempfile +import unittest +#Py3 +try: +import urllib.request as urllib +except ImportError: +import urllib from layman.dbbase import DbBase from layman.output import Message from layman.config import BareConfig @@ -35,8 +39,8 @@ class Unicode(unittest.TestCase): o = DbBase(config, [filename]) for verbose in (True, False): for t in o.list(verbose=verbose): -print t[0] -print +print(t[0].decode('utf-8')) +print() def test_184449(self): self._overlays_bug(184449)