comparison run_tests.py @ 1881:f9e620befb43

make this run under py2.1
author Richard Jones <richard@users.sourceforge.net>
date Sun, 02 Nov 2003 08:43:22 +0000
parents f63aa57386b0
children 2996e168d359
comparison
equal deleted inserted replaced
1880:24ac1b330bda 1881:f9e620befb43
174 174
175 __super_init = unittest._TextTestResult.__init__ 175 __super_init = unittest._TextTestResult.__init__
176 __super_startTest = unittest._TextTestResult.startTest 176 __super_startTest = unittest._TextTestResult.startTest
177 __super_printErrors = unittest._TextTestResult.printErrors 177 __super_printErrors = unittest._TextTestResult.printErrors
178 178
179 def __init__(self, stream, descriptions, verbosity, debug=False, 179 def __init__(self, stream, descriptions, verbosity, debug=0,
180 count=None, progress=False): 180 count=None, progress=0):
181 self.__super_init(stream, descriptions, verbosity) 181 self.__super_init(stream, descriptions, verbosity)
182 self._debug = debug 182 self._debug = debug
183 self._progress = progress 183 self._progress = progress
184 self._progressWithNames = False 184 self._progressWithNames = 0
185 self._count = count 185 self._count = count
186 self._testtimes = {} 186 self._testtimes = {}
187 if progress and verbosity == 1: 187 if progress and verbosity == 1:
188 self.dots = False 188 self.dots = 0
189 self._progressWithNames = True 189 self._progressWithNames = 1
190 self._lastWidth = 0 190 self._lastWidth = 0
191 self._maxWidth = 80 191 self._maxWidth = 80
192 try: 192 try:
193 import curses 193 import curses
194 except ImportError: 194 except ImportError:
342 if build: 342 if build:
343 self.inplace = build_inplace 343 self.inplace = build_inplace
344 if self.inplace is None: 344 if self.inplace is None:
345 # Need to figure it out 345 # Need to figure it out
346 if os.path.isdir(os.path.join("build", "lib.%s" % PLAT_SPEC)): 346 if os.path.isdir(os.path.join("build", "lib.%s" % PLAT_SPEC)):
347 self.inplace = False 347 self.inplace = 0
348 else: 348 else:
349 self.inplace = True 349 self.inplace = 1
350 # Calculate which directories we're going to add to sys.path, and cd 350 # Calculate which directories we're going to add to sys.path, and cd
351 # to the appropriate working directory 351 # to the appropriate working directory
352 org_cwd = os.getcwd() 352 org_cwd = os.getcwd()
353 if self.inplace: 353 if self.inplace:
354 self.libdir = "src" 354 self.libdir = "src"
379 from zope.testing.functional import FunctionalTestSetup 379 from zope.testing.functional import FunctionalTestSetup
380 FunctionalTestSetup(config_file) 380 FunctionalTestSetup(config_file)
381 381
382 def match(rx, s): 382 def match(rx, s):
383 if not rx: 383 if not rx:
384 return True 384 return 1
385 if rx[0] == "!": 385 if rx[0] == "!":
386 return re.search(rx[1:], s) is None 386 return re.search(rx[1:], s) is None
387 else: 387 else:
388 return re.search(rx, s) is not None 388 return re.search(rx, s) is not None
389 389
623 623
624 # Initialize the path and cwd 624 # Initialize the path and cwd
625 global pathinit 625 global pathinit
626 pathinit = PathInit(build, build_inplace, libdir) 626 pathinit = PathInit(build, build_inplace, libdir)
627 627
628 # Initialize the logging module. 628 # No logging module in py 2.1
629 629 # # Initialize the logging module.
630 import logging.config 630
631 logging.basicConfig() 631 # import logging.config
632 632 # logging.basicConfig()
633 level = os.getenv("LOGGING") 633
634 if level: 634 # level = os.getenv("LOGGING")
635 level = int(level) 635 # if level:
636 else: 636 # level = int(level)
637 level = logging.CRITICAL 637 # else:
638 logging.root.setLevel(level) 638 # level = logging.CRITICAL
639 639 # logging.root.setLevel(level)
640 if os.path.exists(logini): 640
641 logging.config.fileConfig(logini) 641 # if os.path.exists(logini):
642 # logging.config.fileConfig(logini)
642 643
643 files = find_tests(module_filter) 644 files = find_tests(module_filter)
644 files.sort() 645 files.sort()
645 646
646 if GUI: 647 if GUI:
647 gui_runner(files, test_filter) 648 gui_runner(files, test_filter)
648 elif LOOP: 649 elif LOOP:
649 if REFCOUNT: 650 if REFCOUNT:
650 rc = sys.gettotalrefcount() 651 rc = sys.gettotalrefcount()
651 track = TrackRefs() 652 track = TrackRefs()
652 while True: 653 while 1:
653 runner(files, test_filter, debug) 654 runner(files, test_filter, debug)
654 gc.collect() 655 gc.collect()
655 if gc.garbage: 656 if gc.garbage:
656 print "GARBAGE:", len(gc.garbage), gc.garbage 657 print "GARBAGE:", len(gc.garbage), gc.garbage
657 return 658 return
690 argv = sys.argv 691 argv = sys.argv
691 692
692 module_filter = None 693 module_filter = None
693 test_filter = None 694 test_filter = None
694 VERBOSE = 1 695 VERBOSE = 1
695 LOOP = False 696 LOOP = 0
696 GUI = False 697 GUI = 0
697 TRACE = False 698 TRACE = 0
698 REFCOUNT = False 699 REFCOUNT = 0
699 debug = False # Don't collect test results; simply let tests crash 700 debug = 0 # Don't collect test results; simply let tests crash
700 debugger = False 701 debugger = 0
701 build = False 702 build = 0
702 build_inplace = False 703 build_inplace = 0
703 gcthresh = None 704 gcthresh = None
704 gcdebug = 0 705 gcdebug = 0
705 gcflags = [] 706 gcflags = []
706 level = 1 707 level = 1
707 libdir = '.' 708 libdir = '.'
708 progress = False 709 progress = 0
709 timesfn = None 710 timesfn = None
710 timetests = 0 711 timetests = 0
711 keepStaleBytecode = 0 712 keepStaleBytecode = 0
712 functional = False 713 functional = 0
713 test_dir = None 714 test_dir = None
714 715
715 try: 716 try:
716 opts, args = getopt.getopt(argv[1:], "a:bBcdDfg:G:hLmprtTuv", 717 opts, args = getopt.getopt(argv[1:], "a:bBcdDfg:G:hLmprtTuv",
717 ["all", "help", "libdir=", "times=", 718 ["all", "help", "libdir=", "times=",
726 level = int(v) 727 level = int(v)
727 elif k == "--all": 728 elif k == "--all":
728 level = 0 729 level = 0
729 os.environ["COMPLAIN_IF_TESTS_MISSED"]='1' 730 os.environ["COMPLAIN_IF_TESTS_MISSED"]='1'
730 elif k in ("-b", "--build"): 731 elif k in ("-b", "--build"):
731 build = True 732 build = 1
732 elif k == "-B": 733 elif k == "-B":
733 build = build_inplace = True 734 build = build_inplace = 1
734 elif k == "-c": 735 elif k == "-c":
735 # make sure you have a recent version of pychecker 736 # make sure you have a recent version of pychecker
736 if not os.environ.get("PYCHECKER"): 737 if not os.environ.get("PYCHECKER"):
737 os.environ["PYCHECKER"] = "-q" 738 os.environ["PYCHECKER"] = "-q"
738 import pychecker.checker 739 import pychecker.checker
739 elif k == "-d": 740 elif k == "-d":
740 debug = True 741 debug = 1
741 elif k == "-D": 742 elif k == "-D":
742 debug = True 743 debug = 1
743 debugger = True 744 debugger = 1
744 elif k == "-f": 745 elif k == "-f":
745 functional = True 746 functional = 1
746 elif k in ("-h", "--help"): 747 elif k in ("-h", "--help"):
747 print __doc__ 748 print __doc__
748 sys.exit(0) 749 sys.exit(0)
749 elif k == "-g": 750 elif k == "-g":
750 gcthresh = int(v) 751 gcthresh = int(v)
760 elif k == "-L": 761 elif k == "-L":
761 LOOP = 1 762 LOOP = 1
762 elif k == "-m": 763 elif k == "-m":
763 GUI = "minimal" 764 GUI = "minimal"
764 elif k == "-p": 765 elif k == "-p":
765 progress = True 766 progress = 1
766 elif k == "-r": 767 elif k == "-r":
767 if hasattr(sys, "gettotalrefcount"): 768 if hasattr(sys, "gettotalrefcount"):
768 REFCOUNT = True 769 REFCOUNT = 1
769 else: 770 else:
770 print "-r ignored, because it needs a debug build of Python" 771 print "-r ignored, because it needs a debug build of Python"
771 elif k == "-T": 772 elif k == "-T":
772 TRACE = True 773 TRACE = 1
773 elif k == "-t": 774 elif k == "-t":
774 if not timetests: 775 if not timetests:
775 timetests = 50 776 timetests = 50
776 elif k == "-u": 777 elif k == "-u":
777 GUI = 1 778 GUI = 1
784 # must be a filename to write 785 # must be a filename to write
785 timesfn = v 786 timesfn = v
786 elif k == '--dir': 787 elif k == '--dir':
787 test_dir = v 788 test_dir = v
788 789
789 if sys.version_info < ( 2,2,3 ):
790 print """\
791 ERROR: Your python version is not supported by Zope3.
792 Zope3 needs either Python2.3 or Python2.2.3 or greater.
793 In particular, Zope3 on Python2.2.2 is a recipe for
794 pain. You are running:""" + sys.version
795 sys.exit(1)
796
797 if gcthresh is not None: 790 if gcthresh is not None:
798 if gcthresh == 0: 791 if gcthresh == 0:
799 gc.disable() 792 gc.disable()
800 print "gc disabled" 793 print "gc disabled"
801 else: 794 else:
862 coverdir = os.path.join(os.getcwd(), "coverage") 855 coverdir = os.path.join(os.getcwd(), "coverage")
863 import trace 856 import trace
864 ignoremods = ["os", "posixpath", "stat"] 857 ignoremods = ["os", "posixpath", "stat"]
865 tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix], 858 tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix],
866 ignoremods=ignoremods, 859 ignoremods=ignoremods,
867 trace=False, count=True) 860 trace=0, count=1)
868 861
869 tracer.runctx("main(module_filter, test_filter, libdir)", 862 tracer.runctx("main(module_filter, test_filter, libdir)",
870 globals=globals(), locals=vars()) 863 globals=globals(), locals=vars())
871 r = tracer.results() 864 r = tracer.results()
872 path = "/tmp/trace.%s" % os.getpid() 865 path = "/tmp/trace.%s" % os.getpid()
873 import cPickle 866 import cPickle
874 f = open(path, "wb") 867 f = open(path, "wb")
875 cPickle.dump(r, f) 868 cPickle.dump(r, f)
876 f.close() 869 f.close()
877 print path 870 print path
878 r.write_results(show_missing=True, summary=True, coverdir=coverdir) 871 r.write_results(show_missing=1, summary=1, coverdir=coverdir)
879 else: 872 else:
880 bad = main(module_filter, test_filter, libdir) 873 bad = main(module_filter, test_filter, libdir)
881 if bad: 874 if bad:
882 sys.exit(1) 875 sys.exit(1)
883 except ImportError, err: 876 except ImportError, err:

Roundup Issue Tracker: http://roundup-tracker.org/