annotate test/test_builder.py @ 131:bea9f1cc0bef

Try to determine dependencies only when treepkg is fully configured. That is, don't try to parse debian/control if the debian directory does not exist, a situation that most likely happens when running bin/inittreepkg.py to configure the tree packager instance.
author Bernhard Herzog <bh@intevation.de>
date Fri, 23 May 2008 17:44:15 +0000
parents 68d829cac3ff
children bfcb2bbf9a52
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
126
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
20 # 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
21 # 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
22 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
23 import sys, os
118
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
24 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
25 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
26 if value:
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
27 open(value, 'w').close()
118
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
28 """
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
29
121
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
30 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
31
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
32 def setUp(self):
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
33 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
34 dump_command_line_py)
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
35 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
36 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
37 self.command_line_file]
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
38
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
39 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
40 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
41
121
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
42
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
43 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
44
118
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
45 def test_build(self):
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
46 """Tests the PBuilder.build method.
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
47 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
48 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
49 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
50 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
51 the arguments doesn't matter.
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
52
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
53 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
54 the packager tests.
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
55 """
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
56 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
57 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
58 os.rmdir(binary_dir_name)
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
59 # 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
60 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
61
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
62 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
63 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
64 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
65 '--configfile', 'my_pbuilderrc',
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
66 '--logfile', 'the_logfile',
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
67 '--buildresult', binary_dir_name,
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
68 'my_dsc_file'])
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
69 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
70
122
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
71 def test_build_with_bindmounts(self):
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
72 """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
73 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
74 if os.path.exists(binary_dir_name):
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
75 os.rmdir(binary_dir_name)
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
76 # 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
77 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
78
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
79 builder = PBuilder("my_pbuilderrc", self.root_command)
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
80 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
81 bindmounts=["/home/builder/tracks",
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
82 "/home/builder/pbuilder"])
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
83 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
84 '--configfile', 'my_pbuilderrc',
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
85 '--bindmounts', "/home/builder/tracks",
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
86 '--bindmounts', "/home/builder/pbuilder",
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
87 '--logfile', 'the_logfile',
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
88 '--buildresult', binary_dir_name,
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
89 'my_dsc_file'])
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
90 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
91
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
92 def test_build_with_extra_packages(self):
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
93 """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
94 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
95 if os.path.exists(binary_dir_name):
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
96 os.rmdir(binary_dir_name)
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
97 # 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
98 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
99
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
100 builder = PBuilder("my_pbuilderrc", self.root_command)
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
101 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
102 extra_packages=["subversion", "texinfo"])
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
103 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
104 '--configfile', 'my_pbuilderrc',
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
105 '--extrapackages', "subversion",
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
106 '--extrapackages', "texinfo",
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
107 '--logfile', 'the_logfile',
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
108 '--buildresult', binary_dir_name,
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
109 'my_dsc_file'])
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
110 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
111
126
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
112 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
113 """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
114 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
115 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
116 os.rmdir(binary_dir_name)
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
117 env_test_file = self.temp_file_name(self.id() + "_envtest", remove=True)
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
118 # 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
119 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
120 # 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
121 # be set yet
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
122 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
123
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
124 builder = PBuilder("my_pbuilderrc", self.root_command)
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
125 builder.build("my_dsc_file", binary_dir_name, "the_logfile",
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
126 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
127 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
128 '--configfile', 'my_pbuilderrc',
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
129 '--logfile', 'the_logfile',
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
130 '--buildresult', binary_dir_name,
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
131 'my_dsc_file'])
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
132 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
133 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
134
119
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
135 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
136 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
137 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
138 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
139 '--configfile', 'my_pbuilderrc',
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
140 '--logfile', 'the_logfile',
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
141 'my_script'])
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
142
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
143 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
144 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
145 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
146 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
147 "/home/builder/treepkg"))
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
148 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
149 '--configfile', 'my_pbuilderrc',
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
150 '--logfile', 'the_logfile',
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
151 '--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
152 '--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
153 '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
154
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
155
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
156 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
157
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
158 minimal_package = [
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
159 ("debian",
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
160 [("control", """\
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
161 Source: minimal
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
162 Section: utils
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
163 Priority: optional
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
164 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
165 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
166 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
167
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
168 Package: minimal
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
169 Architecture: any
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
170 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
171 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
172 """),
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
173 ("rules", 0755, """\
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
174 #!/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
175
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
176 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
177 build-stamp:
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
178 dh_testdir
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
179 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
180
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
181 clean:
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
182 dh_testdir
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
183 dh_testroot
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
184 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
185 dh_clean
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 # 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
188 binary-arch:
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
189 dh_testdir
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
190 dh_testroot
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
191 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
192 dh_installchangelogs
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
193 dh_fixperms
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
194 dh_installdeb
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
195 dh_gencontrol
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
196 dh_md5sums
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
197 dh_builddeb
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
198
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
199 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
200 .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
201 """),
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
202 ("changelog", """\
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
203 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
204
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
205 * Newly packaged
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
206
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
207 -- 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
208 """)]),
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
209 ("README", """\
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
210 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
211 """),
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
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
214 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
215 ("extra-pkg", [])]
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
216
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
217 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
218 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
219 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
220 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
221 "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
222 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
223 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
224 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
225 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
226 "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
227 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
228 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
229 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
230 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
231
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
232 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
233 """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
234 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
235 # 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
236 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
237
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
238 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
239
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
240 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
241 ["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
242 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
243 '--configfile', self.pbuilderrc])
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)