diff options
author | Zac Medico <zmedico@gentoo.org> | 2008-09-20 08:47:29 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2008-09-20 08:47:29 +0000 |
commit | 7f040e58b8c4c379964cc3a2899998ebf43c60b6 (patch) | |
tree | 39e07bc8978b2b765f0475660e7bab772a20528d | |
parent | 6ea674b66400655cec2cd222cc5cc2121b4ffb2f (diff) | |
download | portage-7f040e58b8c4c379964cc3a2899998ebf43c60b6.tar.gz portage-7f040e58b8c4c379964cc3a2899998ebf43c60b6.tar.bz2 portage-7f040e58b8c4c379964cc3a2899998ebf43c60b6.zip |
Add test cases for SRC_URI validation.
svn path=/main/trunk/; revision=11524
-rw-r--r-- | pym/portage/dbapi/porttree.py | 15 | ||||
-rw-r--r-- | pym/portage/tests/dep/test_src_uri.py | 31 |
2 files changed, 37 insertions, 9 deletions
diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py index feade6fc8..95455182c 100644 --- a/pym/portage/dbapi/porttree.py +++ b/pym/portage/dbapi/porttree.py @@ -63,6 +63,11 @@ def _src_uri_validate(cpv, eapi, src_uri): "supported with EAPI='%s'") % (cpv, eapi)) operator = x continue + if operator is not None: + if "/" in x: + raise portage.exception.InvalidDependString( + ("getFetchMap(): '%s' SRC_URI '/' character in " + \ + "file name: '%s'") % (cpv, x)) uri = None operator = None @@ -548,11 +553,6 @@ class portdbapi(dbapi): if myuris: continue if token == "->": - if eapi in ("0", "1"): - raise portage.exception.InvalidDependString( - ("getFetchMap(): '%s' SRC_URI arrows are not " + \ - "supported with EAPI='%s'") % (mypkg, eapi)) - operator = token continue if operator is None: @@ -563,10 +563,7 @@ class portdbapi(dbapi): "name: '%s'") % (mypkg, uri)) else: distfile = token - if "/" in distfile: - raise portage.exception.InvalidDependString( - ("getFetchMap(): '%s' SRC_URI '/' character in " + \ - "file name: '%s'") % (mypkg, distfile)) + uri_set = uri_map.get(distfile) if uri_set is None: uri_set = set() diff --git a/pym/portage/tests/dep/test_src_uri.py b/pym/portage/tests/dep/test_src_uri.py new file mode 100644 index 000000000..3b9f08052 --- /dev/null +++ b/pym/portage/tests/dep/test_src_uri.py @@ -0,0 +1,31 @@ +# Copyright 2008 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +from portage.tests import TestCase +from portage.dep import paren_reduce +from portage.dbapi.porttree import _src_uri_validate +from portage.exception import InvalidDependString + +class SrcUri(TestCase): + + def testSrcUri(self): + + tests = [ + ( "0", "http://foo/bar -> blah.tbz2" , False ), + ( "1", "http://foo/bar -> blah.tbz2" , False ), + ( "2", "http://foo/bar -> blah.tbz2" , True ), + ( "2", "foo? ( http://foo/bar -> blah.tbz2 )" , True ), + ( "2", "-> http://foo/bar blah.tbz2 )" , False ), + ( "2", "http://foo/bar ->" , False ), + ( "2", "foo? ( http://foo/bar -> ) blah.tbz2" , False ), + ( "2", "http://foo/bar -> foo/blah.tbz2" , False ), + ] + + for eapi, src_uri, valid in tests: + try: + _src_uri_validate("cat/pkg-1", eapi, paren_reduce(src_uri)) + except InvalidDependString: + self.assertEqual(valid, False) + else: + self.assertEqual(valid, True) |