~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to fai/nametest.py

  • Committer: Aaron Bentley
  • Date: 2005-06-07 18:52:04 UTC
  • Revision ID: abentley@panoramicfeedback.com-20050607185204-5fc1f0e3d393b909
Added NEWS, obsoleted bzr-pull

Show diffs side-by-side

added added

removed removed

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