Commits

Jason R. Coombs committed b3405b4

Refactored tests.sh into run-all-tests.sh

Comments (0)

Files changed (1)

+#!/usr/bin/env python
+import shutil
+import subprocess
+import os
+
+def get_python_3_lib_path():
+	cmd = [
+		'python3.2',
+		'-c',
+		"from distutils.util import get_platform; "
+		"import sys; "
+		"print('lib.%s-%s' % (get_platform(), sys.version[0:3]))"
+		]
+	return subprocess.check_output(cmd)
+
+for python_ver in '2.4 2.5 2.6 2.7 3.1 3.2 3.3'.split():
+	try:
+		subprocess.check_call(['python'+python_ver, '-v'])
+	except:
+		print("Skipping tests for Python %s (not found)" % python_ver)
+		continue
+	print ("Running tests for Python %s" % python_ver)
+	if python_ver == '2.4':
+		try:
+			os.remove('distutils2/_backport/_hashlib.so')
+		except:
+			pass
+		cmd = [
+			'python'+python_ver,
+			'setup.py',
+			'build_ext',
+			'-f', '-q',
+			]
+		subprocess.check_call(cmd)
+	wd = '.'
+	env = dict(os.environ)
+	if python_ver.startswith('3'):
+		wd = 'build'
+		
+		env['PYTHONPATH'] = os.path.pathsep.join((
+			get_python_3_lib_path(),
+			'lib',))
+			
+	
+	cmd = [
+		'python'+python_ver,
+		'setup.py',
+		'-Wd',
+		'runtests.py',
+		'-q',
+	]
+	if python_ver == '2.7':
+		cmd[3:3] = ['-bb', '-3']
+	try:
+		subprocess.check_call(cmd, env=env, cwd=wd)
+	except:
+		print("Failed")
+		if python_ver == '2.4':
+			os.remove('distutils2/_backport/_hashlib.so')