[Zope-CVS] CVS: Packages/TestScripts - autotester.py:1.24
Fred L. Drake, Jr.
fred@zope.com
Wed, 26 Feb 2003 17:07:44 -0500
Update of /cvs-repository/Packages/TestScripts
In directory cvs.zope.org:/tmp/cvs-serv5451
Modified Files:
autotester.py
Log Message:
- various re-organizations and cleanups
- remove no-longer-needed import (moved to top in previous commit)
=== Packages/TestScripts/autotester.py 1.23 => 1.24 ===
--- Packages/TestScripts/autotester.py:1.23 Wed Feb 26 15:55:05 2003
+++ Packages/TestScripts/autotester.py Wed Feb 26 17:07:44 2003
@@ -23,44 +23,30 @@
def run(self):
self.result = self.file.read()
+ self.file.close()
- def read(self):
- return self.result
-
-f = open(sys.argv[1])
-config = xml2dict.xml2dict(f.read())
-f.close()
-
-# Set up any necessary environment variables
-os.environ['CVSROOT']=config['cvs'][0]['root'][0]()
-
-# Sandbox path
-sandbox = config['sandbox'][0]()
-
-# stuff we always need to send emails
-email = config['email'][0]
-smtp_server=email['smtp'][0]()
-from_address=email['from'][0]()
-
-
-# The emails to send ( list of (email address,StringIO object,scenario name))
-emails=[]
+def note(*args):
+ fp = sys.stdout
+ fp.write(' '.join(args) + '\n')
+ fp.flush()
+
+def setenv(name, value):
+ os.environ[name] = value
+ note("Setting", name, "to", repr(value))
# executor
def execute(location,python,command,options):
os.chdir(os.path.join(sandbox,location))
+ note("Running:", python, command, options)
(i,c,e) = os.popen3(python+' '+command+' '+options)
+ i.close()
ct = NonBlockingReader(c)
et = NonBlockingReader(e)
ct.start()
et.start()
ct.join()
et.join()
- result = ct.read()+et.read()
- i.close()
- c.close()
- e.close()
- return result
+ return ct.result + et.result
def xml_execute(commands,p):
result=[]
@@ -71,6 +57,33 @@
command['options'][0]()))
return '\n'.join(result)
+def get_module_info(module):
+ return (module['name'][0](),
+ module['rename'][0](),
+ module['tag'][0](),
+ module['location'][0](),
+ )
+
+
+f = open(sys.argv[1])
+config = xml2dict.xml2dict(f.read())
+f.close()
+
+# Set up any necessary environment variables
+setenv("CVSROOT", config['cvs'][0]['root'][0]())
+
+# Sandbox path
+sandbox = config['sandbox'][0]()
+
+# stuff we always need to send emails
+email = config['email'][0]
+smtp_server=email['smtp'][0]()
+from_address=email['from'][0]()
+
+
+# The emails to send ( list of (email address,StringIO object,scenario name))
+emails=[]
+
# get our original directory
home = os.getcwd()
@@ -85,7 +98,7 @@
# blow away the sandbox
if os.path.isdir(sandbox):
- print "Removing existing sandbox..."
+ note("Removing existing sandbox...")
shutil.rmtree(sandbox)
os.makedirs(sandbox)
@@ -93,29 +106,21 @@
modules=[]
for module in scenario['module']:
- modules.append((
- module['name'][0](),
- module['rename'][0](),
- module['tag'][0](),
- module['location'][0]()
- ))
+ modules.append(get_module_info(module))
for modulegroup in scenario.get('modulegroup',[]):
for module in config['modulegroups'][0][modulegroup()][0]['module']:
- modules.append((
- module['name'][0](),
- module['rename'][0](),
- module['tag'][0](),
- module['location'][0]()
- ))
+ modules.append(get_module_info(module))
# do the CVS checkouts
+ cvscmd = config['cvs'][0]['command'][0]()
for (module,name,tag,location) in modules:
# change dir to the right place
os.chdir(os.path.join(sandbox,location))
# do the checkout
- os.system(config['cvs'][0]['command'][0]()
- +" -z9 export -r "+tag+" -d "+name+" "+module)
+ cmd = cvscmd+" -z9 export -r "+tag+" -d "+name+" "+module
+ note("Running:", cmd)
+ os.system(cmd)
# get the python command
p = config['python'][0][scenario['python'][0]()][0]()
@@ -127,11 +132,11 @@
os.environ[key]=value[0]()
# get the python version string
- python_version = execute('',p,'',' -c "import sys; print sys.version"')
+ python_version = execute('',p,'-c','"import sys; print sys.version"')
# execute the build command
build_result = xml_execute(scenario['build'],p)
- print build_result
+ note(build_result)
# run the tests
test_result = xml_execute(scenario['test'],p)
@@ -204,9 +209,8 @@
except:
# oh dear, badness happened, better whine.
- from traceback import format_exception
mailer.send(from_address,
'Autotester.py failed',
- '\n'.join(format_exception(*sys.exc_info())),
+ '\n'.join(traceback.format_exception(*sys.exc_info())),
smtp_server=smtp_server,
from_address=from_address)