FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo Portage Developer

 
 
LinkBack Thread Tools
 
Old 10-09-2011, 06:53 PM
Mike Frysinger
 
Default tests: add a --help option to make runtest more friendly

At the moment, trying to do `./runtests.h -h` just produces an ugly and
indecipherable traceback. Make it a bit more friendly.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
pym/portage/tests/__init__.py | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/pym/portage/tests/__init__.py b/pym/portage/tests/__init__.py
index 7f1ed3f..07be2f6 100644
--- a/pym/portage/tests/__init__.py
+++ b/pym/portage/tests/__init__.py
@@ -5,6 +5,7 @@
import sys
import time
import unittest
+from optparse import OptionParser, OptionValueError

try:
from unittest.runner import _TextTestResult # new in python-2.7
@@ -23,8 +24,12 @@ def main():
basedir = os.path.dirname(os.path.realpath(__file__))
testDirs = []

- if len(sys.argv) > 1:
- suite.addTests(getTestFromCommandLine(sys.argv[1:], basedir))
+ usage = "usage: %s [options] [tests to run]" % sys.argv[0]
+ parser = OptionParser(usage=usage)
+ (options, args) = parser.parse_args(args=sys.argv)
+
+ if len(args) > 1:
+ suite.addTests(getTestFromCommandLine(args[1:], basedir))
return TextTestRunner(verbosity=2).run(suite)

# the os.walk help mentions relative paths as being quirky
--
1.7.6.1
 

Thread Tools




All times are GMT. The time now is 11:47 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org