5 This script is automatically generated by 'command sat test etc...'
6 from ...salomeTools/src/test/scriptTemplate.py
13 import time as THEBIGTIME
17 toolsWay = r'${toolsWay}'
18 resourcesWay = r'${resourcesWay}'
19 outWay = r'${sessionDir}'
22 listTest = ${listTest}
25 sys.path.append(toolsWay)
26 from TOOLS import TOOLS_class
27 my_tools = TOOLS_class(resourcesWay, tmpDir, toolsWay)
29 from TOOLS import SatNotApplicableError
31 # set environement variables
32 os.environ['TT_BASE_RESSOURCES'] = resourcesWay
33 sys.path.append(resourcesWay)
35 __stdout__ = sys.stdout
36 __stderr__ = sys.stderr
38 with open(r'${resultFile}', 'w') as exec_result:
39 exec_result.write('Open\n')
40 print("wrapper ignore tests: %s" % ignore)
42 fileTest = os.path.join(outWay, test)
43 # print("test file: %s" % fileTest) # cvw TODO
44 with open(os.path.join(outWay, test[:-3] + ".result.py"), "w") as pylog:
45 with open(os.path.join(outWay, test[:-3] + ".out.py"), "w") as testout:
47 # print("here set sys.stdout")
51 # pylog.write('#!/usr/bin/env python\n')
52 exec_result.write("Run %s " % test)
56 timeStart = THEBIGTIME.time()
57 # cd ..print("begin... %s" % fileTest)
58 # execfile(fileTest, globals(), locals()) obsolete python3
59 with open(fileTest) as f:
60 # compile associates the filename with the code object making debugging a little easier
61 code = compile(f.read(), fileTest, 'exec')
62 exec(code, globals(), locals())
63 timeTest = THEBIGTIME.time() - timeStart
64 # print("...done %s" % fileTest)
65 timeTest = THEBIGTIME.time() - timeStart
66 except SatNotApplicableError as ex:
67 # print("here SatNotApplicableError")
68 # pylog.write("here SatNotApplicableError")
71 exec_result.write("NA\n")
72 timeTest = THEBIGTIME.time() - timeStart
73 pylog.write('status = "NA"\n')
74 pylog.write('time = "' + timeTest.__str__() + '"\n')
75 pylog.write('callback = "%s"\n' % reason)
76 except Exception as ex:
77 # print("here Exception")
78 # pylog.write("here Exception pylog\n")
83 reason = "Known Failure = %s\n\n" % ignore[test]
84 exec_result.write("%s\n" % status)
85 timeTest = THEBIGTIME.time() - timeStart
86 pylog.write('status = "%s" \n' % status)
87 pylog.write('time = "' + timeTest.__str__() + '"\n')
88 pylog.write('callback="""' + reason)
89 exc_type, exc_value, exc_traceback = sys.exc_info()
90 traceback.print_exception(exc_type,
98 # pylog.write("here else pylog")
99 exec_result.write("OK\n")
100 pylog.write('status = "OK"\n')
101 pylog.write('time = "' + timeTest.__str__() + '"\n')
104 # print("here testout.flush")
108 # print("here restore sys.stdout")
109 sys.stdout = __stdout__
110 sys.stderr = __stderr__
111 my_tools.writeInFiles(pylog)
116 exec_result.write('Close\n')
118 # exec_result.close()
120 if 'PY' not in '${sessionName}':
122 #killScript = os.path.join(os.environ['KERNEL_ROOT_DIR'],
126 #cmd = '{python} {killScript} {port}'.format(python=os.environ['PYTHONBIN'],
127 # killScript=killScript,
128 # port=salome_utils.getPortNumber())
129 cmd = 'killSalome.py {port}'.format( port=salome_utils.getPortNumber())