COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
plot-test-result.py
Go to the documentation of this file.
1 #!python
2 # -*- coding: utf-8 -*-
3 
4 import matplotlib
5 matplotlib.use('AGG')
6 import sys
7 import subprocess
8 import numpy as np
9 import pylab
10 import os
11 
12 var_prefix = 'PyVar'
13 
14 # process arguments
15 test_command = sys.argv[1]
16 
17 # run the test
18 p = subprocess.Popen(test_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
19 
20 # print test output in case of error
21 if p.wait() != 0:
22  for line in p.stdout:
23  print line,
24  for line in p.stderr:
25  print line,
26  raise RuntimeError("Test exited with error")
27 
28 # expects a list of lines that are ordered: title, X-values, Y-values, legend label
29 varnames = []
30 for line in p.stdout:
31  if line.startswith(var_prefix):
32  varnames.append(line.split('=')[0].strip().replace(var_prefix, ''))
33  exec(line.replace(var_prefix, ''))
34  if len(varnames) == 3:
35  pylab.plot(locals()[varnames[0]], locals()[varnames[1]], label=locals()[varnames[2]])
36  pylab.xlabel(varnames[0])
37  pylab.ylabel(varnames[1])
38  varnames = []
39 
40 pylab.grid(True)
41 pylab.legend()
42 
43 fig_filename = test_command.split('/')[-1] + '.png'
44 pylab.savefig(fig_filename)
45 print '<DartMeasurementFile name="Graph" type="image/png">' + os.path.join(os.path.dirname(test_command), fig_filename) + '</DartMeasurementFile>'
46 pylab.clf()
Send comments to:
COOLFluiD Web Admin