[Python-checkins] CVS: python/dist/src/Lib/test regrtest.py,1.42,1.43

Barry Warsaw bwarsaw@users.sourceforge.net
Mon, 20 Aug 2001 15:33:48 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv10015

Modified Files:
	regrtest.py 
Log Message:
Removed --have-resources flag in favor of the more granular -u/--use
flag, which specifies external or resource intensive tests to
perform.  This is used by test_largefile and test_socket_ssl.

-u/--use takes a comma separated list of flags, currently supported:
largefile, network.

usage(): New function.  Note that the semantics of main() have changed
    slightly; instead of returning an error code, it raises a
    SystemExit (via sys.exit()) with the given error code.

main(): use_large_resources => use_resources
    Also, added support for long-option alternative to the short
    options.

_expectations: Added test_socket_ssl to the list of expectedly skipped
    tests.


Index: regrtest.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/regrtest.py,v
retrieving revision 1.42
retrieving revision 1.43
diff -C2 -d -r1.42 -r1.43
*** regrtest.py	2001/08/20 20:33:42	1.42
--- regrtest.py	2001/08/20 22:33:46	1.43
***************
*** 16,20 ****
  -r: random    -- randomize test execution order
  -l: findleaks -- if GC is available detect tests that leak memory
! --have-resources   -- run tests that require large resources (time/space)
  
  If non-option arguments are present, they are names for tests to run,
--- 16,21 ----
  -r: random    -- randomize test execution order
  -l: findleaks -- if GC is available detect tests that leak memory
! -u: use       -- specify which special resource intensive tests to run
! -h: help      -- print this text and exit
  
  If non-option arguments are present, they are names for tests to run,
***************
*** 31,34 ****
--- 32,46 ----
  used instead of /tmp).
  
+ -u is used to specify which special resource intensive tests to run, such as
+ those requiring large file support or network connectivity.  The argument is a
+ comma-separated list of words indicating the resources to test.  Currently
+ only the following are defined:
+ 
+     largefile - It is okay to run some test that may create huge files.  These
+                 tests can take a long time and may consume >2GB of disk space
+                 temporarily.
+ 
+     network -   It is okay to run tests that use external network resource,
+                 e.g. testing SSL support for sockets.
  """
  
***************
*** 42,48 ****
  import test_support
  
  def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0,
           exclude=0, single=0, randomize=0, findleaks=0,
!          use_large_resources=0):
      """Execute a test suite.
  
--- 54,66 ----
  import test_support
  
+ def usage(code, msg=''):
+     print __doc__
+     if msg: print msg
+     sys.exit(code)
+ 
+ 
  def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0,
           exclude=0, single=0, randomize=0, findleaks=0,
!          use_resources=None):
      """Execute a test suite.
  
***************
*** 61,66 ****
      files beginning with test_ will be used.
  
!     The other seven default arguments (verbose, quiet, generate, exclude,
!     single, randomize, and findleaks) allow programmers calling main()
      directly to set the values that would normally be set by flags on the
      command line.
--- 79,84 ----
      files beginning with test_ will be used.
  
!     The other default arguments (verbose, quiet, generate, exclude, single,
!     randomize, findleaks, and use_resources) allow programmers calling main()
      directly to set the values that would normally be set by flags on the
      command line.
***************
*** 69,89 ****
  
      try:
!         opts, args = getopt.getopt(sys.argv[1:], 'vgqxsrl', ['have-resources'])
      except getopt.error, msg:
!         print msg
!         print __doc__
!         return 2
      for o, a in opts:
!         if o == '-v': verbose = verbose+1
!         if o == '-q': quiet = 1; verbose = 0
!         if o == '-g': generate = 1
!         if o == '-x': exclude = 1
!         if o == '-s': single = 1
!         if o == '-r': randomize = 1
!         if o == '-l': findleaks = 1
!         if o == '--have-resources': use_large_resources = 1
      if generate and verbose:
!         print "-g and -v don't go together!"
!         return 2
      good = []
      bad = []
--- 87,126 ----
  
      try:
!         opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrlu:',
!                                    ['help', 'verbose', 'quiet', 'generate',
!                                     'exclude', 'single', 'random',
!                                     'findleaks', 'use='])
      except getopt.error, msg:
!         usage(2, msg)
! 
!     # Defaults
!     if use_resources is None:
!         use_resources = []
      for o, a in opts:
!         if o in ('-h', '--help'):
!             usage(0)
!         elif o in ('-v', '--verbose'):
!             verbose += 1
!         elif o in ('-q', '--quiet'):
!             quiet = 1;
!             verbose = 0
!         elif o in ('-g', '--generate'):
!             generate = 1
!         elif o in ('-x', '--exclude'):
!             exclude = 1
!         elif o in ('-s', '--single'):
!             single = 1
!         elif o in ('-r', '--randomize'):
!             randomize = 1
!         elif o in ('-l', '--findleaks'):
!             findleaks = 1
!         elif o in ('-u', '--use'):
!             use_resources = [x.lower() for x in a.split(',')]
!             for r in use_resources:
!                 if r not in ('largefile', 'network'):
!                     usage(1, 'Invalid -u/--use option: %s' % a)
      if generate and verbose:
!         usage(2, "-g and -v don't go together!")
! 
      good = []
      bad = []
***************
*** 131,135 ****
          random.shuffle(tests)
      test_support.verbose = verbose      # Tell tests to be moderately quiet
!     test_support.use_large_resources = use_large_resources
      save_modules = sys.modules.keys()
      for test in tests:
--- 168,172 ----
          random.shuffle(tests)
      test_support.verbose = verbose      # Tell tests to be moderately quiet
!     test_support.use_resources = use_resources
      save_modules = sys.modules.keys()
      for test in tests:
***************
*** 198,202 ****
              os.unlink(filename)
  
!     return len(bad) > 0
  
  STDTESTS = [
--- 235,240 ----
              os.unlink(filename)
  
!     sys.exit(len(bad) > 0)
! 
  
  STDTESTS = [
***************
*** 348,352 ****
  
  class Compare:
- 
      def __init__(self, filename):
          if os.path.exists(filename):
--- 386,389 ----
***************
*** 453,456 ****
--- 490,494 ----
          test_pwd
          test_signal
+         test_socket_ssl
          test_socketserver
          test_sunaudiodev
***************
*** 468,471 ****
--- 506,510 ----
          test_nis
          test_ntpath
+         test_socket_ssl
          test_socketserver
          test_sunaudiodev
***************
*** 498,500 ****
  
  if __name__ == '__main__':
!     sys.exit(main())
--- 537,539 ----
  
  if __name__ == '__main__':
!     main()