[Treepkg-commits] r174 - in trunk: bin test

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Mar 6 20:57:05 CET 2009


Author: bh
Date: 2009-03-06 20:57:04 +0100 (Fri, 06 Mar 2009)
New Revision: 174

Modified:
   trunk/bin/listpackages.py
   trunk/test/test_listpackages.py
Log:
Make bin/listpackages.py handle corner cases like no revisions built or
--revision referring to non-exisiting revisions better.  Add tests for this.


Modified: trunk/bin/listpackages.py
===================================================================
--- trunk/bin/listpackages.py	2009-03-06 19:22:53 UTC (rev 173)
+++ trunk/bin/listpackages.py	2009-03-06 19:57:04 UTC (rev 174)
@@ -48,14 +48,19 @@
 
     return revision, rulesrev
 
+def format_revision(main_rev, rules_rev):
+    formatted = str(main_rev)
+    if rules_rev is not None:
+        formatted += "-" + str(rules_rev)
+    return formatted
 
+
 def list_track_packages(track, revision, source, binary):
     main_rev, rules_rev = revision
 
     revisions = track.get_revisions()
-    if not revisions:
-        print >>sys.stderr, "No revisions have been packaged"
-        sys.exit(1)
+    if not revisions and main_rev is None:
+        return
 
     if main_rev is None:
         revpkg = revisions[-1]
@@ -77,7 +82,7 @@
             for filename in revpkg.list_binary_files():
                 print filename
     else:
-        print >>sys.stderr, "No revision", repr(revision)
+        print >>sys.stderr, "No revision", format_revision(main_rev, rules_rev)
         sys.exit(1)
 
 def list_packages(config_file, trackname, revision, source, binary):

Modified: trunk/test/test_listpackages.py
===================================================================
--- trunk/test/test_listpackages.py	2009-03-06 19:22:53 UTC (rev 173)
+++ trunk/test/test_listpackages.py	2009-03-06 19:57:04 UTC (rev 174)
@@ -100,6 +100,28 @@
             raise self.failureException("\n" + "".join(diff))
 
 
+class TestListPackagesNoPackages(ListPackagesTest):
+
+    track_files = []
+
+    def test_listpackages_noargs(self):
+        # if nothing has been packaged yet, the output is simply empty
+        self.check_cmd(["--source"], "")
+
+    def test_listpackages_revision(self):
+        # if nothing has been packaged yet, the output is simply empty
+        self.assertEquals(self.run_command(["--source", "--revision=12345",
+                                            "--track=kdepim"],
+                                           expected_exit_code=1),
+                          "No revision 12345\n")
+
+    def test_listpackages_revision_rulesrev(self):
+        # if nothing has been packaged yet, the output is simply empty
+        self.assertEquals(self.run_command(["--source", "--revision=12345-321",
+                                            "--track=kdepim"],
+                                           expected_exit_code=1),
+                          "No revision 12345-321\n")
+
 class TestListPackagesTrackNoRevision(ListPackagesTest):
 
     track_files = [package_track_files("kdepim", "1.0.1",



More information about the Treepkg-commits mailing list