Mercurial > treepkg
changeset 248:5dd710b167d2
Make bin/listpackages.py handle corner cases like no revisions built or
--revision referring to non-exisiting revisions better. Add tests for this.
author | Bernhard Herzog <bh@intevation.de> |
---|---|
date | Fri, 06 Mar 2009 19:57:04 +0000 |
parents | 55337021fe5b |
children | a3f106580525 |
files | bin/listpackages.py test/test_listpackages.py |
diffstat | 2 files changed, 31 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/bin/listpackages.py Fri Mar 06 19:22:53 2009 +0000 +++ b/bin/listpackages.py Fri Mar 06 19:57:04 2009 +0000 @@ -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):
--- a/test/test_listpackages.py Fri Mar 06 19:22:53 2009 +0000 +++ b/test/test_listpackages.py Fri Mar 06 19:57:04 2009 +0000 @@ -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",