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

File Contents

# Content
1 from __future__ import print_function
2
3 import os
4 import sys
5
6 import unittest
7
8 def _find_raydir():
9 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 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 '''return the full path to file in bin dir'''
24 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 '''return the full path to file in data dir'''
30 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 print(' failed')
38 print('-----------------------------')
39 for e in res.errors:
40 print(e[1])
41 for e in res.failures:
42 es = e[1].strip()
43 sl = '\n'.split(es)
44 print(sl[-1])
45 print('-----------------------------')
46 else:
47 print(' ok')
48