Mercurial > treepkg
comparison test/test_packager.py @ 98:f7b9c7113c46
Make packaging a specific revision work even if newer revisions have already
been packaged. Add corresponding tests
author | Bernhard Herzog <bh@intevation.de> |
---|---|
date | Mon, 26 Nov 2007 15:17:04 +0000 |
parents | d85efd3276bd |
children | 312949e7628d |
comparison
equal
deleted
inserted
replaced
97:d85efd3276bd | 98:f7b9c7113c46 |
---|---|
106 self.svn_url = create_svn_repository(self.svndir) + "/trunk" | 106 self.svn_url = create_svn_repository(self.svndir) + "/trunk" |
107 subversion.checkout(self.svn_url, self.svnworkdir) | 107 subversion.checkout(self.svn_url, self.svnworkdir) |
108 for message, files in self.revisions: | 108 for message, files in self.revisions: |
109 add_svn_files(self.svnworkdir, files, message) | 109 add_svn_files(self.svnworkdir, files, message) |
110 | 110 |
111 def runtest(self, debrevision, **extra_track_args): | 111 def runtest(self, debrevision, group_args=None, **extra_track_args): |
112 rootcmd = os.path.join(os.path.dirname(__file__), os.pardir, "test", | 112 rootcmd = os.path.join(os.path.dirname(__file__), os.pardir, "test", |
113 "mocksudopbuilder.py") | 113 "mocksudopbuilder.py") |
114 track = PackageTrack(name="testpkg", base_dir=self.trackdir, | 114 track = PackageTrack(name="testpkg", base_dir=self.trackdir, |
115 svn_url=self.svn_url, pbuilderrc="", | 115 svn_url=self.svn_url, pbuilderrc="", |
116 root_cmd=[sys.executable, rootcmd], | 116 root_cmd=[sys.executable, rootcmd], |
117 deb_email="treepkg@example.com", | 117 deb_email="treepkg@example.com", |
118 deb_fullname="treepkg tester", | 118 deb_fullname="treepkg tester", |
119 **extra_track_args) | 119 **extra_track_args) |
120 group = PackagerGroup([track], 1) | 120 |
121 if group_args is None: | |
122 group_args = {} | |
123 group = PackagerGroup([track], 1, **group_args) | |
121 group.check_package_tracks() | 124 group.check_package_tracks() |
122 | 125 |
123 # determine version that has been packaged. This assumes that | 126 # determine version that has been packaged. This assumes that |
124 # check_package_tracks will leave the checkout in the revision | 127 # check_package_tracks will leave the checkout in the revision |
125 # that was actually packaged. | 128 # that was actually packaged. |
126 version = subversion.last_changed_revision(self.svn_url) | 129 version = track.last_changed_revision() |
127 | 130 |
128 # Now check the source and binary package files | 131 # Now check the source and binary package files |
129 pkgdir = os.path.join(self.trackdir, "pkg", "%d-1" % version) | 132 pkgdir = os.path.join(self.trackdir, "pkg", "%d-1" % version) |
130 self.assertEquals(sorted(os.listdir(os.path.join(pkgdir, "src"))), | 133 self.assertEquals(sorted(os.listdir(os.path.join(pkgdir, "src"))), |
131 [name % locals() for name in | 134 [name % locals() for name in |
148 def test_default_debrevision_prefix(self): | 151 def test_default_debrevision_prefix(self): |
149 self.runtest("treepkg1") | 152 self.runtest("treepkg1") |
150 | 153 |
151 def test_custom_debrevision_prefix(self): | 154 def test_custom_debrevision_prefix(self): |
152 self.runtest("kk1", debrevision_prefix="kk") | 155 self.runtest("kk1", debrevision_prefix="kk") |
156 | |
157 | |
158 class TestPackagerWithMultipleRevisions(PackagerTest): | |
159 | |
160 revisions = [ | |
161 ("Initial Revision", | |
162 [("README", "and miles to go before I sleep")]), | |
163 ("Add some code", | |
164 [("program.c", "int main(void) { return 0; }")]), | |
165 ("Add some more code", | |
166 [("another.c", "int main(void) { return 1; }")]), | |
167 ] | |
168 | |
169 def test_packaging_specific_revision(self): | |
170 # Package the newest revision and then package an older one. | |
171 self.runtest("treepkg1") | |
172 self.runtest("treepkg1", group_args=dict(revision=3)) | |
173 | |
153 | 174 |
154 class StoppingPackager(treepkg.packager.RevisionPackager): | 175 class StoppingPackager(treepkg.packager.RevisionPackager): |
155 | 176 |
156 def package(self): | 177 def package(self): |
157 pass | 178 pass |