Merge lp:~cjwatson/launchpad-buildd/is-package-available-virtual into lp:launchpad-buildd

Proposed by Colin Watson
Status: Merged
Merged at revision: 302
Proposed branch: lp:~cjwatson/launchpad-buildd/is-package-available-virtual
Merge into: lp:launchpad-buildd
Diff against target: 91 lines (+21/-7)
4 files modified
debian/changelog (+2/-0)
lpbuildd/target/backend.py (+3/-3)
lpbuildd/target/tests/test_chroot.py (+8/-2)
lpbuildd/target/tests/test_lxd.py (+8/-2)
To merge this branch: bzr merge lp:~cjwatson/launchpad-buildd/is-package-available-virtual
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+333104@code.launchpad.net

Commit message

Make Backend.is_package_available handle the case where the requested
package name is purely virtual.

To post a comment you must log in.
303. By Colin Watson

Don't assume that Package: is the first line.

Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2017-11-01 11:17:44 +0000
3+++ debian/changelog 2017-11-01 23:08:33 +0000
4@@ -12,6 +12,8 @@
5 * Raise more useful exceptions when LXD.copy_in or LXD.copy_out fail.
6 * Make Backend.run implementations print command output if echo and
7 get_output are both true.
8+ * Make Backend.is_package_available handle the case where the requested
9+ package name is purely virtual.
10
11 -- Colin Watson <cjwatson@ubuntu.com> Fri, 08 Sep 2017 13:42:17 +0100
12
13
14=== modified file 'lpbuildd/target/backend.py'
15--- lpbuildd/target/backend.py 2017-11-01 11:17:44 +0000
16+++ lpbuildd/target/backend.py 2017-11-01 23:08:33 +0000
17@@ -152,10 +152,10 @@
18 """
19 try:
20 with open("/dev/null", "w") as devnull:
21- self.run(
22+ output = self.run(
23 ["apt-cache", "show", package],
24- stdout=devnull, stderr=devnull)
25- return True
26+ get_output=True, stderr=devnull)
27+ return ("Package: %s" % package) in output.splitlines()
28 except subprocess.CalledProcessError:
29 return False
30
31
32=== modified file 'lpbuildd/target/tests/test_chroot.py'
33--- lpbuildd/target/tests/test_chroot.py 2017-09-08 15:57:18 +0000
34+++ lpbuildd/target/tests/test_chroot.py 2017-11-01 23:08:33 +0000
35@@ -271,18 +271,24 @@
36 def test_is_package_available(self):
37 self.useFixture(EnvironmentVariable("HOME", "/expected/home"))
38 processes_fixture = self.useFixture(FakeProcesses())
39- test_proc_infos = iter([{}, {"returncode": 100}])
40+ test_proc_infos = iter([
41+ {"stdout": io.BytesIO(b"Package: snapd\n")},
42+ {"returncode": 100},
43+ {"stderr": io.BytesIO(b"N: No packages found\n")},
44+ ])
45 processes_fixture.add(lambda _: next(test_proc_infos), name="sudo")
46 self.assertTrue(
47 Chroot("1", "xenial", "amd64").is_package_available("snapd"))
48 self.assertFalse(
49 Chroot("1", "xenial", "amd64").is_package_available("nonexistent"))
50+ self.assertFalse(
51+ Chroot("1", "xenial", "amd64").is_package_available("virtual"))
52
53 expected_args = [
54 ["sudo", "/usr/sbin/chroot",
55 "/expected/home/build-1/chroot-autobuild",
56 "linux64", "apt-cache", "show", package]
57- for package in ("snapd", "nonexistent")
58+ for package in ("snapd", "nonexistent", "virtual")
59 ]
60 self.assertEqual(
61 expected_args,
62
63=== modified file 'lpbuildd/target/tests/test_lxd.py'
64--- lpbuildd/target/tests/test_lxd.py 2017-11-01 11:13:36 +0000
65+++ lpbuildd/target/tests/test_lxd.py 2017-11-01 23:08:33 +0000
66@@ -593,17 +593,23 @@
67
68 def test_is_package_available(self):
69 processes_fixture = self.useFixture(FakeProcesses())
70- test_proc_infos = iter([{}, {"returncode": 100}])
71+ test_proc_infos = iter([
72+ {"stdout": io.BytesIO(b"Package: snapd\n")},
73+ {"returncode": 100},
74+ {"stderr": io.BytesIO(b"N: No packages found\n")},
75+ ])
76 processes_fixture.add(lambda _: next(test_proc_infos), name="lxc")
77 self.assertTrue(
78 LXD("1", "xenial", "amd64").is_package_available("snapd"))
79 self.assertFalse(
80 LXD("1", "xenial", "amd64").is_package_available("nonexistent"))
81+ self.assertFalse(
82+ LXD("1", "xenial", "amd64").is_package_available("virtual"))
83
84 expected_args = [
85 ["lxc", "exec", "lp-xenial-amd64", "--",
86 "linux64", "apt-cache", "show", package]
87- for package in ("snapd", "nonexistent")
88+ for package in ("snapd", "nonexistent", "virtual")
89 ]
90 self.assertEqual(
91 expected_args,

Subscribers

People subscribed via source and target branches

to all changes: