annotate test/test_builder.py @ 177:df7498d0bd9d

Add bin/treepkgbuilder.py, a script to manage treepkg's pbuilder instance
author Bernhard Herzog <bh@intevation.de>
date Tue, 24 Jun 2008 17:52:14 +0000
parents 7bde59aa611e
children b2fa3b0926d0
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):
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
41 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
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."""
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
48 basedir = self.create_temp_dir(self.id())
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())
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
88 self.checkFileContents(pbuilderrc, pbuilderrc_contents)
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.
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
91 self.checkFileContents(os.path.join(basedir, "extra-pkg", "Packages"),
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
92 "")
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 """
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
109 basedir = self.create_temp_dir(self.id())
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
bfcb2bbf9a52 Move the pbuilder initialization code from bin/initpbuilder.py to
Bernhard Herzog <bh@intevation.de>
parents: 126
diff changeset
141
118
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
142 def test_build(self):
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
143 """Tests the PBuilder.build method.
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
144 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
145 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
146 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
147 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
148 the arguments doesn't matter.
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
149
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
150 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
151 the packager tests.
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
152 """
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
153 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
154 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
155 os.rmdir(binary_dir_name)
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
156 # 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
157 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
158
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
159 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
160 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
161 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
162 '--configfile', 'my_pbuilderrc',
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
163 '--logfile', 'the_logfile',
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
164 '--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
165 '--debbuildopts', '-b',
118
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
166 'my_dsc_file'])
9d59ed0e3116 Add test/test_builder.py with tests for treepkg.builder
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
167 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
168
122
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
169 def test_build_with_bindmounts(self):
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
170 """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
171 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
172 if os.path.exists(binary_dir_name):
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
173 os.rmdir(binary_dir_name)
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
174 # 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
175 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
176
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
177 builder = PBuilder("my_pbuilderrc", self.root_command)
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
178 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
179 bindmounts=["/home/builder/tracks",
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
180 "/home/builder/pbuilder"])
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
181 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
182 '--configfile', 'my_pbuilderrc',
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
183 '--bindmounts', "/home/builder/tracks",
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
184 '--bindmounts', "/home/builder/pbuilder",
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
185 '--logfile', 'the_logfile',
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
186 '--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
187 '--debbuildopts', '-b',
122
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
188 'my_dsc_file'])
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
189 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
190
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
191 def test_build_with_extra_packages(self):
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
192 """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
193 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
194 if os.path.exists(binary_dir_name):
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
195 os.rmdir(binary_dir_name)
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
196 # 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
197 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
198
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
199 builder = PBuilder("my_pbuilderrc", self.root_command)
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
200 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
201 extra_packages=["subversion", "texinfo"])
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
202 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
203 '--configfile', 'my_pbuilderrc',
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
204 '--extrapackages', "subversion",
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
205 '--extrapackages', "texinfo",
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
206 '--logfile', 'the_logfile',
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
207 '--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
208 '--debbuildopts', '-b',
122
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
209 'my_dsc_file'])
6e34fc4ebe39 New arguments for the PBuilder.build method:
Bernhard Herzog <bh@intevation.de>
parents: 121
diff changeset
210 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
211
126
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
212 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
213 """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
214 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
215 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
216 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
217 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
218 # 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
219 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
220 # 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
221 # be set yet
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
222 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
223
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
224 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
225 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
226 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
227 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
228 '--configfile', 'my_pbuilderrc',
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
229 '--logfile', 'the_logfile',
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
230 '--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
231 '--debbuildopts', '-b',
126
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
232 'my_dsc_file'])
68d829cac3ff New parameter for PBuilder.build: extra_env, a mapping with extra
Bernhard Herzog <bh@intevation.de>
parents: 122
diff changeset
233 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
234 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
235
119
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
236 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
237 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
238 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
239 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
240 '--configfile', 'my_pbuilderrc',
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
241 '--logfile', 'the_logfile',
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
242 'my_script'])
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
243
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
244 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
245 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
246 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
247 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
248 "/home/builder/treepkg"))
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
249 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
250 '--configfile', 'my_pbuilderrc',
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
251 '--logfile', 'the_logfile',
92116333ef77 Add PBuilder.run_script method and associated tests. The run_script
Bernhard Herzog <bh@intevation.de>
parents: 118
diff changeset
252 '--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
253 '--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
254 '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
255
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
256
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
257 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
258
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
259 minimal_package = [
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
260 ("debian",
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
261 [("control", """\
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
262 Source: minimal
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
263 Section: utils
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
264 Priority: optional
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
265 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
266 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
267 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
268
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
269 Package: minimal
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
270 Architecture: any
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
271 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
272 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
273 """),
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
274 ("rules", 0755, """\
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
275 #!/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
276
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
277 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
278 build-stamp:
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
279 dh_testdir
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
280 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
281
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
282 clean:
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
283 dh_testdir
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
284 dh_testroot
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
285 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
286 dh_clean
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
287
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
288 # 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
289 binary-arch:
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
290 dh_testdir
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
291 dh_testroot
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
292 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
293 dh_installchangelogs
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
294 dh_fixperms
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
295 dh_installdeb
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
296 dh_gencontrol
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
297 dh_md5sums
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
298 dh_builddeb
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
299
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
300 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
301 .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
302 """),
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
303 ("changelog", """\
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
304 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
305
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
306 * Newly packaged
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
307
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
308 -- 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
309 """)]),
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
310 ("README", """\
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
311 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
312 """),
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
313 ]
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
314
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
315 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
316 ("extra-pkg", [])]
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 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
319 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
320 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
321 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
322 "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
323 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
324 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
325 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
326 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
327 "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
328 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
329 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
330 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
331 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
332
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
333 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
334 """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
335 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
336 # 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
337 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
338
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
339 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
340
890bb70920d6 Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
Bernhard Herzog <bh@intevation.de>
parents: 119
diff changeset
341 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
342 ["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
343 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
344 '--configfile', self.pbuilderrc])
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)