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
=== modified file 'debian/changelog'
--- debian/changelog 2017-11-01 11:17:44 +0000
+++ debian/changelog 2017-11-01 23:08:33 +0000
@@ -12,6 +12,8 @@
12 * Raise more useful exceptions when LXD.copy_in or LXD.copy_out fail.12 * Raise more useful exceptions when LXD.copy_in or LXD.copy_out fail.
13 * Make Backend.run implementations print command output if echo and13 * Make Backend.run implementations print command output if echo and
14 get_output are both true.14 get_output are both true.
15 * Make Backend.is_package_available handle the case where the requested
16 package name is purely virtual.
1517
16 -- Colin Watson <cjwatson@ubuntu.com> Fri, 08 Sep 2017 13:42:17 +010018 -- Colin Watson <cjwatson@ubuntu.com> Fri, 08 Sep 2017 13:42:17 +0100
1719
1820
=== modified file 'lpbuildd/target/backend.py'
--- lpbuildd/target/backend.py 2017-11-01 11:17:44 +0000
+++ lpbuildd/target/backend.py 2017-11-01 23:08:33 +0000
@@ -152,10 +152,10 @@
152 """152 """
153 try:153 try:
154 with open("/dev/null", "w") as devnull:154 with open("/dev/null", "w") as devnull:
155 self.run(155 output = self.run(
156 ["apt-cache", "show", package],156 ["apt-cache", "show", package],
157 stdout=devnull, stderr=devnull)157 get_output=True, stderr=devnull)
158 return True158 return ("Package: %s" % package) in output.splitlines()
159 except subprocess.CalledProcessError:159 except subprocess.CalledProcessError:
160 return False160 return False
161161
162162
=== modified file 'lpbuildd/target/tests/test_chroot.py'
--- lpbuildd/target/tests/test_chroot.py 2017-09-08 15:57:18 +0000
+++ lpbuildd/target/tests/test_chroot.py 2017-11-01 23:08:33 +0000
@@ -271,18 +271,24 @@
271 def test_is_package_available(self):271 def test_is_package_available(self):
272 self.useFixture(EnvironmentVariable("HOME", "/expected/home"))272 self.useFixture(EnvironmentVariable("HOME", "/expected/home"))
273 processes_fixture = self.useFixture(FakeProcesses())273 processes_fixture = self.useFixture(FakeProcesses())
274 test_proc_infos = iter([{}, {"returncode": 100}])274 test_proc_infos = iter([
275 {"stdout": io.BytesIO(b"Package: snapd\n")},
276 {"returncode": 100},
277 {"stderr": io.BytesIO(b"N: No packages found\n")},
278 ])
275 processes_fixture.add(lambda _: next(test_proc_infos), name="sudo")279 processes_fixture.add(lambda _: next(test_proc_infos), name="sudo")
276 self.assertTrue(280 self.assertTrue(
277 Chroot("1", "xenial", "amd64").is_package_available("snapd"))281 Chroot("1", "xenial", "amd64").is_package_available("snapd"))
278 self.assertFalse(282 self.assertFalse(
279 Chroot("1", "xenial", "amd64").is_package_available("nonexistent"))283 Chroot("1", "xenial", "amd64").is_package_available("nonexistent"))
284 self.assertFalse(
285 Chroot("1", "xenial", "amd64").is_package_available("virtual"))
280286
281 expected_args = [287 expected_args = [
282 ["sudo", "/usr/sbin/chroot",288 ["sudo", "/usr/sbin/chroot",
283 "/expected/home/build-1/chroot-autobuild",289 "/expected/home/build-1/chroot-autobuild",
284 "linux64", "apt-cache", "show", package]290 "linux64", "apt-cache", "show", package]
285 for package in ("snapd", "nonexistent")291 for package in ("snapd", "nonexistent", "virtual")
286 ]292 ]
287 self.assertEqual(293 self.assertEqual(
288 expected_args,294 expected_args,
289295
=== modified file 'lpbuildd/target/tests/test_lxd.py'
--- lpbuildd/target/tests/test_lxd.py 2017-11-01 11:13:36 +0000
+++ lpbuildd/target/tests/test_lxd.py 2017-11-01 23:08:33 +0000
@@ -593,17 +593,23 @@
593593
594 def test_is_package_available(self):594 def test_is_package_available(self):
595 processes_fixture = self.useFixture(FakeProcesses())595 processes_fixture = self.useFixture(FakeProcesses())
596 test_proc_infos = iter([{}, {"returncode": 100}])596 test_proc_infos = iter([
597 {"stdout": io.BytesIO(b"Package: snapd\n")},
598 {"returncode": 100},
599 {"stderr": io.BytesIO(b"N: No packages found\n")},
600 ])
597 processes_fixture.add(lambda _: next(test_proc_infos), name="lxc")601 processes_fixture.add(lambda _: next(test_proc_infos), name="lxc")
598 self.assertTrue(602 self.assertTrue(
599 LXD("1", "xenial", "amd64").is_package_available("snapd"))603 LXD("1", "xenial", "amd64").is_package_available("snapd"))
600 self.assertFalse(604 self.assertFalse(
601 LXD("1", "xenial", "amd64").is_package_available("nonexistent"))605 LXD("1", "xenial", "amd64").is_package_available("nonexistent"))
606 self.assertFalse(
607 LXD("1", "xenial", "amd64").is_package_available("virtual"))
602608
603 expected_args = [609 expected_args = [
604 ["lxc", "exec", "lp-xenial-amd64", "--",610 ["lxc", "exec", "lp-xenial-amd64", "--",
605 "linux64", "apt-cache", "show", package]611 "linux64", "apt-cache", "show", package]
606 for package in ("snapd", "nonexistent")612 for package in ("snapd", "nonexistent", "virtual")
607 ]613 ]
608 self.assertEqual(614 self.assertEqual(
609 expected_args,615 expected_args,

Subscribers

People subscribed via source and target branches

to all changes: