Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 292394 | Differences between
and this patch

Collapse All | Expand All

(-)a/pym/repoman/checks.py (-1 / +15 lines)
Lines 436-441 class BuiltWithUse(LineCheck): Link Here
436
	re = re.compile('^.*built_with_use')
436
	re = re.compile('^.*built_with_use')
437
	error = errors.BUILT_WITH_USE
437
	error = errors.BUILT_WITH_USE
438
438
439
class PNotInSourceUri(LineCheck):
440
	fail = False
441
	pv = ''
442
	def new(self, pkg):
443
		self.pv = pkg.cpv_split[1] + '.' + pkg.cpv_split[2]
444
		self.re = re.compile(self.pv, re.I)
445
		self.src_uri = pkg.metadata["SRC_URI"]
446
		self.fail = self.re.search( self.src_uri)
447
448
	def check(self, num, line):
449
		if self.fail:
450
			return "SRC_URI: '" + self.src_uri + "' conntains $P: '" \
451
			+ self.pv + "' but it shouldn't."
452
		
439
# EAPI-3 checks
453
# EAPI-3 checks
440
class Eapi3DeprecatedFuncs(LineCheck):
454
class Eapi3DeprecatedFuncs(LineCheck):
441
	repoman_check_name = 'EAPI.deprecated'
455
	repoman_check_name = 'EAPI.deprecated'
Lines 496-502 _constant_checks = tuple((c() for c in ( Link Here
496
	EbuildPatches, EbuildQuotedA, EapiDefinition,
510
	EbuildPatches, EbuildQuotedA, EapiDefinition,
497
	IUseUndefined, InheritAutotools,
511
	IUseUndefined, InheritAutotools,
498
	EMakeParallelDisabled, EMakeParallelDisabledViaMAKEOPTS, NoAsNeeded,
512
	EMakeParallelDisabled, EMakeParallelDisabledViaMAKEOPTS, NoAsNeeded,
499
	DeprecatedBindnowFlags, SrcUnpackPatches, WantAutoDefaultValue,
513
	DeprecatedBindnowFlags,PNotInSourceUri, SrcUnpackPatches, WantAutoDefaultValue,
500
	SrcCompileEconf, Eapi3DeprecatedFuncs,
514
	SrcCompileEconf, Eapi3DeprecatedFuncs,
501
	Eapi4IncompatibleFuncs, Eapi4GoneVars, BuiltWithUse)))
515
	Eapi4IncompatibleFuncs, Eapi4GoneVars, BuiltWithUse)))
502
516
(-)a/pym/repoman/tests/checks/P_shouldnt_be_in_source_ri.py (-1 / +61 lines)
Line 0 Link Here
0
- 
1
import unittest
2
from portage.tests import TestCase
3
from repoman.checks import PNotInSourceUri
4
'''
5
	using real _emerge.Package.Package turned out to be  very troublesome.
6
	I had
7
	#begin source... don't mind abusing spaces it's just a comment
8
	import portage
9
	from portage import portdb
10
	from _emerge.Package import Package
11
	from _emerge.RootConfig import RootConfig
12
13
	cpv         = "app-editors/vim-7.2.402"
14
	allvars     = set(x for x in portage.auxdbkeys if not x.startswith("UNUSED_"))
15
	metadata    = portdb.aux_get( cpv, allvars) 
16
	root_config = RootConfig(portage.config(), "/usr/portage", None)
17
	pkg         = Package( cpv = cpv, metadata = metadata, root_config = root_config)
18
	#end source
19
20
	but it still didn't work so I gave up and wrote FakePackage.
21
	Making test a lot more complicated than tested code is wong IMO.
22
'''
23
class FakePackage:
24
	metadata = dict()
25
	cpv_split = (u'c', u'p', u'v', 'r')
26
27
class TestPNotInSourceUri(unittest.TestCase):
28
	uri_name_ok= (
29
		(u'http://foomatic/foobar.tar.gz', (u'foo-matic', u'foobar', u'1', u'r0')),
30
		(u'http://foomatic.org/1/foobar.tar.gz', (u'foo-matic', u'foobar', u'1', u'r0')))
31
32
	uri_name_bad= (
33
		(u'http://foomatic.org/foobar/1.tgz', (u'foo-matic', u'foobar', u'1', u'r0')),
34
		(u'http://foomatic.org/foobar-1.tar.gz', (u'foo-matic', u'foobar', u'1', u'r0')),
35
		(u'http://foomatic/FOOBAR-1.htm', (u'foo-matic', u'foobar', u'1', u'r0')),
36
		(u'http://foomatic/foobar-1/get_me.tar.gz', (u'foo-matic', u'foobar', u'1', u'r0')))
37
38
	testee = PNotInSourceUri()
39
	pkg = FakePackage( )
40
	
41
	def check_returns_none(self, uri, cpv):
42
			self.pkg.metadata['SRC_URI'] = uri
43
			self.pkg.cpv_split = cpv
44
			self.testee.new( self.pkg)
45
			return self.testee.check( 1, "") is None
46
47
	def test_accept_any_EAPI(self):
48
		for eapi in ('0', '1', '2', '3', '3_pre2', '4'):
49
			self.assertTrue(self.testee.check_eapi(eapi))
50
	
51
	def test_accept_no_p_in_src_uri(self):
52
		for uri_name in self.uri_name_ok:
53
			self.assertTrue(self.check_returns_none(uri_name[0], uri_name[1]))
54
55
	def test_reject_p_in_src_uri(self):
56
		for uri_name in self.uri_name_bad:
57
			self.assertFalse(self.check_returns_none(uri_name[0], uri_name[1]))
58
59
if __name__ == '__main__':
60
	suite = unittest.TestLoader().loadTestsFromTestCase(TestPNotInSourceUri)
61
	unittest.TextTestRunner(verbosity=2).run(suite)

Return to bug 292394