annotate test/test_builder.py @ 124:e08b4b09d35f

New parameter treepkg.run.call: extra_env for additional environment variables passed to the subprocess. Also add a test case.
author Bernhard Herzog <bh@intevation.de>
date Thu, 22 May 2008 12:44:43 +0000
parents 6e34fc4ebe39
children 68d829cac3ff
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
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
13
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
14 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
15 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
16
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
17 from filesupport import FileTestMixin
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
18
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
19 # helper program to dump the command line arguments into a file so that
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
20 # test cases can check them.
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
21 dump_command_line_py = """
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
22 import sys
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
23 open(sys.argv[1], 'w').write(repr(sys.argv[2:]))
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
24 """
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
25
121
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
26 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
27
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
28 def setUp(self):
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
29 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
30 dump_command_line_py)
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
31 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
32 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
33 self.command_line_file]
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
34
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
35 def check_command_line(self, args):
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
36 self.checkFileContents(self.command_line_file, repr(args))
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
37
121
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
38
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
39 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
40
118
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
41 def test_build(self):
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
42 """Tests the PBuilder.build method.
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
43 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
44 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
45 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
46 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
47 the arguments doesn't matter.
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
48
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
49 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
50 the packager tests.
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
51 """
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
52 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
53 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
54 os.rmdir(binary_dir_name)
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
55 # 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
56 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
57
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
58 builder = PBuilder("my_pbuilderrc", self.root_command)
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
59 builder.build("my_dsc_file", binary_dir_name, "the_logfile")
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
60 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
61 '--configfile', 'my_pbuilderrc',
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
62 '--logfile', 'the_logfile',
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
63 '--buildresult', binary_dir_name,
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
64 'my_dsc_file'])
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
65 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
66
122
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
67 def test_build_with_bindmounts(self):
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
68 """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
69 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
70 if os.path.exists(binary_dir_name):
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
71 os.rmdir(binary_dir_name)
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
72 # 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
73 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
74
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
75 builder = PBuilder("my_pbuilderrc", self.root_command)
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
76 builder.build("my_dsc_file", binary_dir_name, "the_logfile",
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
77 bindmounts=["/home/builder/tracks",
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
78 "/home/builder/pbuilder"])
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
79 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
80 '--configfile', 'my_pbuilderrc',
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
81 '--bindmounts', "/home/builder/tracks",
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
82 '--bindmounts', "/home/builder/pbuilder",
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
83 '--logfile', 'the_logfile',
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
84 '--buildresult', binary_dir_name,
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
85 'my_dsc_file'])
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
86 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
87
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
88 def test_build_with_extra_packages(self):
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
89 """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
90 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
91 if os.path.exists(binary_dir_name):
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
92 os.rmdir(binary_dir_name)
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
93 # 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
94 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
95
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
96 builder = PBuilder("my_pbuilderrc", self.root_command)
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
97 builder.build("my_dsc_file", binary_dir_name, "the_logfile",
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
98 extra_packages=["subversion", "texinfo"])
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
99 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
100 '--configfile', 'my_pbuilderrc',
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
101 '--extrapackages', "subversion",
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
102 '--extrapackages', "texinfo",
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
103 '--logfile', 'the_logfile',
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
104 '--buildresult', binary_dir_name,
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
105 'my_dsc_file'])
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
106 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
107
119
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
108 def test_run_script(self):
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
109 builder = PBuilder("my_pbuilderrc", self.root_command)
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
110 builder.run_script("my_script", logfile="the_logfile")
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
111 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
112 '--configfile', 'my_pbuilderrc',
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
113 '--logfile', 'the_logfile',
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
114 'my_script'])
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
115
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
116 def test_run_script_with_bindmounts(self):
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
117 builder = PBuilder("my_pbuilderrc", self.root_command)
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
118 builder.run_script("my_script", logfile="the_logfile",
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
119 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
120 "/home/builder/treepkg"))
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
121 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
122 '--configfile', 'my_pbuilderrc',
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
123 '--logfile', 'the_logfile',
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
124 '--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
125 '--bindmounts', '/home/builder/treepkg',
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
126 'my_script'])
121
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
127
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
128
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
129 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
130
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
131 minimal_package = [
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
132 ("debian",
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
133 [("control", """\
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
134 Source: minimal
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
135 Section: utils
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
136 Priority: optional
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
137 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
138 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
139 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
140
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
141 Package: minimal
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
142 Architecture: any
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
143 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
144 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
145 """),
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
146 ("rules", 0755, """\
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
147 #!/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
148
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
149 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
150 build-stamp:
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
151 dh_testdir
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
152 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
153
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
154 clean:
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
155 dh_testdir
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
156 dh_testroot
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
157 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
158 dh_clean
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
159
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
160 # 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
161 binary-arch:
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
162 dh_testdir
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
163 dh_testroot
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
164 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
165 dh_installchangelogs
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
166 dh_fixperms
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
167 dh_installdeb
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
168 dh_gencontrol
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
169 dh_md5sums
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
170 dh_builddeb
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
171
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
172 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
173 .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
174 """),
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
175 ("changelog", """\
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
176 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
177
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
178 * Newly packaged
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
179
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
180 -- 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
181 """)]),
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
182 ("README", """\
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
183 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
184 """),
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
185 ]
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
186
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
187 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
188 ("extra-pkg", [])]
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
189
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
190 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
191 PBuilderTests.setUp(self)
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
192 self.temp_base_dir = self.create_temp_dir(self.id())
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
193 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
194 "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
195 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
196 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
197 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
198 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
199 "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
200 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
201 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
202 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
203 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
204
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
205 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
206 """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
207 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
208 # 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
209 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
210
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
211 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
212
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
213 self.assertEquals(sorted(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
214 ["Packages", "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
215 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
216 '--configfile', self.pbuilderrc])
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)