source: branches/testScripts/nightlyBuild.py @ 730

Last change on this file since 730 was 730, checked in by jpfasano, 12 years ago

Mofified NBcheckResult so that it is a bunch of small functions that check for one specific thing.
NBprojectConfig now defines a dictionary where the key is the project.
The value is a list of functions that need to be run to check the success of a particular test run.
The code still needs to be cleaned up, but it seems to be running and was time to do a check-in so I can move it to other platforms for testing.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 7.1 KB
RevLine 
[676]1#!/usr/bin/env python
2
[718]3#------------------------------------------------------------------------
4# This file is distributed under the Common Public License.
5# It is part of the BuildTools project in COIN-OR (www.coin-or.org)
6#------------------------------------------------------------------------
7
[676]8import os
9import sys
10import NBprojectConfig
11import NBlogMessages
12import NBemail
13import NBosCommand
14import NBsvnCommand
15import NBcheckResult
16import NBbuildConfig
17
[692]18
19execfile('NBuserParametersDefault.py')
20execfile('NBuserParameters.py')
21
22
23
24
25
[676]26# TODO:
27#   -In userConfig allow one to optionally do a clean checkout and/or config
[694]28#   -Clean up the kludge that tests if "make test" and 'unitTest' were
29#    successfull
[723]30#   -Reduce size of email messages.
31#   -Get working on windows
[676]32
33
34#------------------------------------------------------------------------
35#  Main Program Starts Here 
36#------------------------------------------------------------------------
37
38#------------------------------------------------------------------------
39#  If needed create the top level directory
40#------------------------------------------------------------------------
[692]41if not os.path.isdir( NIGHTLY_BUILD_ROOT_DIR) :
42  os.makedirs(NIGHTLY_BUILD_ROOT_DIR)
43os.chdir( NIGHTLY_BUILD_ROOT_DIR)
[676]44
45#------------------------------------------------------------------------
46#  Get the data directories if they don't already exist
47#------------------------------------------------------------------------
[692]48dataBaseDir=os.path.join(NIGHTLY_BUILD_ROOT_DIR,'Data')
[676]49if not os.path.isdir(dataBaseDir) :
50  os.makedirs(dataBaseDir)
51dataDirs=['Netlib','miplib3']
52for d in dataDirs :
53  dataDir=os.path.join(dataBaseDir,d)
54  if not os.path.isdir(dataDir) :
[692]55    svnCmd=os.path.join( SVNPATH_PREFIX,'svn') + ' checkout https://projects.coin-or.org/svn/Data/releases/1.0.0/'+d+' '+d
[676]56    if NBsvnCommand.run(svnCmd,dataBaseDir,'Data')!='OK' :
57      sys.exit(1)
58    result=NBosCommand.run('find '+d+' -name \*.gz -print | xargs gzip -d')
59netlibDir=os.path.join(dataBaseDir,'Netlib')
60miplib3Dir=os.path.join(dataBaseDir,'miplib3')
61
62#------------------------------------------------------------------------
63# Loop once for each project (get code, compile & link, and test).
64#------------------------------------------------------------------------
65configuration={}
[692]66configuration['rootDir']=NIGHTLY_BUILD_ROOT_DIR
[676]67#for p,buildConfigs in NBprojectConfig.BUILDS.iteritems():
[692]68for p in PROJECTS :
[676]69
70  configuration['project']=p
71
72  #------------------------------------------------------------------------
73  # Loop once for each build configuration of p
74  #------------------------------------------------------------------------
[692]75  buildConfigs = BUILDS[p]
[676]76  for bc in buildConfigs:
77
78    #--------------------------------------------------------------------
79    # Does build reference another project's build configuration.
80    # If yes, then build p as specified by the reference project.
81    #--------------------------------------------------------------------
82    if 'Reference' in bc :
[692]83      referencedConfigs = BUILDS[ bc['Reference'] ]
[676]84      for c in referencedConfigs :
85        buildConfigs.append(c)
86      continue
87
88    #--------------------------------------------------------------------
89    # Setup subversion verion
90    #--------------------------------------------------------------------
91    if 'SvnVersion' not in bc :
92      print 'Error. BUILDS does not contain SvnVersion'
93      print '       Project is '+p
94      print '       BuildConfig is '+str(bc)
95      sys.exit(1)
96    if bc['SvnVersion']=='latestStable' :
[709]97      lsv=NBsvnCommand.latestStableVersion(p)
98      if not lsv :
99        print 'Error. BUILDS configured to use lastest stable svn version'
100        print '       Project does not have a stable version'
101        print '       Project is '+p
102        print '       BuildConfig is '+str(bc)
103        sys.exit(1)
104      configuration['svnVersion']='stable/'+lsv
105    elif bc['SvnVersion']=='latestRelease' :
106      lrv=NBsvnCommand.latestReleaseVersion(p)
107      if not lrv :
108        print 'Error. BUILDS configured to use lastest release svn version'
109        print '       Project does not have a release version'
110        print '       Project is '+p
111        print '       BuildConfig is '+str(bc)
112        sys.exit(1)
113      configuration['svnVersion']='releases/'+lrv
[676]114    else:
115      configuration['svnVersion']=bc['SvnVersion']
116
117    #--------------------------------------------------------------------
118    # Setup usage of 3rd Party code
119    #--------------------------------------------------------------------
120    if 'noThirdParty' in configuration: configuration.pop('noThirdParty')
121    if 'ThirdParty' in bc:
122      if bc['ThirdParty'].lower()=='yes' :
123        configuration['noThirdParty']=False
124      else:
125        configuration['noThirdParty']=True
126
127    #--------------------------------------------------------------------
128    # Set config options
129    #--------------------------------------------------------------------
130    configuration['configOptions']={}
131    configuration['configOptions']['unique']=""
132    configuration['configOptions']['invariant']=""
133    if 'OptLevel' not in bc :
134      print 'Error. BUILDS does not contain OptLevel'
135      print '       Project is '+p
136      print '       BuildConfig is '+str(bc)
137      sys.exit(1)
138    if bc['OptLevel']=='Debug' :
139      configuration['configOptions']['unique']+=" --enable-debug"
140    if 'AdditionalConfigOptions' in bc :
141      configuration['configOptions']['unique']+=" "+bc['AdditionalConfigOptions']
142
[692]143    configuration['configOptions']['invariant']+=" "+ CONFIGURE_FLAGS
[676]144
145    #--------------------------------------------------------------------
146    # Deal with coin projects to be skipped by ./config
147    #--------------------------------------------------------------------
148    if 'SkipProjects' in configuration: configuration.pop('SkipProjects')
149    if 'SkipProjects' in bc :
150      configuration['SkipProjects']=bc['SkipProjects']
151
152    #---------------------------------------------------------------------
153    # Setup checkMakeTest
154    #---------------------------------------------------------------------
[730]155    #configuration['checkMakeTest']=NBcheckResult.didTestFail
156    configuration['checkMakeTest']=NBprojectConfig.CHECK_MAKE_TEST[p]
[676]157
158
159    #---------------------------------------------------------------------
160    # Set up unitTest
161    #---------------------------------------------------------------------
162    configuration['unitTest']={}
163    if NBprojectConfig.UNITTEST_CMD.has_key(p) :
164
165      unitTestCmdTemplate=NBprojectConfig.UNITTEST_CMD[p]
166      unitTestCmd=unitTestCmdTemplate.replace('_NETLIBDIR_',netlibDir)
167      unitTestCmd=unitTestCmd.replace('_MIPLIB3DIR_',miplib3Dir)
168
169      configuration['unitTest']['command']=unitTestCmd
[730]170      configuration['unitTest']['checkUnitTest']=NBprojectConfig.CHECK_UNITTEST[p]
[676]171      configuration['unitTest']['path']=NBprojectConfig.UNITTEST_DIR[p]
172
173    else :
174      # No unitTest so remove from configuration
175      configuration.pop('unitTest')
176
177    #--------------------------------------------------
178    # Build & Test the configuration
179    #--------------------------------------------------
180    NBbuildConfig.run(configuration)
181
182
183NBlogMessages.writeMessage( "nightlyBuild.py Finished" )
184
185sys.exit(0)
186
Note: See TracBrowser for help on using the repository browser.