1414
1515# ----------
1616
17+ def PrintMessage (message ):
18+ print >> sys .stdout , message
19+ sys .stdout .flush ()
20+
1721class Package :
1822 def __init__ (self , root , name , version ):
1923 self .root = root
@@ -51,7 +55,7 @@ def GetName(self):
5155def FindAllPackagesToTest (root , options ):
5256 """Locate packages that can be tested"""
5357 if options .verbose :
54- print "Locating packages under '%s'" % root
58+ PrintMessage ( "Locating packages under '%s'" % root )
5559 tests = []
5660 dirs = os .listdir (root )
5761 dirs .sort ()
@@ -71,7 +75,7 @@ def FindAllPackagesToTest(root, options):
7175 raise RuntimeError ("Too many XML files found in %s to identify a package definition file" % bamDir )
7276 package = Package (xmlFiles [0 ])
7377 if options .verbose :
74- print "\t %s" % package .GetId ()
78+ PrintMessage ( "\t %s" % package .GetId () )
7579 tests .append (package )
7680 return tests
7781
@@ -99,7 +103,7 @@ def _runBuildAMation(options, package, extraArgs, outputMessages, errorMessages)
99103 argList .append ("--clean" )
100104 if extraArgs :
101105 argList .extend (extraArgs )
102- print " " .join (argList )
106+ PrintMessage ( " " .join (argList ) )
103107 p = subprocess .Popen (argList , stdout = subprocess .PIPE , stderr = subprocess .PIPE , cwd = package .GetPath ())
104108 (outputStream , errorStream ) = p .communicate () # this should WAIT
105109 if outputStream :
@@ -115,23 +119,23 @@ def _postExecute(builder, options, package, outputMessages, errorMessages):
115119 return 0
116120
117121def ExecuteTests (package , configuration , options , args , outputBuffer ):
118- print "Package : " , package .GetId ()
122+ PrintMessage ( "Package : %s" % package .GetId () )
119123 if options .verbose :
120- print "Description : " , package .GetDescription ()
121- print "Available build modes:" , configuration .GetBuildModes ()
124+ PrintMessage ( "Description : %s" % package .GetDescription () )
125+ PrintMessage ( "Available build modes: %s" % configuration .GetBuildModes () )
122126 if not options .buildmode in configuration .GetBuildModes ():
123127 outputBuffer .write ("IGNORED: Package '%s' does not support build mode '%s' in the test configuration\n " % (package .GetDescription (),options .buildmode ))
124- print "\t Ignored"
128+ PrintMessage ( "\t Ignored" )
125129 return 0
126130 variationArgs = configuration .GetVariations (options .buildmode , options .excludeResponseFiles )
127131 if len (variationArgs ) == 0 :
128132 outputBuffer .write ("IGNORED: Package '%s' has no response file with the current options\n " % package .GetDescription ())
129- print "\t Ignored"
133+ PrintMessage ( "\t Ignored" )
130134 return 0
131135 if options .verbose :
132- print "Response filenames: " , variationArgs
136+ PrintMessage ( "Response filenames: %s" % variationArgs )
133137 if options .excludeResponseFiles :
134- print " (excluding" , options .excludeResponseFiles , ")"
138+ PrintMessage ( " (excluding %s)" % options .excludeResponseFiles )
135139 nonKWArgs = []
136140 for arg in args :
137141 if '=' in arg :
@@ -158,7 +162,7 @@ def ExecuteTests(package, configuration, options, args, outputBuffer):
158162 if returncode == 0 :
159163 returncode = _postExecute (theBuilder , options , package , outputMessages , errorMessages )
160164 except Exception , e :
161- print "Popen exception: '%s'" % str (e )
165+ PrintMessage ( "Popen exception: '%s'" % str (e ) )
162166 raise
163167 finally :
164168 message = "Package '%s'" % package .GetDescription ()
@@ -195,7 +199,7 @@ def CleanUp(options):
195199 else :
196200 argList .append (os .path .join (os .getcwd (), "removedebugprojects.sh" ))
197201 if options .verbose :
198- print "Executing: " , argList
202+ PrintMessage ( "Executing: %s" % argList )
199203 p = subprocess .Popen (argList )
200204 p .wait ()
201205
@@ -235,8 +239,8 @@ def FindBamDefaultRepository():
235239 raise RuntimeError ("No package repositories to test" )
236240
237241 if options .verbose :
238- print "Options are " , options
239- print "Args are " , args
242+ PrintMessage ( "Options are %s" % options )
243+ PrintMessage ( "Args are %s" % args )
240244
241245 #if not options.platforms:
242246 # raise RuntimeError("No platforms were specified")
@@ -252,17 +256,17 @@ def FindBamDefaultRepository():
252256 repoTestDir = os .path .join (repo , "tests" )
253257 bamTestsConfigPathname = os .path .join (repoTestDir , 'bamtests.py' )
254258 if not os .path .isfile (bamTestsConfigPathname ):
255- print "Package repository %s has no bamtests.py file" % repo
259+ PrintMessage ( "Package repository %s has no bamtests.py file" % repo )
256260 continue
257261 bamtests = imp .load_source ('bamtests' , bamTestsConfigPathname )
258262 testConfigs = bamtests .ConfigureRepository ()
259263 tests = FindAllPackagesToTest (repoTestDir , options )
260264 if not options .tests :
261265 if options .verbose :
262- print "All tests will run"
266+ PrintMessage ( "All tests will run" )
263267 else :
264268 if options .verbose :
265- print "Tests to run are: " , options .tests
269+ PrintMessage ( "Tests to run are: %s" % options .tests )
266270 filteredTests = []
267271 for test in options .tests :
268272 found = False
@@ -281,18 +285,18 @@ def FindBamDefaultRepository():
281285 config = testConfigs [package .GetId ()]
282286 except KeyError , e :
283287 if options .verbose :
284- print "No configuration for package: '%s'" % str (e )
288+ PrintMessage ( "No configuration for package: '%s'" % str (e ) )
285289 continue
286290 exitCode += ExecuteTests (package , config , options , args , outputBuffer )
287291
288292 if not options .keepFiles :
289293 # TODO: consider keeping track of all directories created instead
290294 CleanUp (options )
291295
292- print "--------------------"
293- print "| Results summary |"
294- print "--------------------"
295- print outputBuffer .getvalue ()
296+ PrintMessage ( "--------------------" )
297+ PrintMessage ( "| Results summary |" )
298+ PrintMessage ( "--------------------" )
299+ PrintMessage ( outputBuffer .getvalue () )
296300
297301 logsDir = os .path .join (repoTestDir , "Logs" )
298302 if not os .path .isdir (logsDir ):
0 commit comments