Changeset 626 for branches/testScripts


Ignore:
Timestamp:
Oct 17, 2007 7:52:37 AM (12 years ago)
Author:
jpfasano
Message:

Added NBosCommand (nightly build operating system command).
This is an attempt to run commands and exe's in a subprocess, so if they
crash they don't bring down the script

Location:
branches/testScripts
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • branches/testScripts/NBemail.py

    r622 r626  
    4242  emailMsg += "Host name: "+gethostname()+"\n\n"
    4343
    44   emailMsg += "'" + cmd + "' messages are:\n"
    45   emailMsg += cmdMsgs
     44  emailMsg += "stderr messages are:\n"
     45  emailMsg += cmdMsgs['stderr']
     46  emailMsg += "\n\nstdout messages are:\n"
     47  emailMsg += cmdMsgs['stdout']
     48  if cmdMsgs.has_key('config.log') :
     49    emailMsg += "\n\nconfig.log messages are:\n"
     50    emailMsg += cmdMsgs['config.log']
    4651  send(toAddrs,subject,emailMsg)
    4752  NBlogMessages.writeMessage( "  email sent regarding "+project+" running '"+cmd+"'" )
  • branches/testScripts/NBuserConfig.py

    r625 r626  
    7979# List of Projects to be processed by script
    8080#----------------------------------------------------------------------
    81 PROJECTS = ['CoinUtils','DyLP','Clp','SYMPHONY','Vol','Osi','Cgl','Cbc','Ipopt','OS','CppAD']
    82 PROJECTS = ['CoinUtils']
     81PROJECTS = ['CoinUtils','DyLP','Clp','SYMPHONY','Vol','Osi','Cgl','Cbc',\
     82            'FlopC++','Ipopt','OS','CppAD']
    8383
    8484
  • branches/testScripts/nightlyBuild.py

    r625 r626  
    33import os
    44import sys
    5 import commands
    65import smtplib
    76import re
     
    1110import NBlogMessages
    1211import NBemail
     12import NBosCommand
    1313
    1414# TODO:
     
    2626
    2727
    28 #------------------------------------------------------------------------
    29 # Run command in another process.
    30 # Return: command's return code, stdout messages, & stderr messages
    31 #------------------------------------------------------------------------
    32 def runCommand(cmd) :
    33   p=subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
    34   p.wait
    35   cmdRc=p.returncode
    36   cmdStdout=p.stdout.read()
    37   cmdStderr=p.stderr.read()
    3828
    3929#------------------------------------------------------------------------
    4030# Function to Check Return Code from unitTest
    4131#------------------------------------------------------------------------
    42 def didTestFail( rc, project, buildStep ) :
     32def didTestFail( result, project, buildStep ) :
    4333  retVal = 0
    4434
    4535  # If the return code is not 0, then failure
    46   if rc[0] != 0 :
     36  if result['returnCode'] != 0 :
    4737    retVal = 1
    4838
     
    5242    if buildStep in NBprojectConfig.ALL_TESTS_COMPLETED_SUCCESSFULLY_CMDS[project] :
    5343      # Is the success message contained in the output?
    54       if rc[1].rfind("All tests completed successfully") == -1 :
     44      if result['stderr'].rfind("All tests completed successfully") == -1 and \
     45         result['stdout'].rfind("All tests completed successfully") == -1 :
    5546        # Success message not found, assume test failed
    5647        retVal = 1
     
    6455    # Check that last netlib test case ran by looking for message of form
    6556    # '../../Data/Netlib/woodw took 0.47 seconds using algorithm either'
    66     reexp = r"(.|\n)*\.\.(\\|/)\.\.(\\|/)Data(\\|/)Netlib(\\|/)woodw took (\d*\.\d*) seconds using algorithm either(.|\n)*"
    67     msgTail = rc[1][-200:]
     57    reexp = r"(.|\n)*(\\|/)Data(\\|/)Netlib(\\|/)woodw took (\d*\.\d*) seconds using algorithm either(.|\n)*"
     58    msgTail = result['stdout'][-200:]
    6859    if not re.compile(reexp).match(msgTail,1) :
    6960      # message not found, assume test failed
     
    7566    # 'cbc_clp solved 2 out of 2 and took XX.XX seconds.'
    7667    reexp=r"(.|\n)*cbc_clp solved 2 out of 2 and took (\d*\.\d*) seconds."
    77     msgTail = rc[1][-300:]
     68    msgTail = result['stdout'][-300:]
    7869    if not re.compile(reexp).match(msgTail,1) :
    7970      # message not found, assume test failed
     
    8273  # Cbc's "./cbc -unitTest dirNetlib=_MIPLIB3DIR_ -miplib"
    8374  elif project=='Cbc' and buildStep==NBprojectConfig.UNITTEST_CMD['Cbc'] :
    84     if rc[0]>=0 and rc[0]<=2 :
     75    if result['returnCode']>=0 and result['returnCode']<=2 :
    8576      # return code is between 0 and 2.
    8677      # Return code between 1 and 44 is the number of test cases that
     
    10091  os.chdir(dir)
    10192  NBlogMessages.writeMessage('  '+svnCmd)
    102   rc=commands.getstatusoutput(svnCmd)
    103   if rc[0] != 0 :
    104     NBemail.sendCmdMsgs(project,rc[1],svnCmd)
     93  result = NBosCommand.run(svnCmd)
     94  if result['returnCode'] != 0 :
     95    NBemail.sendCmdMsgs(project,result,svnCmd)
    10596    retVal='Error'
    10697  return retVal
     
    113104#  If needed create the top level directory
    114105#------------------------------------------------------------------------
    115 # rc=commands.getstatusoutput(NBuserConfig.NIGHTLY_BUILD_ROOT_DIR)
    116106if not os.path.isdir(NBuserConfig.NIGHTLY_BUILD_ROOT_DIR) :
    117107  os.makedirs(NBuserConfig.NIGHTLY_BUILD_ROOT_DIR)
     
    131121    if issueSvnCmd(svnCmd,dataBaseDir,'Data')!='OK' :
    132122      sys.exit(1)
    133     rc=commands.getstatusoutput('find '+d+' -name \*.gz -print | xargs gzip -d')
     123    result=NBosCommand.run('find '+d+' -name \*.gz -print | xargs gzip -d')
    134124netlibDir=os.path.join(dataBaseDir,'Netlib')
    135125miplib3Dir=os.path.join(dataBaseDir,'miplib3')
     
    140130for p in NBuserConfig.PROJECTS:
    141131  NBlogMessages.writeMessage( p )
    142   rc = [0]
    143132
    144133  #---------------------------------------------------------------------
     
    170159  configCmd = os.path.join('.','configure -C')
    171160  NBlogMessages.writeMessage('  '+configCmd)
    172   rc=commands.getstatusoutput(configCmd)
     161  result=NBosCommand.run(configCmd)
    173162 
    174163  # Check if configure worked
    175   if rc[0] != 0 :
    176     error_msg = rc[1] + '\n\n'
     164  if result['returnCode'] != 0 :
     165    error_msg = result
    177166    # Add contents of log file to message
    178167    logFileName = 'config.log'
    179168    if os.path.isfile(logFileName) :
    180169      logFilePtr = open(logFileName,'r')
    181       error_msg += "config.log contains: \n"
    182       error_msg += logFilePtr.read()
     170      error_msg['config.log']  = "config.log contains: \n"
     171      error_msg['config.log'] += logFilePtr.read()
    183172      logFilePtr.close()
    184173    NBemail.sendCmdMsgs(p,error_msg,configCmd)
     
    186175
    187176  #---------------------------------------------------------------------
    188   # Run make part of buid
     177  # Run make part of build
    189178  #---------------------------------------------------------------------
    190179  NBlogMessages.writeMessage( '  make' )
    191   rc=commands.getstatusoutput('make')
     180  result=NBosCommand.run('make')
    192181 
    193182  # Check if make worked
    194   if rc[0] != 0 :
    195     NBemail.sendCmdMsgs(p,rc[1],'make')
     183  if result['returnCode'] != 0 :
     184    NBemail.sendCmdMsgs(p,result,'make')
    196185    continue
    197186
    198187  #---------------------------------------------------------------------
    199   # Run 'make test' part of buid
     188  # Run 'make test' part of build
    200189  #---------------------------------------------------------------------
    201190  NBlogMessages.writeMessage( '  make test' )
    202   rc=commands.getstatusoutput('make test')
     191  result=NBosCommand.run('make test')
    203192 
    204193  # Check if 'make test' worked
    205   if didTestFail(rc,p,"make test") :
    206     NBemail.sendCmdMsgs(p,rc[1],"make test")
     194  if didTestFail(result,p,"make test") :
     195    NBemail.sendCmdMsgs(p,result,"make test")
    207196    continue
    208197
     
    219208
    220209    NBlogMessages.writeMessage( '  '+unitTestCmd )
    221     rc=commands.getstatusoutput(unitTestCmd)
     210    result=NBosCommand.run(unitTestCmd)
    222211 
    223     if didTestFail(rc,p,unitTestCmdTemplate) :
    224       NBemail.sendCmdMsgs(p,rc[1],unitTestCmd)
     212    if didTestFail(result,p,unitTestCmdTemplate) :
     213      NBemail.sendCmdMsgs(p,result,unitTestCmd)
    225214      continue
    226215
Note: See TracChangeset for help on using the changeset viewer.