diff options
author | R. Tyler Ballance <tyler@monkeypox.org> | 2009-11-08 16:52:48 -0800 |
---|---|---|
committer | R. Tyler Ballance <tyler@monkeypox.org> | 2009-11-16 00:04:10 -0800 |
commit | b6ae1200cc013ae8fede21a290bcbd95e9758742 (patch) | |
tree | 843486ebb2446ebb806796cd5506e573704aa90f /buildandrun | |
parent | a062578776fb57bc83edf042f84f21588ac780dc (diff) | |
download | python-cheetah-b6ae1200cc013ae8fede21a290bcbd95e9758742.tar.gz |
Refactor CheetahWrapper tests to locate my local cheetah/cheetah-compile in my PATH
Adding the "buildandrun" shortcut script so to easily rerun the
full test suite locally; usage: ./buildandrun cheetah/Tests/Test.py
Diffstat (limited to 'buildandrun')
-rwxr-xr-x | buildandrun | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/buildandrun b/buildandrun new file mode 100755 index 0000000..d3b4e42 --- /dev/null +++ b/buildandrun @@ -0,0 +1,66 @@ +#!/usr/bin/env python + +import logging +import os +import os.path +import subprocess +import sys + +from optparse import OptionParser + +if os.getenv('DEBUG'): + logging.basicConfig(level=logging.DEBUG) + +def recursiverm(d): + for root, dirs, files in os.walk(d): + for f in files: + f = root + os.path.sep + f + logging.debug('Removing file: %s' % f) + os.unlink(f) + +def main(): + op = OptionParser() + op.add_option('-c', '--clean', dest='clean', action='store_true', + help='Remove the contents of the build directory') + opts, args = op.parse_args() + if not args: + print('Specify a test script') + return + + + if opts.clean: + logging.debug('Removing build/') + recursiverm('build') + + logging.debug('Building Cheetah') + rc = subprocess.call(('python', 'setup.py', 'build')) + + if rc: + logging.debug('Build failed!') + return + + logging.debug('Adjusting PATH and PYTHONPATH') + cwd = os.getcwd() + + libdir = None + scriptdir = None + + for sub in os.listdir('build'): + if sub.startswith('scripts'): + scriptdir = os.path.sep.join((cwd, 'build', sub)) + if sub.startswith('lib'): + libdir = os.path.sep.join((cwd, 'build', sub)) + + newpath = '%s:%s' % (scriptdir, os.getenv('PATH')) + logging.debug('Setting PATH to: %s' % newpath) + os.putenv('PATH', newpath) + logging.debug('Setting PYTHONPATH to: %s' % libdir) + os.putenv('PYTHONPATH', libdir) + + rc = subprocess.call( ['python',] + args ) + + + +if __name__ == '__main__': + main() + |