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
|
# pyfedpkg.tests - run some simple tests on fedpkg
import os
import sys
from pyfedpkg import _run_command
def run(*args, **kwargs):
print " CMD:", args, kwargs
_run_command(*args, **kwargs)
__all__ = [ 'tests' ]
def int_test_clone(fedpkg, anonymous):
package_name = 'lsnipes'
cmd = list(fedpkg)
if anonymous:
cmd.extend(['clone', '-a', package_name])
else:
cmd.extend(['clone', package_name])
run(cmd)
oldcwd = os.getcwd()
os.chdir(package_name)
cmd = list(fedpkg)
cmd.extend(['srpm'])
run(cmd)
cmd = list(fedpkg)
cmd.extend(['local'])
run(cmd)
cmd = list(fedpkg)
cmd.extend(['lint'])
run(cmd)
def test_anon_clone(fedpkg):
int_test_clone(fedpkg, anonymous=True)
def test_user_clone(fedpkg):
int_test_clone(fedpkg, anonymous=False)
def test_foo(cmd):
pass
def tests(fedpkg):
if type(fedpkg) == type([]):
pass
else:
fedpkg = [ fedpkg ]
print "Running tests on", repr(fedpkg)
mod = sys.modules[__name__]
for fname in [ x for x in dir(mod) if x.startswith('test_') ]:
fun = getattr(mod, fname)
print "TC", fname
oldcwd = os.getcwd()
os.makedirs(fname)
os.chdir(fname)
fun(list(fedpkg))
os.chdir(oldcwd)
run(['rm', '-rf', fname])
if __name__ == '__main__':
tests(sys.argv[1:])
|