annotate test/test_builder.py @ 274:2676abfc0e1d

Refactoring: Implement do_package in treepkg.packager.SourcePackager. The actual implementation in the derived classes is almost identical in all cases so it's better to have as much of the implementation in the base class. The update_version_numbers method is not called directly by the base class code so is removed from the base class. OTOH, prepare_sources_for_tarball has been added as a more general variant of update_version_numbers that is actually called by the default implementation of do_package.
author Bernhard Herzog <bh@intevation.de>
date Thu, 07 May 2009 15:19:15 +0000
parents cbcd8f549ff7
children ce7be2fb93ee
rev   line source
118
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
1 # Copyright (C) 2007, 2008 by Intevation GmbH
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
2 # Authors:
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
3 # Bernhard Herzog <bh@intevation.de>
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
4 #
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
5 # This program is free software under the GPL (>=v2)
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
6 # Read the file COPYING coming with the software for details.
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
7
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
8 """Tests for treepkg.builder"""
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
9
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
10 import sys
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
11 import os
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
12 import unittest
170
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
13 import StringIO
118
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
14
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
15 from treepkg.builder import PBuilder
121
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
16 from treepkg.run import call
118
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
17
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
18 from filesupport import FileTestMixin
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
19
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
20 # helper program to dump the command line arguments into a file so that
126
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
21 # test cases can check them. Also if the environment variable
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
22 # TREEPKG_TEST is set, create the file named by it.
118
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
23 dump_command_line_py = """
126
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
24 import sys, os
118
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
25 open(sys.argv[1], 'w').write(repr(sys.argv[2:]))
126
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
26 value = os.environ.get('TREEPKG_TEST')
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
27 if value:
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
28 open(value, 'w').close()
118
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
29 """
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
30
121
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
31 class PBuilderTests(unittest.TestCase, FileTestMixin):
118
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
32
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
33 def setUp(self):
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
34 self.dump_command_line = self.create_temp_file("dump_command_line.py",
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
35 dump_command_line_py)
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
36 self.command_line_file = self.temp_file_name("command_line")
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
37 self.root_command = [sys.executable, self.dump_command_line,
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
38 self.command_line_file]
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
39
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
40 def check_command_line(self, args):
195
e3ab8aca2b08 Make filesupport.py more PEP8 conformant. Rename method
Bernhard Herzog <bh@intevation.de>
parents: 186
diff changeset
41 self.check_file_contents(self.command_line_file, repr(args))
118
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
42
121
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
43
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
44 class TestPBuilder(PBuilderTests):
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
45
170
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
46 def test_init_pbuilder(self):
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
47 """Tests the PBuilder.init_pbuilder method."""
185
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 183
diff changeset
48 basedir = self.create_temp_dir("pbuilder")
170
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
49 pbuilderrc = os.path.join(basedir, "pbuilderrc")
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
50 builder = PBuilder(pbuilderrc, self.root_command)
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
51 old_stdout = sys.stdout
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
52 sys.stdout = captured_stdout = StringIO.StringIO()
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
53 try:
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
54 builder.init_pbuilder(distribution="etch",
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
55 mirrorsite="http://example.com/debian",
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
56 extramirrors=None)
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
57 finally:
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
58 sys.stdout = old_stdout
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
59
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
60 # check whether the necessary directories were created
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
61 missing = [dirname for dirname in ["base", "build", "result",
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
62 "aptcache", "extra-pkg"]
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
63 if not os.path.isdir(os.path.join(basedir, dirname))]
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
64 if missing:
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
65 self.fail("init_pbuilder did not create these directories: %s"
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
66 % " ".join(missing))
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
67
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
68 # check the pbuilderrc. This test is a little too strict
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
69 # because it checks the exact contents of the file. Instread it
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
70 # should normalize the contents in some way and check that.
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
71 pbuilderrc_contents = (
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
72 "# This file was automatically generated by initpbuilder.py.\n"
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
73 "# for the possible settings see \"man pbuilderrc\"\n"
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
74 "\n"
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
75 "BASETGZ=%(basedir)s/base/base.tgz\n"
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
76 "BUILDPLACE=%(basedir)s/build\n"
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
77 "USEPROC=yes\n"
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
78 "USEDEVPTS=yes\n"
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
79 "BUILDRESULT=%(basedir)s/result\n"
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
80 "DISTRIBUTION=etch\n"
173
97435e92411a Introduce filenameproperties for the various directories in the PBuilder class
Bernhard Herzog <bh@intevation.de>
parents: 171
diff changeset
81 "APTCACHE=%(basedir)s/aptcache\n"
170
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
82 "APTCACHEHARDLINK=yes\n"
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
83 "REMOVEPACKAGES=lilo\n"
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
84 "MIRRORSITE=\"http://example.com/debian\"\n"
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
85 "OTHERMIRROR=\"deb file://%(basedir)s/extra-pkg ./\"\n"
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
86 "BINDMOUNTS=\"%(basedir)s/extra-pkg\"\n"
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
87 "PKGNAME_LOGFILE=yes\n" % locals())
195
e3ab8aca2b08 Make filesupport.py more PEP8 conformant. Rename method
Bernhard Herzog <bh@intevation.de>
parents: 186
diff changeset
88 self.check_file_contents(pbuilderrc, pbuilderrc_contents)
170
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
89
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
90 # The Packages file is empty for now.
195
e3ab8aca2b08 Make filesupport.py more PEP8 conformant. Rename method
Bernhard Herzog <bh@intevation.de>
parents: 186
diff changeset
91 self.check_file_contents(os.path.join(basedir, "extra-pkg", "Packages"),
e3ab8aca2b08 Make filesupport.py more PEP8 conformant. Rename method
Bernhard Herzog <bh@intevation.de>
parents: 186
diff changeset
92 "")
170
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
93 # check the text written to stdout. This test is a little too
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
94 # strict because it checks the exact output.
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
95 self.assertEquals(captured_stdout.getvalue(),
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
96 "creating directory: '%(basedir_repr)s/base'\n"
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
97 "creating directory: '%(basedir_repr)s/build'\n"
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
98 "creating directory: '%(basedir_repr)s/result'\n"
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
99 "creating directory: '%(basedir_repr)s/aptcache'\n"
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
100 "creating directory: '%(basedir_repr)s/extra-pkg'\n"
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
101 "creating pbuilderrc: '%(basedir_repr)s/pbuilderrc'\n"
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
102 "turning the extra-pkg dir into a debian archive\n"
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
103 "running pbuilder create\n"
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
104 % dict(basedir_repr=repr(basedir)[1:-1]))
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
105
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
106 def test_init_pbuilder_run_twice(self):
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
107 """Tests whether PBuilder.init_pbuilder prints an error when run twice.
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
108 """
185
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 183
diff changeset
109 basedir = self.create_temp_dir("pbuilder")
170
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
110
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
111 # run it once
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
112 pbuilderrc = os.path.join(basedir, "pbuilderrc")
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
113 builder = PBuilder(pbuilderrc, self.root_command)
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
114 old_stdout = sys.stdout
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
115 sys.stdout = captured_stdout = StringIO.StringIO()
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
116 try:
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
117 builder.init_pbuilder(distribution="etch",
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
118 mirrorsite="http://example.com/debian",
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
119 extramirrors=None)
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
120 finally:
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
121 sys.stdout = old_stdout
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
122
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
123 # running it again should not modify anything in the directory
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
124 # (which we don't check currently), it should print an error
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
125 # message and exit with exit code 1.
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
126 old_stderr = sys.stderr
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
127 sys.stderr = captured_stderr = StringIO.StringIO()
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
128 try:
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
129 try:
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
130 builder.init_pbuilder(distribution="etch",
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
131 mirrorsite="http://example.com/debian",
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
132 extramirrors=None)
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
133 except SystemExit, exc:
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
134 self.assertEquals(exc.code, 1)
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
135 finally:
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
136 sys.stderr = old_stderr
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
137 self.assertEquals("pbuilderrc %r already exists.\n"
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
138 % os.path.join(basedir, "pbuilderrc"),
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
139 captured_stderr.getvalue())
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
140
178
b2fa3b0926d0 PBuilder: refactor the "pbuilder update" call into a separate method
Bernhard Herzog <bh@intevation.de>
parents: 176
diff changeset
141 def test_update(self):
b2fa3b0926d0 PBuilder: refactor the "pbuilder update" call into a separate method
Bernhard Herzog <bh@intevation.de>
parents: 176
diff changeset
142 """Tests the PBuilder.update method."""
b2fa3b0926d0 PBuilder: refactor the "pbuilder update" call into a separate method
Bernhard Herzog <bh@intevation.de>
parents: 176
diff changeset
143 builder = PBuilder("my_pbuilderrc", self.root_command)
b2fa3b0926d0 PBuilder: refactor the "pbuilder update" call into a separate method
Bernhard Herzog <bh@intevation.de>
parents: 176
diff changeset
144 builder.update()
b2fa3b0926d0 PBuilder: refactor the "pbuilder update" call into a separate method
Bernhard Herzog <bh@intevation.de>
parents: 176
diff changeset
145 self.check_command_line(['/usr/sbin/pbuilder', 'update',
b2fa3b0926d0 PBuilder: refactor the "pbuilder update" call into a separate method
Bernhard Herzog <bh@intevation.de>
parents: 176
diff changeset
146 '--configfile', 'my_pbuilderrc'])
170
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
147
118
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
148 def test_build(self):
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
149 """Tests the PBuilder.build method.
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
150 The test checks whether the build method creates the binary_dir
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
151 and then checks the arguments with which the root command is
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
152 called. The test is a little too strict because it expects a
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
153 specific order of the arguments even though the order of some of
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
154 the arguments doesn't matter.
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
155
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
156 A more thorough test of the build method is implicity done by
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
157 the packager tests.
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
158 """
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
159 binary_dir_name = self.temp_file_name("binary")
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
160 if os.path.exists(binary_dir_name):
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
161 os.rmdir(binary_dir_name)
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
162 # sanity check: the binary directory must not exist yet.
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
163 self.failIf(os.path.exists(binary_dir_name))
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
164
186
2622bf5ed5bd For log files, use a name under the test specific temp dir to avoid
Bernhard Herzog <bh@intevation.de>
parents: 185
diff changeset
165 logfilename = self.temp_file_name("the_logfile")
2622bf5ed5bd For log files, use a name under the test specific temp dir to avoid
Bernhard Herzog <bh@intevation.de>
parents: 185
diff changeset
166
118
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
167 builder = PBuilder("my_pbuilderrc", self.root_command)
186
2622bf5ed5bd For log files, use a name under the test specific temp dir to avoid
Bernhard Herzog <bh@intevation.de>
parents: 185
diff changeset
168 builder.build("my_dsc_file", binary_dir_name, logfilename)
118
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
169 self.check_command_line(['/usr/sbin/pbuilder', 'build',
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
170 '--configfile', 'my_pbuilderrc',
186
2622bf5ed5bd For log files, use a name under the test specific temp dir to avoid
Bernhard Herzog <bh@intevation.de>
parents: 185
diff changeset
171 '--logfile', logfilename,
118
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
172 '--buildresult', binary_dir_name,
171
c0ea6cbb0fd2 Add "--debbuildopts -b" to "pbuilder build" command line to stop
Bernhard Herzog <bh@intevation.de>
parents: 170
diff changeset
173 '--debbuildopts', '-b',
118
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
174 'my_dsc_file'])
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
175 self.failUnless(os.path.isdir(binary_dir_name))
119
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
176
122
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
177 def test_build_with_bindmounts(self):
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
178 """Tests the PBuilder.build method with the bindmounts parameter"""
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
179 binary_dir_name = self.temp_file_name("binary")
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
180 if os.path.exists(binary_dir_name):
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
181 os.rmdir(binary_dir_name)
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
182 # sanity check: the binary directory must not exist yet.
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
183 self.failIf(os.path.exists(binary_dir_name))
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
184
186
2622bf5ed5bd For log files, use a name under the test specific temp dir to avoid
Bernhard Herzog <bh@intevation.de>
parents: 185
diff changeset
185 logfilename = self.temp_file_name("the_logfile")
2622bf5ed5bd For log files, use a name under the test specific temp dir to avoid
Bernhard Herzog <bh@intevation.de>
parents: 185
diff changeset
186
122
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
187 builder = PBuilder("my_pbuilderrc", self.root_command)
186
2622bf5ed5bd For log files, use a name under the test specific temp dir to avoid
Bernhard Herzog <bh@intevation.de>
parents: 185
diff changeset
188 builder.build("my_dsc_file", binary_dir_name, logfilename,
122
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
189 bindmounts=["/home/builder/tracks",
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
190 "/home/builder/pbuilder"])
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
191 self.check_command_line(['/usr/sbin/pbuilder', 'build',
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
192 '--configfile', 'my_pbuilderrc',
209
cbcd8f549ff7 Make logfile and binary_dir parameters of PBuilder.build optional.
Bernhard Herzog <bh@intevation.de>
parents: 195
diff changeset
193 '--logfile', logfilename,
cbcd8f549ff7 Make logfile and binary_dir parameters of PBuilder.build optional.
Bernhard Herzog <bh@intevation.de>
parents: 195
diff changeset
194 '--buildresult', binary_dir_name,
122
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
195 '--bindmounts', "/home/builder/tracks",
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
196 '--bindmounts', "/home/builder/pbuilder",
171
c0ea6cbb0fd2 Add "--debbuildopts -b" to "pbuilder build" command line to stop
Bernhard Herzog <bh@intevation.de>
parents: 170
diff changeset
197 '--debbuildopts', '-b',
122
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
198 'my_dsc_file'])
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
199 self.failUnless(os.path.isdir(binary_dir_name))
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
200
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
201 def test_build_with_extra_packages(self):
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
202 """Tests the PBuilder.build method with the extra_packages parameter"""
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
203 binary_dir_name = self.temp_file_name("binary")
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
204 if os.path.exists(binary_dir_name):
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
205 os.rmdir(binary_dir_name)
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
206 # sanity check: the binary directory must not exist yet.
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
207 self.failIf(os.path.exists(binary_dir_name))
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
208
186
2622bf5ed5bd For log files, use a name under the test specific temp dir to avoid
Bernhard Herzog <bh@intevation.de>
parents: 185
diff changeset
209 logfilename = self.temp_file_name("the_logfile")
2622bf5ed5bd For log files, use a name under the test specific temp dir to avoid
Bernhard Herzog <bh@intevation.de>
parents: 185
diff changeset
210
122
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
211 builder = PBuilder("my_pbuilderrc", self.root_command)
186
2622bf5ed5bd For log files, use a name under the test specific temp dir to avoid
Bernhard Herzog <bh@intevation.de>
parents: 185
diff changeset
212 builder.build("my_dsc_file", binary_dir_name, logfilename,
122
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
213 extra_packages=["subversion", "texinfo"])
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
214 self.check_command_line(['/usr/sbin/pbuilder', 'build',
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
215 '--configfile', 'my_pbuilderrc',
209
cbcd8f549ff7 Make logfile and binary_dir parameters of PBuilder.build optional.
Bernhard Herzog <bh@intevation.de>
parents: 195
diff changeset
216 '--logfile', logfilename,
cbcd8f549ff7 Make logfile and binary_dir parameters of PBuilder.build optional.
Bernhard Herzog <bh@intevation.de>
parents: 195
diff changeset
217 '--buildresult', binary_dir_name,
122
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
218 '--extrapackages', "subversion",
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
219 '--extrapackages', "texinfo",
171
c0ea6cbb0fd2 Add "--debbuildopts -b" to "pbuilder build" command line to stop
Bernhard Herzog <bh@intevation.de>
parents: 170
diff changeset
220 '--debbuildopts', '-b',
122
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
221 'my_dsc_file'])
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
222 self.failUnless(os.path.isdir(binary_dir_name))
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
223
126
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
224 def test_build_with_extra_env(self):
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
225 """Tests the PBuilder.build method with the extra_env parameter"""
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
226 binary_dir_name = self.temp_file_name("binary")
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
227 if os.path.exists(binary_dir_name):
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
228 os.rmdir(binary_dir_name)
185
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 183
diff changeset
229 env_test_file = self.temp_file_name("envtest")
126
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
230 # sanity check: the binary directory must not exist yet.
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
231 self.failIf(os.path.exists(binary_dir_name))
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
232 # sanity check: the environment variable TREEPKG_TEST must not
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
233 # be set yet
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
234 self.failIf("TREEPKG_TEST" in os.environ)
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
235
186
2622bf5ed5bd For log files, use a name under the test specific temp dir to avoid
Bernhard Herzog <bh@intevation.de>
parents: 185
diff changeset
236 logfilename = self.temp_file_name("the_logfile")
2622bf5ed5bd For log files, use a name under the test specific temp dir to avoid
Bernhard Herzog <bh@intevation.de>
parents: 185
diff changeset
237
126
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
238 builder = PBuilder("my_pbuilderrc", self.root_command)
186
2622bf5ed5bd For log files, use a name under the test specific temp dir to avoid
Bernhard Herzog <bh@intevation.de>
parents: 185
diff changeset
239 builder.build("my_dsc_file", binary_dir_name, logfilename,
126
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
240 extra_env=dict(TREEPKG_TEST=env_test_file))
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
241 self.check_command_line(['/usr/sbin/pbuilder', 'build',
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
242 '--configfile', 'my_pbuilderrc',
186
2622bf5ed5bd For log files, use a name under the test specific temp dir to avoid
Bernhard Herzog <bh@intevation.de>
parents: 185
diff changeset
243 '--logfile', logfilename,
126
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
244 '--buildresult', binary_dir_name,
171
c0ea6cbb0fd2 Add "--debbuildopts -b" to "pbuilder build" command line to stop
Bernhard Herzog <bh@intevation.de>
parents: 170
diff changeset
245 '--debbuildopts', '-b',
126
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
246 'my_dsc_file'])
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
247 self.failUnless(os.path.isdir(binary_dir_name))
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
248 self.failUnless(os.path.exists(env_test_file))
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
249
119
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
250 def test_run_script(self):
186
2622bf5ed5bd For log files, use a name under the test specific temp dir to avoid
Bernhard Herzog <bh@intevation.de>
parents: 185
diff changeset
251 logfilename = self.temp_file_name("the_logfile")
119
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
252 builder = PBuilder("my_pbuilderrc", self.root_command)
186
2622bf5ed5bd For log files, use a name under the test specific temp dir to avoid
Bernhard Herzog <bh@intevation.de>
parents: 185
diff changeset
253 builder.run_script(["my_script"], logfile=logfilename)
119
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
254 self.check_command_line(['/usr/sbin/pbuilder', 'execute',
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
255 '--configfile', 'my_pbuilderrc',
186
2622bf5ed5bd For log files, use a name under the test specific temp dir to avoid
Bernhard Herzog <bh@intevation.de>
parents: 185
diff changeset
256 '--logfile', logfilename, '--',
119
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
257 'my_script'])
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
258
181
81585486281b Extend the PBuilder.run_script method so that the script can be called
Bernhard Herzog <bh@intevation.de>
parents: 178
diff changeset
259 def test_run_script_with_arguments(self):
186
2622bf5ed5bd For log files, use a name under the test specific temp dir to avoid
Bernhard Herzog <bh@intevation.de>
parents: 185
diff changeset
260 logfilename = self.temp_file_name("the_logfile")
181
81585486281b Extend the PBuilder.run_script method so that the script can be called
Bernhard Herzog <bh@intevation.de>
parents: 178
diff changeset
261 builder = PBuilder("my_pbuilderrc", self.root_command)
186
2622bf5ed5bd For log files, use a name under the test specific temp dir to avoid
Bernhard Herzog <bh@intevation.de>
parents: 185
diff changeset
262 builder.run_script(["my_script", "--verbose"], logfile=logfilename)
181
81585486281b Extend the PBuilder.run_script method so that the script can be called
Bernhard Herzog <bh@intevation.de>
parents: 178
diff changeset
263 self.check_command_line(['/usr/sbin/pbuilder', 'execute',
81585486281b Extend the PBuilder.run_script method so that the script can be called
Bernhard Herzog <bh@intevation.de>
parents: 178
diff changeset
264 '--configfile', 'my_pbuilderrc',
186
2622bf5ed5bd For log files, use a name under the test specific temp dir to avoid
Bernhard Herzog <bh@intevation.de>
parents: 185
diff changeset
265 '--logfile', logfilename, '--',
181
81585486281b Extend the PBuilder.run_script method so that the script can be called
Bernhard Herzog <bh@intevation.de>
parents: 178
diff changeset
266 'my_script', '--verbose'])
81585486281b Extend the PBuilder.run_script method so that the script can be called
Bernhard Herzog <bh@intevation.de>
parents: 178
diff changeset
267
119
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
268 def test_run_script_with_bindmounts(self):
186
2622bf5ed5bd For log files, use a name under the test specific temp dir to avoid
Bernhard Herzog <bh@intevation.de>
parents: 185
diff changeset
269 logfilename = self.temp_file_name("the_logfile")
119
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
270 builder = PBuilder("my_pbuilderrc", self.root_command)
186
2622bf5ed5bd For log files, use a name under the test specific temp dir to avoid
Bernhard Herzog <bh@intevation.de>
parents: 185
diff changeset
271 builder.run_script(["my_script"], logfile=logfilename,
119
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
272 bindmounts=("/home/builder/foo",
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
273 "/home/builder/treepkg"))
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
274 self.check_command_line(['/usr/sbin/pbuilder', 'execute',
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
275 '--configfile', 'my_pbuilderrc',
186
2622bf5ed5bd For log files, use a name under the test specific temp dir to avoid
Bernhard Herzog <bh@intevation.de>
parents: 185
diff changeset
276 '--logfile', logfilename,
119
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
277 '--bindmounts', '/home/builder/foo',
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
278 '--bindmounts', '/home/builder/treepkg',
183
72e41b27f224 Add test case for the save_after_exec parameter and adapt the other
Bernhard Herzog <bh@intevation.de>
parents: 181
diff changeset
279 '--', 'my_script'])
72e41b27f224 Add test case for the save_after_exec parameter and adapt the other
Bernhard Herzog <bh@intevation.de>
parents: 181
diff changeset
280
72e41b27f224 Add test case for the save_after_exec parameter and adapt the other
Bernhard Herzog <bh@intevation.de>
parents: 181
diff changeset
281 def test_run_script_save_after_exec(self):
186
2622bf5ed5bd For log files, use a name under the test specific temp dir to avoid
Bernhard Herzog <bh@intevation.de>
parents: 185
diff changeset
282 logfilename = self.temp_file_name("the_logfile")
183
72e41b27f224 Add test case for the save_after_exec parameter and adapt the other
Bernhard Herzog <bh@intevation.de>
parents: 181
diff changeset
283 builder = PBuilder("my_pbuilderrc", self.root_command)
186
2622bf5ed5bd For log files, use a name under the test specific temp dir to avoid
Bernhard Herzog <bh@intevation.de>
parents: 185
diff changeset
284 builder.run_script(["my_script", "--verbose"], logfilename,
183
72e41b27f224 Add test case for the save_after_exec parameter and adapt the other
Bernhard Herzog <bh@intevation.de>
parents: 181
diff changeset
285 save_after_exec=True)
72e41b27f224 Add test case for the save_after_exec parameter and adapt the other
Bernhard Herzog <bh@intevation.de>
parents: 181
diff changeset
286 self.check_command_line(['/usr/sbin/pbuilder', 'execute',
72e41b27f224 Add test case for the save_after_exec parameter and adapt the other
Bernhard Herzog <bh@intevation.de>
parents: 181
diff changeset
287 '--configfile', 'my_pbuilderrc',
186
2622bf5ed5bd For log files, use a name under the test specific temp dir to avoid
Bernhard Herzog <bh@intevation.de>
parents: 185
diff changeset
288 '--logfile', logfilename,
183
72e41b27f224 Add test case for the save_after_exec parameter and adapt the other
Bernhard Herzog <bh@intevation.de>
parents: 181
diff changeset
289 '--save-after-exec', '--',
72e41b27f224 Add test case for the save_after_exec parameter and adapt the other
Bernhard Herzog <bh@intevation.de>
parents: 181
diff changeset
290 'my_script', '--verbose'])
121
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
291
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
292
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
293 class TestPBuilderWithBinaryPackage(PBuilderTests):
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
294
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
295 minimal_package = [
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
296 ("debian",
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
297 [("control", """\
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
298 Source: minimal
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
299 Section: utils
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
300 Priority: optional
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
301 Maintainer: Bernhard Herzog <bh@intevation.de>
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
302 Standards-Version: 3.7.2.2
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
303 Build-Depends: debhelper
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
304
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
305 Package: minimal
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
306 Architecture: any
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
307 Depends: ${shlibs:Depends}
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
308 Description: Minimal package for test purposes
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
309 """),
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
310 ("rules", 0755, """\
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
311 #!/usr/bin/make -f
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
312
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
313 build: build-stamp
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
314 build-stamp:
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
315 dh_testdir
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
316 touch build-stamp
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
317
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
318 clean:
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
319 dh_testdir
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
320 dh_testroot
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
321 rm -f build-stamp
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
322 dh_clean
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
323
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
324 # Build architecture-dependent files here.
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
325 binary-arch:
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
326 dh_testdir
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
327 dh_testroot
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
328 dh_installdocs README
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
329 dh_installchangelogs
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
330 dh_fixperms
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
331 dh_installdeb
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
332 dh_gencontrol
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
333 dh_md5sums
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
334 dh_builddeb
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
335
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
336 binary: binary-arch
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
337 .PHONY: build build-stamp clean binary-arch binary
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
338 """),
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
339 ("changelog", """\
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
340 minimal (1.0-1) unstable; urgency=low
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
341
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
342 * Newly packaged
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
343
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
344 -- Bernhard Herzog <bh@intevation.de> Wed, 21 May 2008 16:10:29 +0200
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
345 """)]),
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
346 ("README", """\
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
347 This is a minimal debian package for test purposes
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
348 """),
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
349 ]
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
350
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
351 pbuilder_files = [("pbuilderrc", ""),
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
352 ("extra-pkg", [])]
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
353
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
354 def setUp(self):
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
355 PBuilderTests.setUp(self)
185
e1c7cd896310 Rework test/filesupport.py so that test cases always use their own
Bernhard Herzog <bh@intevation.de>
parents: 183
diff changeset
356 self.temp_base_dir = self.create_temp_dir("pbuilder")
121
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
357 self.minimal_packge_dir = os.path.join(self.temp_base_dir,
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
358 "minimal-1.0")
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
359 self.create_files(self.minimal_packge_dir, self.minimal_package)
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
360 call(["dpkg-buildpackage", "-rfakeroot", "-b", "-uc"],
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
361 cwd=self.minimal_packge_dir, suppress_output=True)
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
362 self.minimal_package_deb = os.path.join(self.temp_base_dir,
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
363 "minimal_1.0-1_i386.deb")
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
364 self.pbuilder_basedir = os.path.join(self.temp_base_dir, "pbuilder")
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
365 self.create_files(self.pbuilder_basedir, self.pbuilder_files)
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
366 self.extra_pkg_dir = os.path.join(self.pbuilder_basedir, "extra-pkg")
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
367 self.pbuilderrc = os.path.join(self.pbuilder_basedir, "pbuilderrc")
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
368
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
369 def test_add_binaries_to_extra_pkg(self):
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
370 """Tests the PBuilder.add_binaries_to_extra_pkg method"""
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
371 builder = PBuilder(self.pbuilderrc, self.root_command)
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
372 # sanity check: the extra-pkg directory should be empty now
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
373 self.assertEquals(os.listdir(self.extra_pkg_dir), [])
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
374
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
375 builder.add_binaries_to_extra_pkg([self.minimal_package_deb])
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
376
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
377 self.assertEquals(sorted(os.listdir(self.extra_pkg_dir)),
176
7bde59aa611e Make PBuilder.update_extra_pkg_dir create Release and Release.gpg files
Bernhard Herzog <bh@intevation.de>
parents: 173
diff changeset
378 ["Packages", "Release", "minimal_1.0-1_i386.deb"])
121
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
379 self.check_command_line(['/usr/sbin/pbuilder', 'update',
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
380 '--configfile', self.pbuilderrc])
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)