1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
#!/usr/bin/python
# arch-tag: 707bdb87-bc61-4d5d-9cd1-489aeb329951
# Copyright (C) 2004 Johannes Berg <johannes@sipsolutions.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
## package parsing tests ##
from arch.pathname import NameParser, ForkNameParser
import arch
archives = ['arch@arch.thinkmo.de--2003-archives', 'archo--dummy', '',
'arch@arch.org--archie--dada--dudu', '1@']
categories = ['moin', 'test-test',] # known to fail, tla bug: 'yadda-'
branches = ['', 'cvs','test-test-test','test--test--test','#++','emacs+junk']
versions = ['1.1', '1.2.3.4.5.6.7', '0', 'a', 'a.b.c.d',]
levels = ['patch-1321', 'base-0', 'version-0', 'versionfix-209', 'vsn-12',
'a', 'version-1', 'version-1.2.3',]
_archives = archives
_categories = []
for i in _archives:
for j in categories:
if i != '':
_categories = _categories + [i+'/'+j]
else:
_categories = _categories + [j]
_branches = []
for i in _categories:
for j in branches:
if j != '':
_branches = _branches + [i+'--'+j]
else:
_branches = _branches + [i]
_versions = []
for i in _branches:
for j in versions:
_versions = _versions + [i+'--'+j]
_levels = []
for i in _versions:
for j in levels:
_levels = _levels + [i+'--'+j]
#print _archives
#print _categories
#print _branches
#print _versions
#print _levels
verbose = False
#verbose = True
count = 0
def test(fct, type):
global verbose
global count
for i in type:
np = NameParser.__dict__.get(fct)(NameParser(i))
fnp = ForkNameParser.__dict__.get(fct)(ForkNameParser(i))
if verbose:
print 'NP ',i,fct,'=',np
print 'FNP ',i,fct,'=',fnp
if np != fnp: print '*****',i,fct,'mismatches:',np,fnp
count = count + 1
for fct in ['archive', 'nonarch', 'category', 'branch',
'package', 'version', 'patchlevel']:
for type in [_categories, _branches, _versions, _levels]:
test('get_'+fct, type)
for pre in ['is', 'has']:
for fct in ['category', 'package', 'version', 'patchlevel']:
if (pre, fct) == ('is', 'patchlevel'): continue
for type in [_categories, _branches, _versions, _levels]:
test(pre+'_'+fct, type)
print 'Done',count,'tests.'
|