From df0cd5ba9cd97cc56c2d1447a913f00a6845d4a3 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Sat, 22 Jan 2011 18:18:05 +0100 Subject: tests: Basic clone/local/lint test case --- Makefile.am | 7 +++++ src/pyfedpkg/tests.py | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 src/pyfedpkg/tests.py diff --git a/Makefile.am b/Makefile.am index 506ad96..79d03a4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -79,6 +79,13 @@ ppc-koji: $(srcdir)/src/secondary-koji rm -f ppc-koji install -p -m 755 -T $(srcdir)/src/secondary-koji ppc-koji +if HAVE_PYTHON +check-local: check-local-fedpkg-tests +check-local-fedpkg-tests: + cd $(srcdir)/src \ + && python "pyfedpkg/tests.py" python "$$PWD/fedpkg.py" -v +endif + if HAVE_PYTHON CLEANFILES += fedpkg.1 man1_MANS = fedpkg.1 diff --git a/src/pyfedpkg/tests.py b/src/pyfedpkg/tests.py new file mode 100644 index 0000000..8beb337 --- /dev/null +++ b/src/pyfedpkg/tests.py @@ -0,0 +1,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:]) -- cgit