1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
# -*- coding: latin1 -*-
"""Script pour execution de CppUniTest.
"""
import os
################################################################################
# BuildError
class BuildError(Exception):
################################################################################
# shell_command
def shell_command(cmd):
"""Start a Process and return the Output of the process as Stringlist
"""
cmd2 = cmd + ' 2>&1'
p = os.popen(cmd2)
lines = []
line = p.readline()
while line:
lines.append(line)
line = p.readline()
try:
status = p.close()
except KeyboardInterrupt, e:
raise
except:
raise BuildError(''.join(lines))
if status:
raise BuildError(''.join(lines))
print line
return lines
################################################################################
# execute_config
def execute_testscripts(path, logpath, config):
"""cherche dans le repertoire des scriptes finissant par .test.pl, .test.py ou .test.bat endenet les execute.
"""
messages = {};
for root, dirs, files in os.walk(path):
if root.find('.svn') < 0: # pas les fichiers dans le repertoire .svn
for file in files:
cmd = None
if file.lower().endswith('.test.pl'):
cmd = 'perl.exe '
elif file.lower().endswith('.test.py'):
cmd = 'python.exe '
elif file.lower().endswith('.test.bat'):
cmd = 'cmd /C '
if cmd:
cmd += root + '\\' + file
print '%-30s ' % file,
try:
if 'Debug' in dirs:
shell_command('rmdir /S /Q ' + root + '\\Debug') # Efface tous les fichiers du dernier test
shell_command(cmd + ' %s' % config)
print 'ok'
messages[file] = ''
except BuildError, e:
print 'Fehler'
messages[file] = str(e)
return messages
################################################################################
# main
def main():
"""The main programm".
"""
import sys
messages = execute_testscripts(rootpath, logpath, 'Debug') # Debug usw. muss ins Config-File
has_errors = False
for file in sorted(messages.keys()):
if messages[file]:
has_errors = True
log.writeLog( "Loading configuration file: config.xml", "Configuration" )
return has_errors
################################################################################
if __name__ == '__main__':
main() |
Partager