mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-13 08:01:09 +00:00
Test for that every script can run --help and return 0.
This commit is contained in:
parent
51966025d6
commit
3ac706401f
3
debian/changelog
vendored
3
debian/changelog
vendored
@ -15,6 +15,7 @@ ubuntu-dev-tools (0.109) UNRELEASED; urgency=low
|
|||||||
DEBEMAIL. (LP: #665202)
|
DEBEMAIL. (LP: #665202)
|
||||||
* Add the beginnings of a test suite. (LP: #690386)
|
* Add the beginnings of a test suite. (LP: #690386)
|
||||||
- Switch to setuptools, to support setup.py test.
|
- Switch to setuptools, to support setup.py test.
|
||||||
|
- Test for that every script can run --help and return 0.
|
||||||
* ubuntutools/common.py: Remove https_proxy unsetting code, working around
|
* ubuntutools/common.py: Remove https_proxy unsetting code, working around
|
||||||
LP: #94130.
|
LP: #94130.
|
||||||
|
|
||||||
@ -29,7 +30,7 @@ ubuntu-dev-tools (0.109) UNRELEASED; urgency=low
|
|||||||
- Fix 'str' object has no attribute 'startwith' crash caused by a typo.
|
- Fix 'str' object has no attribute 'startwith' crash caused by a typo.
|
||||||
- Fix crash if uploading to ubuntu without building the package before.
|
- Fix crash if uploading to ubuntu without building the package before.
|
||||||
|
|
||||||
-- Benjamin Drung <bdrung@ubuntu.com> Wed, 22 Dec 2010 00:51:48 +0100
|
-- Stefano Rivera <stefanor@ubuntu.com> Wed, 22 Dec 2010 15:02:45 +0200
|
||||||
|
|
||||||
ubuntu-dev-tools (0.108) experimental; urgency=low
|
ubuntu-dev-tools (0.108) experimental; urgency=low
|
||||||
|
|
||||||
|
111
setup.py
111
setup.py
@ -13,57 +13,60 @@ if os.path.exists(changelog):
|
|||||||
if match:
|
if match:
|
||||||
version = match.group(1)
|
version = match.group(1)
|
||||||
|
|
||||||
setup(name='ubuntu-dev-tools',
|
scripts = ['404main',
|
||||||
version=version,
|
'backportpackage',
|
||||||
scripts=['404main',
|
'check-symbols',
|
||||||
'backportpackage',
|
'dch-repeat',
|
||||||
'check-symbols',
|
'dgetlp',
|
||||||
'dch-repeat',
|
'edit-patch',
|
||||||
'dgetlp',
|
'errno',
|
||||||
'edit-patch',
|
'get-branches',
|
||||||
'errno',
|
'get-build-deps',
|
||||||
'get-branches',
|
'grab-attachments',
|
||||||
'get-build-deps',
|
'grab-merge',
|
||||||
'grab-attachments',
|
'grep-merges',
|
||||||
'grab-merge',
|
'hugdaylist',
|
||||||
'grep-merges',
|
'import-bug-from-debian',
|
||||||
'hugdaylist',
|
'lp-list-bugs',
|
||||||
'import-bug-from-debian',
|
'lp-project-upload',
|
||||||
'lp-list-bugs',
|
'lp-set-dup',
|
||||||
'lp-project-upload',
|
'lp-shell',
|
||||||
'lp-set-dup',
|
'manage-credentials',
|
||||||
'lp-shell',
|
'massfile',
|
||||||
'manage-credentials',
|
'merge-changelog',
|
||||||
'massfile',
|
'mk-sbuild',
|
||||||
'merge-changelog',
|
'pbuilder-dist',
|
||||||
'mk-sbuild',
|
'pbuilder-dist-simple',
|
||||||
'pbuilder-dist',
|
'pull-debian-debdiff',
|
||||||
'pbuilder-dist-simple',
|
'pull-debian-source',
|
||||||
'pull-debian-debdiff',
|
'pull-lp-source',
|
||||||
'pull-debian-source',
|
'pull-revu-source',
|
||||||
'pull-lp-source',
|
'requestsync',
|
||||||
'pull-revu-source',
|
'reverse-build-depends',
|
||||||
'requestsync',
|
'setup-packaging-environment',
|
||||||
'reverse-build-depends',
|
'sponsor-patch',
|
||||||
'setup-packaging-environment',
|
'submittodebian',
|
||||||
'sponsor-patch',
|
'suspicious-source',
|
||||||
'submittodebian',
|
'syncpackage',
|
||||||
'suspicious-source',
|
'ubuntu-build',
|
||||||
'syncpackage',
|
'ubuntu-iso',
|
||||||
'ubuntu-build',
|
'update-maintainer',
|
||||||
'ubuntu-iso',
|
'what-patch',
|
||||||
'update-maintainer',
|
'wrap-and-sort',
|
||||||
'what-patch',
|
]
|
||||||
'wrap-and-sort',
|
|
||||||
],
|
if __name__ == '__main__':
|
||||||
packages=['ubuntutools',
|
setup(name='ubuntu-dev-tools',
|
||||||
'ubuntutools/lp',
|
version=version,
|
||||||
'ubuntutools/requestsync',
|
scripts=scripts,
|
||||||
'ubuntutools/sponsor_patch',
|
packages=['ubuntutools',
|
||||||
'ubuntutools/test',
|
'ubuntutools/lp',
|
||||||
],
|
'ubuntutools/requestsync',
|
||||||
data_files=[('share/man/man1', glob.glob("doc/*.1")),
|
'ubuntutools/sponsor_patch',
|
||||||
('share/man/man5', glob.glob("doc/*.5")),
|
'ubuntutools/test',
|
||||||
],
|
],
|
||||||
test_suite='ubuntutools.test.discover',
|
data_files=[('share/man/man1', glob.glob("doc/*.1")),
|
||||||
)
|
('share/man/man5', glob.glob("doc/*.5")),
|
||||||
|
],
|
||||||
|
test_suite='ubuntutools.test.discover',
|
||||||
|
)
|
||||||
|
77
ubuntutools/test/test_help.py
Normal file
77
ubuntutools/test/test_help.py
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
# test_help.py - Ensure scripts can run --help.
|
||||||
|
#
|
||||||
|
# Copyright (C) 2010, Stefano Rivera <stefanor@ubuntu.com>
|
||||||
|
#
|
||||||
|
# Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
# purpose with or without fee is hereby granted, provided that the above
|
||||||
|
# copyright notice and this permission notice appear in all copies.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
# AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||||
|
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||||
|
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
# PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
import fcntl
|
||||||
|
import os
|
||||||
|
import select
|
||||||
|
import signal
|
||||||
|
import subprocess
|
||||||
|
import time
|
||||||
|
|
||||||
|
import setup
|
||||||
|
from ubuntutools.test import unittest
|
||||||
|
|
||||||
|
BLACKLIST = ['grep-merges', 'submittodebian']
|
||||||
|
TIMEOUT = 5
|
||||||
|
|
||||||
|
def load_tests(loader, tests, pattern):
|
||||||
|
"Give HelpTestCase a chance to populate before loading its test cases"
|
||||||
|
suite = unittest.TestSuite()
|
||||||
|
HelpTestCase.populate()
|
||||||
|
suite.addTests(loader.loadTestsFromTestCase(HelpTestCase))
|
||||||
|
return suite
|
||||||
|
|
||||||
|
class HelpTestCase(unittest.TestCase):
|
||||||
|
@classmethod
|
||||||
|
def populate(cls):
|
||||||
|
for script in setup.scripts:
|
||||||
|
setattr(cls, 'test_' + script, cls.makeHelpTester(script))
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def makeHelpTester(cls, script):
|
||||||
|
def tester(self):
|
||||||
|
if script in BLACKLIST:
|
||||||
|
raise unittest.SkipTest("Blacklisted")
|
||||||
|
|
||||||
|
null = open('/dev/null', 'r')
|
||||||
|
p = subprocess.Popen(['./' + script, '--help'],
|
||||||
|
close_fds=True, stdin=null,
|
||||||
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
started = time.time()
|
||||||
|
out = []
|
||||||
|
|
||||||
|
fds = [p.stdout.fileno(), p.stderr.fileno()]
|
||||||
|
for fd in fds:
|
||||||
|
fcntl.fcntl(fd, fcntl.F_SETFL,
|
||||||
|
fcntl.fcntl(fd, fcntl.F_GETFL) | os.O_NONBLOCK)
|
||||||
|
|
||||||
|
while time.time() - started < TIMEOUT:
|
||||||
|
for fd in select.select(fds, [], fds, TIMEOUT)[0]:
|
||||||
|
out.append(os.read(fd, 1024))
|
||||||
|
if p.poll() is not None:
|
||||||
|
break
|
||||||
|
|
||||||
|
if p.poll() is None:
|
||||||
|
os.kill(signal.SIG_TERM)
|
||||||
|
time.sleep(1)
|
||||||
|
if p.poll() is None:
|
||||||
|
os.kill(signal.SIG_KILL)
|
||||||
|
|
||||||
|
self.assertEqual(p.poll(), 0,
|
||||||
|
"%s failed to return usage within %i seconds.\n"
|
||||||
|
"Output:\n%s"
|
||||||
|
% (script, TIMEOUT, ''.join(out)))
|
||||||
|
return tester
|
Loading…
x
Reference in New Issue
Block a user