1. Ronald Oussoren
  2. pyobjc


pyobjc / Scripts / runalltests

The branch 'pyobjc-ancient' does not exist.
#!/usr/bin/env python

# Run all PyObjC tests. Every testscript will be started in a 
# fresh interpreter: Some tests depend on the availability or
# non-availability of some frameworks.
# Run from the root of the source-tree.
# NOTE: There should probably be a script that can run the
# scripts from the installed tree, but this should be enough
# to make it easy to actually run the full testsuite.

import sys
import os

tests = {}
test_sum = { 'OK': 0, 'FAIL':0, 'CRASH': 0 }

def perform_some_tests(dummy, dirname, fnames):
        if os.path.split(dirname)[-1] != 'test': return

        for nm in fnames:
                if not nm.startswith('test_'): continue
                if not nm.endswith('.py'): continue
        	path = os.path.join(dirname, nm)
        	print "-- Running '%s'"%path

                if 0:

        	fd = os.popen("'%s' '%s' 2>&1"%(sys.executable, path), 'r')
                ln = ''
                for _ln in fd.xreadlines():

                    # Odd GNUstep bug...
                    if _ln.startswith('Unable to retrieve information about SIGPIPE'): continue

                    # Debugging version of python
                    if _ln[0] == '[' and _ln.endswith(' refs]\n'): continue

                    # MallocGuard output
                    if _ln.startswith('GuardMalloc-'): continue
                    if _ln.startswith('Allocations will be placed on '):continue
                    if _ln.startswith(' - Small buffer overruns may '): continue
                    if _ln.startswith(' - Applications using AltiVec '):continue

                    ln = _ln

                xit = fd.close()
                if ln.startswith('OK'):
                    if xit is not None:
                        tests[path] = 'Exit with %s: %s'%(xit, ln.strip())
                        test_sum['CRASH'] += 1
                        tests[path] = ln.strip()
                        test_sum['OK'] += 1

                elif ln.startswith('FAIL'):
                    tests[path] = ln.strip()
                    test_sum['FAIL'] += 1

                    tests[path] = 'CRASHED'
                    test_sum['CRASH'] += 1

        	print "-- Done"

#os.path.walk('Lib/objc', perform_some_tests, None)
#os.path.walk('Lib/Foundation', perform_some_tests, None)
os.path.walk('Lib', perform_some_tests, None)

keys = tests.keys()
print "\nSummary of not-OK tests:"
for k in keys:
    if tests[k] != "OK":
        print "  %-50s: %s"%(k[4:], tests[k])

print "\n%(OK)s OK, %(FAIL)s FAILED, %(CRASH)s CRASHED"%test_sum