Mercurial > treepkg
comparison test/test_builder.py @ 186:2622bf5ed5bd
For log files, use a name under the test specific temp dir to avoid
leaving test files in the current working directory
author | Bernhard Herzog <bh@intevation.de> |
---|---|
date | Thu, 26 Jun 2008 16:33:14 +0000 |
parents | e1c7cd896310 |
children | e3ab8aca2b08 |
comparison
equal
deleted
inserted
replaced
185:e1c7cd896310 | 186:2622bf5ed5bd |
---|---|
160 if os.path.exists(binary_dir_name): | 160 if os.path.exists(binary_dir_name): |
161 os.rmdir(binary_dir_name) | 161 os.rmdir(binary_dir_name) |
162 # sanity check: the binary directory must not exist yet. | 162 # sanity check: the binary directory must not exist yet. |
163 self.failIf(os.path.exists(binary_dir_name)) | 163 self.failIf(os.path.exists(binary_dir_name)) |
164 | 164 |
165 builder = PBuilder("my_pbuilderrc", self.root_command) | 165 logfilename = self.temp_file_name("the_logfile") |
166 builder.build("my_dsc_file", binary_dir_name, "the_logfile") | 166 |
167 builder = PBuilder("my_pbuilderrc", self.root_command) | |
168 builder.build("my_dsc_file", binary_dir_name, logfilename) | |
167 self.check_command_line(['/usr/sbin/pbuilder', 'build', | 169 self.check_command_line(['/usr/sbin/pbuilder', 'build', |
168 '--configfile', 'my_pbuilderrc', | 170 '--configfile', 'my_pbuilderrc', |
169 '--logfile', 'the_logfile', | 171 '--logfile', logfilename, |
170 '--buildresult', binary_dir_name, | 172 '--buildresult', binary_dir_name, |
171 '--debbuildopts', '-b', | 173 '--debbuildopts', '-b', |
172 'my_dsc_file']) | 174 'my_dsc_file']) |
173 self.failUnless(os.path.isdir(binary_dir_name)) | 175 self.failUnless(os.path.isdir(binary_dir_name)) |
174 | 176 |
178 if os.path.exists(binary_dir_name): | 180 if os.path.exists(binary_dir_name): |
179 os.rmdir(binary_dir_name) | 181 os.rmdir(binary_dir_name) |
180 # sanity check: the binary directory must not exist yet. | 182 # sanity check: the binary directory must not exist yet. |
181 self.failIf(os.path.exists(binary_dir_name)) | 183 self.failIf(os.path.exists(binary_dir_name)) |
182 | 184 |
183 builder = PBuilder("my_pbuilderrc", self.root_command) | 185 logfilename = self.temp_file_name("the_logfile") |
184 builder.build("my_dsc_file", binary_dir_name, "the_logfile", | 186 |
187 builder = PBuilder("my_pbuilderrc", self.root_command) | |
188 builder.build("my_dsc_file", binary_dir_name, logfilename, | |
185 bindmounts=["/home/builder/tracks", | 189 bindmounts=["/home/builder/tracks", |
186 "/home/builder/pbuilder"]) | 190 "/home/builder/pbuilder"]) |
187 self.check_command_line(['/usr/sbin/pbuilder', 'build', | 191 self.check_command_line(['/usr/sbin/pbuilder', 'build', |
188 '--configfile', 'my_pbuilderrc', | 192 '--configfile', 'my_pbuilderrc', |
189 '--bindmounts', "/home/builder/tracks", | 193 '--bindmounts', "/home/builder/tracks", |
190 '--bindmounts', "/home/builder/pbuilder", | 194 '--bindmounts', "/home/builder/pbuilder", |
191 '--logfile', 'the_logfile', | 195 '--logfile', logfilename, |
192 '--buildresult', binary_dir_name, | 196 '--buildresult', binary_dir_name, |
193 '--debbuildopts', '-b', | 197 '--debbuildopts', '-b', |
194 'my_dsc_file']) | 198 'my_dsc_file']) |
195 self.failUnless(os.path.isdir(binary_dir_name)) | 199 self.failUnless(os.path.isdir(binary_dir_name)) |
196 | 200 |
200 if os.path.exists(binary_dir_name): | 204 if os.path.exists(binary_dir_name): |
201 os.rmdir(binary_dir_name) | 205 os.rmdir(binary_dir_name) |
202 # sanity check: the binary directory must not exist yet. | 206 # sanity check: the binary directory must not exist yet. |
203 self.failIf(os.path.exists(binary_dir_name)) | 207 self.failIf(os.path.exists(binary_dir_name)) |
204 | 208 |
205 builder = PBuilder("my_pbuilderrc", self.root_command) | 209 logfilename = self.temp_file_name("the_logfile") |
206 builder.build("my_dsc_file", binary_dir_name, "the_logfile", | 210 |
211 builder = PBuilder("my_pbuilderrc", self.root_command) | |
212 builder.build("my_dsc_file", binary_dir_name, logfilename, | |
207 extra_packages=["subversion", "texinfo"]) | 213 extra_packages=["subversion", "texinfo"]) |
208 self.check_command_line(['/usr/sbin/pbuilder', 'build', | 214 self.check_command_line(['/usr/sbin/pbuilder', 'build', |
209 '--configfile', 'my_pbuilderrc', | 215 '--configfile', 'my_pbuilderrc', |
210 '--extrapackages', "subversion", | 216 '--extrapackages', "subversion", |
211 '--extrapackages', "texinfo", | 217 '--extrapackages', "texinfo", |
212 '--logfile', 'the_logfile', | 218 '--logfile', logfilename, |
213 '--buildresult', binary_dir_name, | 219 '--buildresult', binary_dir_name, |
214 '--debbuildopts', '-b', | 220 '--debbuildopts', '-b', |
215 'my_dsc_file']) | 221 'my_dsc_file']) |
216 self.failUnless(os.path.isdir(binary_dir_name)) | 222 self.failUnless(os.path.isdir(binary_dir_name)) |
217 | 223 |
225 self.failIf(os.path.exists(binary_dir_name)) | 231 self.failIf(os.path.exists(binary_dir_name)) |
226 # sanity check: the environment variable TREEPKG_TEST must not | 232 # sanity check: the environment variable TREEPKG_TEST must not |
227 # be set yet | 233 # be set yet |
228 self.failIf("TREEPKG_TEST" in os.environ) | 234 self.failIf("TREEPKG_TEST" in os.environ) |
229 | 235 |
230 builder = PBuilder("my_pbuilderrc", self.root_command) | 236 logfilename = self.temp_file_name("the_logfile") |
231 builder.build("my_dsc_file", binary_dir_name, "the_logfile", | 237 |
238 builder = PBuilder("my_pbuilderrc", self.root_command) | |
239 builder.build("my_dsc_file", binary_dir_name, logfilename, | |
232 extra_env=dict(TREEPKG_TEST=env_test_file)) | 240 extra_env=dict(TREEPKG_TEST=env_test_file)) |
233 self.check_command_line(['/usr/sbin/pbuilder', 'build', | 241 self.check_command_line(['/usr/sbin/pbuilder', 'build', |
234 '--configfile', 'my_pbuilderrc', | 242 '--configfile', 'my_pbuilderrc', |
235 '--logfile', 'the_logfile', | 243 '--logfile', logfilename, |
236 '--buildresult', binary_dir_name, | 244 '--buildresult', binary_dir_name, |
237 '--debbuildopts', '-b', | 245 '--debbuildopts', '-b', |
238 'my_dsc_file']) | 246 'my_dsc_file']) |
239 self.failUnless(os.path.isdir(binary_dir_name)) | 247 self.failUnless(os.path.isdir(binary_dir_name)) |
240 self.failUnless(os.path.exists(env_test_file)) | 248 self.failUnless(os.path.exists(env_test_file)) |
241 | 249 |
242 def test_run_script(self): | 250 def test_run_script(self): |
243 builder = PBuilder("my_pbuilderrc", self.root_command) | 251 logfilename = self.temp_file_name("the_logfile") |
244 builder.run_script(["my_script"], logfile="the_logfile") | 252 builder = PBuilder("my_pbuilderrc", self.root_command) |
253 builder.run_script(["my_script"], logfile=logfilename) | |
245 self.check_command_line(['/usr/sbin/pbuilder', 'execute', | 254 self.check_command_line(['/usr/sbin/pbuilder', 'execute', |
246 '--configfile', 'my_pbuilderrc', | 255 '--configfile', 'my_pbuilderrc', |
247 '--logfile', 'the_logfile', '--', | 256 '--logfile', logfilename, '--', |
248 'my_script']) | 257 'my_script']) |
249 | 258 |
250 def test_run_script_with_arguments(self): | 259 def test_run_script_with_arguments(self): |
251 builder = PBuilder("my_pbuilderrc", self.root_command) | 260 logfilename = self.temp_file_name("the_logfile") |
252 builder.run_script(["my_script", "--verbose"], logfile="the_logfile") | 261 builder = PBuilder("my_pbuilderrc", self.root_command) |
262 builder.run_script(["my_script", "--verbose"], logfile=logfilename) | |
253 self.check_command_line(['/usr/sbin/pbuilder', 'execute', | 263 self.check_command_line(['/usr/sbin/pbuilder', 'execute', |
254 '--configfile', 'my_pbuilderrc', | 264 '--configfile', 'my_pbuilderrc', |
255 '--logfile', 'the_logfile', '--', | 265 '--logfile', logfilename, '--', |
256 'my_script', '--verbose']) | 266 'my_script', '--verbose']) |
257 | 267 |
258 def test_run_script_with_bindmounts(self): | 268 def test_run_script_with_bindmounts(self): |
259 builder = PBuilder("my_pbuilderrc", self.root_command) | 269 logfilename = self.temp_file_name("the_logfile") |
260 builder.run_script(["my_script"], logfile="the_logfile", | 270 builder = PBuilder("my_pbuilderrc", self.root_command) |
271 builder.run_script(["my_script"], logfile=logfilename, | |
261 bindmounts=("/home/builder/foo", | 272 bindmounts=("/home/builder/foo", |
262 "/home/builder/treepkg")) | 273 "/home/builder/treepkg")) |
263 self.check_command_line(['/usr/sbin/pbuilder', 'execute', | 274 self.check_command_line(['/usr/sbin/pbuilder', 'execute', |
264 '--configfile', 'my_pbuilderrc', | 275 '--configfile', 'my_pbuilderrc', |
265 '--logfile', 'the_logfile', | 276 '--logfile', logfilename, |
266 '--bindmounts', '/home/builder/foo', | 277 '--bindmounts', '/home/builder/foo', |
267 '--bindmounts', '/home/builder/treepkg', | 278 '--bindmounts', '/home/builder/treepkg', |
268 '--', 'my_script']) | 279 '--', 'my_script']) |
269 | 280 |
270 def test_run_script_save_after_exec(self): | 281 def test_run_script_save_after_exec(self): |
271 builder = PBuilder("my_pbuilderrc", self.root_command) | 282 logfilename = self.temp_file_name("the_logfile") |
272 builder.run_script(["my_script", "--verbose"], logfile="the_logfile", | 283 builder = PBuilder("my_pbuilderrc", self.root_command) |
284 builder.run_script(["my_script", "--verbose"], logfilename, | |
273 save_after_exec=True) | 285 save_after_exec=True) |
274 self.check_command_line(['/usr/sbin/pbuilder', 'execute', | 286 self.check_command_line(['/usr/sbin/pbuilder', 'execute', |
275 '--configfile', 'my_pbuilderrc', | 287 '--configfile', 'my_pbuilderrc', |
276 '--logfile', 'the_logfile', | 288 '--logfile', logfilename, |
277 '--save-after-exec', '--', | 289 '--save-after-exec', '--', |
278 'my_script', '--verbose']) | 290 'my_script', '--verbose']) |
279 | 291 |
280 | 292 |
281 class TestPBuilderWithBinaryPackage(PBuilderTests): | 293 class TestPBuilderWithBinaryPackage(PBuilderTests): |