ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/Development/ray/test/py_tests/unit_tools/support.py
Revision: 1.3
Committed: Thu Mar 10 01:49:56 2016 UTC (9 years, 9 months ago) by schorsch
Content type: text/x-python
Branch: MAIN
CVS Tags: rad6R0, rad5R4, rad5R3, rad5R2, rad5R1, HEAD
Changes since 1.2: +9 -9 lines
Log Message:
SCons build system learns about platform architecture

File Contents

# User Rev Content
1 schorsch 1.3 from __future__ import print_function
2 schorsch 1.1
3     import os
4 schorsch 1.2 import sys
5 schorsch 1.1
6     import unittest
7    
8     def _find_raydir():
9 schorsch 1.2 if __name__ == '__main__':
10     thisfile = sys.argv[0]
11     else: thisfile = sys.modules[__name__].__file__
12     unit_tools = os.path.abspath(os.path.dirname(thisfile))
13     py_tests = os.path.dirname(unit_tools)
14     test = os.path.dirname(py_tests)
15     raydir = os.path.dirname(test)
16 schorsch 1.1 return raydir
17    
18     RAYDIR = _find_raydir()
19     DATADIR = os.path.join(RAYDIR, 'test', 'test data')
20     BINDIR = os.path.join(RAYDIR, 'bin')
21    
22     def binfile(fn):
23 schorsch 1.2 '''return the full path to file in bin dir'''
24 schorsch 1.1 if os.name == 'nt':
25     return os.path.normpath(os.path.join(BINDIR, fn + '.exe'))
26     else: return os.path.normpath(os.path.join(BINDIR, fn))
27    
28     def datafile(fn):
29 schorsch 1.2 '''return the full path to file in data dir'''
30 schorsch 1.1 return os.path.normpath(os.path.join(DATADIR, fn))
31    
32     def run_case(c):
33     res = unittest.TestResult()
34     s = unittest.makeSuite(c, 'test')
35     s.run(res)
36     if res.errors or res.failures:
37 schorsch 1.3 print(' failed')
38     print('-----------------------------')
39 schorsch 1.1 for e in res.errors:
40 schorsch 1.3 print(e[1])
41 schorsch 1.1 for e in res.failures:
42 schorsch 1.3 es = e[1].strip()
43     sl = '\n'.split(es)
44     print(sl[-1])
45     print('-----------------------------')
46 schorsch 1.1 else:
47 schorsch 1.3 print(' ok')
48 schorsch 1.1