[PATCH 1/3] autodetect Ruby packages
Antonio Terceiro
terceiro at debian.org
Mon Sep 8 00:06:05 UTC 2014
---
lib/testdesc.py | 28 ++++++++++++++++++++++++++++
tests/testdesc | 16 ++++++++++++++++
2 files changed, 44 insertions(+)
diff --git a/lib/testdesc.py b/lib/testdesc.py
index 8e49992..ffae057 100644
--- a/lib/testdesc.py
+++ b/lib/testdesc.py
@@ -313,6 +313,9 @@ def parse_debian_source(srcdir, testbed_caps, control_path=None):
else:
control_path = os.path.join(srcdir, 'debian', 'tests', 'control')
+ if not os.path.exists(control_path):
+ return autodetect_implicit_control(srcdir)
+
for record in parse_rfc822(control_path):
command = None
try:
@@ -477,3 +480,28 @@ def parse_click(clickpath, testbed_caps, srcdir=None):
pkg.close()
return parse_click_manifest(manifest, testbed_caps, [clickpath], srcdir)
+
+
+def autodetect_implicit_control(srcdir):
+ tests = []
+ some_skipped = False
+
+ autodetect_ruby_package(srcdir, tests)
+
+ return (tests, some_skipped)
+
+
+def autodetect_ruby_package(srcdir, tests):
+ if (any(map(lambda f: os.path.exists(os.path.join(srcdir, f)),
+ ['debian/ruby-tests.rake', 'debian/ruby-tests.rb',
+ 'debian/ruby-test-files.yaml']))):
+
+ adtlog.info('Ruby package detected')
+
+ command = 'gem2deb-test-runner --autopkgtest 2>&1'
+ depends = _parse_debian_depends(command, '@, gem2deb-test-runner',
+ srcdir)
+
+ test = Test('command1', None, command, [], [], depends, [])
+
+ tests.append(test)
diff --git a/tests/testdesc b/tests/testdesc
index 16b4b3b..85a8ed0 100755
--- a/tests/testdesc
+++ b/tests/testdesc
@@ -404,6 +404,22 @@ class Debian(unittest.TestCase):
self.assertFalse(skipped)
+ def test_implicit_control_for_ruby_packages(self):
+ with open(os.path.join(self.pkgdir, 'debian', 'ruby-tests.rb'), 'w') as f:
+ f.write("exit(0)\n")
+ with open(os.path.join(self.pkgdir, 'debian', 'control'), 'w') as f:
+ f.write('Source: ruby-foo\n\n')
+ f.write('Package: ruby-foo\n')
+ f.write('Architecture: all\n')
+
+ (ts, skipped) = testdesc.parse_debian_source(self.pkgdir, [], control_path='debian/tests/control')
+
+ self.assertEqual(len(ts), 1)
+ self.assertRegex(ts[0].command, 'gem2deb-test-runner')
+ self.assertRegex(ts[0].command, '--autopkgtest')
+ self.assertTrue('gem2deb-test-runner' in ts[0].depends)
+ self.assertTrue('ruby-foo' in ts[0].depends)
+
class Click(unittest.TestCase):
@classmethod
--
2.1.0
More information about the autopkgtest-devel
mailing list