2013-11-27 07:53:57 -06:00
|
|
|
#!/usr/bin/python2
|
2009-12-09 10:09:53 -06:00
|
|
|
|
|
|
|
"""
|
|
|
|
Run IPA unit tests under multiple versions of Python (if present).
|
|
|
|
"""
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import optparse
|
|
|
|
import os
|
|
|
|
from os import path
|
|
|
|
from subprocess import call
|
|
|
|
|
|
|
|
versions = ('2.4', '2.5', '2.6', '2.7')
|
|
|
|
python = '/usr/bin/python'
|
|
|
|
nose = '/usr/bin/nosetests'
|
|
|
|
ran = []
|
|
|
|
fail = []
|
|
|
|
|
2012-04-04 08:42:22 -05:00
|
|
|
cmd = [
|
|
|
|
nose,
|
2009-12-09 10:09:53 -06:00
|
|
|
'-v',
|
|
|
|
'--with-doctest',
|
2009-12-18 00:57:39 -06:00
|
|
|
'--doctest-tests',
|
2009-12-09 10:09:53 -06:00
|
|
|
'--exclude=plugins',
|
|
|
|
]
|
2012-04-04 08:42:22 -05:00
|
|
|
cmd += sys.argv[1:]
|
2009-12-09 10:09:53 -06:00
|
|
|
|
|
|
|
|
|
|
|
# This must be set so ipalib.api gets initialized property for tests:
|
|
|
|
os.environ['IPA_UNIT_TEST_MODE'] = 'cli_test'
|
|
|
|
|
2013-06-03 08:04:58 -05:00
|
|
|
# Add in-tree client binaries to PATH
|
|
|
|
os.environ['PATH'] = './ipa-client:' + os.environ['PATH']
|
|
|
|
|
2009-12-09 10:09:53 -06:00
|
|
|
if not path.isfile(nose):
|
|
|
|
print 'ERROR: need %r' % nose
|
|
|
|
sys.exit(100)
|
|
|
|
for v in versions:
|
|
|
|
pver = python + v
|
|
|
|
if not path.isfile(pver):
|
|
|
|
continue
|
2012-04-04 08:42:22 -05:00
|
|
|
command = [pver] + cmd
|
|
|
|
print ' '.join(cmd)
|
|
|
|
if 0 != call(cmd):
|
2009-12-09 10:09:53 -06:00
|
|
|
fail.append(pver)
|
|
|
|
ran.append(pver)
|
|
|
|
|
|
|
|
|
|
|
|
print '=' * 70
|
|
|
|
for pver in ran:
|
|
|
|
if pver in fail:
|
|
|
|
print 'FAILED under %r' % pver
|
|
|
|
else:
|
|
|
|
print 'passed under %r' % pver
|
|
|
|
print ''
|
|
|
|
if fail:
|
|
|
|
print '** FAIL **'
|
2013-02-22 17:41:58 -06:00
|
|
|
sys.exit(1)
|
2009-12-09 10:09:53 -06:00
|
|
|
else:
|
|
|
|
print '** pass **'
|
2013-02-22 17:41:58 -06:00
|
|
|
sys.exit(0)
|