diff --git a/tests/autopkgtest.py b/tests/autopkgtest.py index 23847bc..66c6250 100755 --- a/tests/autopkgtest.py +++ b/tests/autopkgtest.py @@ -199,54 +199,88 @@ args.func() ''' % {'py': sys.executable, 'path': self.data.path, 'rq': request}) def run_britney(self, args=[]): - '''Run britney and return (exit, out, err)''' + '''Run britney. + Assert that it succeeds and does not produce anything on stderr. + Return generated excuses.html output. + ''' britney = subprocess.Popen([self.britney, '-c', self.britney_conf], stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=self.data.path, universal_newlines=True) (out, err) = britney.communicate() - return (britney.returncode, out, err) - - def test_no_request_for_uninstallable(self): - '''Does not request a test for an uninstallable package''' - - # uninstallable unstable version - self.data.add('green', True, - {'Version': '1.1~beta', - 'Depends': 'libc6 (>= 0.9), libgreen1 (>= 2)'}) - - self.make_adt_britney('green 1.1~beta FAIL green 1.1~beta\n') - - (c, o, e) = self.run_britney() - self.assertEqual(e, '', e) - self.assertEqual(c, 0, o + e) + self.assertEqual(britney.returncode, 0, out + err) + self.assertEqual(err, '') with open(os.path.join(self.data.path, 'output', 'excuses.html')) as f: excuses = f.read() - self.assertIn('green/amd64 unsatisfiable Depends: libgreen1 (>= 2)', excuses) - # does not request autopkgtest for uninstallable package - self.assertNotIn('autopkgtest', excuses) - def test_request_for_installable(self): - '''Requests a test for an installable package''' + return excuses - # installable unstable version - self.data.add('green', True, - {'Version': '1.1~beta', - 'Depends': 'libc6 (>= 0.9), libgreen1'}) + def test_no_request_for_uninstallable(self): + '''Does not request a test for an uninstallable package''' - self.make_adt_britney('green 1.1~beta RUNNING green 1.1~beta\n') + self.do_test( + # uninstallable unstable version + [('green', {'Version': '1.1~beta', 'Depends': 'libc6 (>= 0.9), libgreen1 (>= 2)'})], + 'green 1.1~beta RUNNING green 1.1~beta\n', + False, + [r'\bgreen\b.*>1 to .*>1.1~beta<', + 'green/amd64 unsatisfiable Depends: libgreen1 \(>= 2\)'], + # autopkgtest should not be triggered for uninstallable pkg + ['autopkgtest']) + + def test_request_for_installable_running(self): + '''Requests a test for an installable package, test still running''' + + self.do_test( + [('green', {'Version': '1.1~beta', 'Depends': 'libc6 (>= 0.9), libgreen1'})], + 'green 1.1~beta RUNNING green 1.1~beta\n', + False, + [r'\bgreen\b.*>1 to .*>1.1~beta<', + '