/[escript]/trunk/tools/testrunner.py
ViewVC logotype

Contents of /trunk/tools/testrunner.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5707 - (show annotations)
Mon Jun 29 03:59:06 2015 UTC (3 years, 6 months ago) by sshaw
File MIME type: text/x-python
File size: 3112 byte(s)
adding copyright headers to files without copyright info, moved header to top of file in some cases where it wasn't
1
2 ##############################################################################
3 #
4 # Copyright (c) 2003-2015 by The University of Queensland
5 # http://www.uq.edu.au
6 #
7 # Primary Business: Queensland, Australia
8 # Licensed under the Open Software License version 3.0
9 # http://www.opensource.org/licenses/osl-3.0.php
10 #
11 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 # Development 2012-2013 by School of Earth Sciences
13 # Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 #
15 ##############################################################################
16 from __future__ import print_function, division
17 import sys
18
19 fail_format = """======================================================================
20 FAIL: {0} {1}
21 ----------------------------------------------------------------------
22 {2}
23 ----------------------------------------------------------------------
24 """
25
26 def rearrange(string):
27 parts = string.split()
28 parts = [parts[1][1:-1], parts[0]]
29 return ".".join(parts)
30
31 def rearrange_to_default(string):
32 parts = string.split()
33 print(parts)
34 return ".".join(parts)
35
36 def run_tests(modules, exit_on_failure=False):
37 skiplist = []
38 faillist = []
39 for module in modules:
40 if module[-3:] == ".py":
41 module = module[:-3]
42 m = __import__(module)
43 res = m.run_tests(module, exit_on_failure=exit_on_failure)
44 skiplist.extend(["%s : %s\n"%(rearrange(str(i[0])),i[1]) for i in res.skipped])
45 faillist.extend([fail_format.format(str(i[0]).split()[0],str(i[0]).split()[1], i[1]) for i in res.failures+res.errors])
46 return skiplist, faillist
47
48 if __name__ == "__main__":
49 modules = sys.argv[1:]
50 if len(modules) == 0:
51 print("%s missing argument, provide module to run tests on"%sys.argv[0])
52 sys.exit(1)
53 skipfile = None
54 skipappendfile = None
55 failfile = None
56 failappendfile = None
57 exit = False
58 n = 0
59 while n < len(modules):
60 m = modules[n]
61 if m.startswith("-skipfile="):
62 modules.pop(n)
63 skipfile = m.split("=")[1]
64 continue
65 if m.startswith("-skipappendfile="):
66 modules.pop(n)
67 skipappendfile = m.split("=")[1]
68 continue
69 if m.startswith("-failfile="):
70 modules.pop(n)
71 failfile = m.split("=")[1]
72 continue
73 if m.startswith("-failappendfile="):
74 modules.pop(n)
75 failappendfile = m.split("=")[1]
76 continue
77 if m == "-exit":
78 modules.pop(n)
79 exit = True
80 continue
81 n += 1
82
83 skipped, failed = run_tests(modules, exit_on_failure=exit)
84 if skipfile:
85 open(skipfile, "w").writelines("".join(skipped))
86 elif skipappendfile:
87 open(skipappendfile, "a").writelines("".join(skipped))
88 else:
89 print("".join(skipped))
90
91 if failfile:
92 open(failfile, "w").writelines("".join(failed))
93 elif failappendfile:
94 open(failappendfile, "a").writelines("".join(failed))
95 else:
96 print("".join(failed))

  ViewVC Help
Powered by ViewVC 1.1.26