summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Ulrich Niedermann <hun@n-dimensional.de>2011-01-22 18:18:05 +0100
committerHans Ulrich Niedermann <hun@n-dimensional.de>2011-01-22 18:18:05 +0100
commitdf0cd5ba9cd97cc56c2d1447a913f00a6845d4a3 (patch)
tree70bc884501e8b08c9e50f51bcc3575f75fbf70d9
parent7f551fc7512f4476077dd5f47b51bea673a304fa (diff)
downloadfedora-packager-4/local-ops.zip
fedora-packager-4/local-ops.tar.gz
fedora-packager-4/local-ops.tar.xz
tests: Basic clone/local/lint test case4/local-ops
-rw-r--r--Makefile.am7
-rw-r--r--src/pyfedpkg/tests.py76
2 files changed, 83 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am
index 506ad96..79d03a4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -80,6 +80,13 @@ ppc-koji: $(srcdir)/src/secondary-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
fedpkg.1: fedpkg
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:])