1 |
jfenwick |
2266 |
######################################################## |
2 |
|
|
# |
3 |
|
|
# Copyright (c) 2003-2008 by University of Queensland |
4 |
|
|
# Earth Systems Science Computational Center (ESSCC) |
5 |
|
|
# http://www.uq.edu.au/esscc |
6 |
|
|
# |
7 |
|
|
# Primary Business: Queensland, Australia |
8 |
|
|
# Licensed under the Open Software License version 3.0 |
9 |
|
|
# http://www.opensource.org/licenses/osl-3.0.php |
10 |
|
|
# |
11 |
|
|
######################################################## |
12 |
|
|
|
13 |
|
|
__copyright__="""Copyright (c) 2003-2008 by University of Queensland |
14 |
|
|
Earth Systems Science Computational Center (ESSCC) |
15 |
|
|
http://www.uq.edu.au/esscc |
16 |
|
|
Primary Business: Queensland, Australia""" |
17 |
|
|
__license__="""Licensed under the Open Software License version 3.0 |
18 |
|
|
http://www.opensource.org/licenses/osl-3.0.php""" |
19 |
jfenwick |
2344 |
__url__="https://launchpad.net/escript-finley" |
20 |
jfenwick |
2266 |
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
class GroupTest: |
24 |
|
|
def __init__(self, exec_cmd, evars, python_dir, working_dir, test_list): |
25 |
|
|
self.python_dir=python_dir |
26 |
|
|
self.working_dir=working_dir |
27 |
|
|
self.test_list=test_list |
28 |
|
|
self.exec_cmd=exec_cmd |
29 |
|
|
self.evars=evars |
30 |
|
|
self.mkdirs=[] |
31 |
|
|
|
32 |
|
|
def makeDir(self,dirname): |
33 |
|
|
self.mkdirs.append(dirname) |
34 |
|
|
|
35 |
jfenwick |
2276 |
def makeHeader(build_platform): |
36 |
jfenwick |
2266 |
res="#!/bin/bash\n" |
37 |
|
|
res=res+"\n#############################################\n" |
38 |
|
|
res=res+"# This file is autogenerated by scons.\n" |
39 |
|
|
res=res+"# It will be regenerated each time scons is run\n" |
40 |
|
|
res=res+"#############################################\n\n" |
41 |
|
|
res=res+"function failed()\n{\n echo ""Execution failed for $@""\n exit 1\n}\n" |
42 |
jfenwick |
2276 |
res=res+"\nexport LD_LIBRARY_PATH=`pwd`/lib:$LD_LIBRARY_PATH\n" |
43 |
|
|
if build_platform=='darwin': |
44 |
|
|
res=res+"export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH:$DYLD_LIBRARY_PATH\n" |
45 |
|
|
res=res+"\nexport OLD_PYTHON=`pwd`:$PYTHONPATH\nBINRUNNER=$1\nPYTHONRUNNER=\"$1 $2\"\nBATCH_ROOT=`pwd`\n" |
46 |
|
|
res=res+"BUILD_DIR=$BATCH_ROOT/build/"+build_platform |
47 |
|
|
res=res+"\nif [ ! -d $BUILD_DIR ]\nthen\n echo Can not find build directory $BUILD_DIR\n exit 2\nfi\n" |
48 |
jfenwick |
2266 |
res=res+"if [ $# -lt 2 ]\nthen\n echo Usage: $0 bin_run_cmd python_run_cmd\n exit 2\nfi\n" |
49 |
|
|
return res |
50 |
|
|
makeHeader=staticmethod(makeHeader) |
51 |
|
|
|
52 |
|
|
def makeString(self): |
53 |
|
|
res="" |
54 |
|
|
for d in self.mkdirs: |
55 |
|
|
res=res+"if [ ! -d "+str(d)+" ]\nthen\n mkdir "+d+"\nfi\n" |
56 |
|
|
for v in self.evars: |
57 |
|
|
res=res+"\nexport "+str(v[0])+"="+str(v[1]) |
58 |
|
|
res=res+"\nexport PYTHONPATH="+self.python_dir+":$OLD_PYTHON"+"\n"+"cd "+self.working_dir+"\n" |
59 |
|
|
for t in self.test_list: |
60 |
|
|
res=res+"echo Starting "+t+"\n" |
61 |
|
|
res=res+self.exec_cmd+' '+t+' || failed '+t+'\n' |
62 |
|
|
res=res+"echo Completed "+t+"\n" |
63 |
|
|
res=res+"\n" |
64 |
|
|
return res |
65 |
|
|
|