Script edna_test_launcher_py
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 __authors__ = ["Olof Svensson", "Jerome Kieffer"]
31 __contact__ = "svensson@esrf.fr"
32 __license__ = "GPLv3"
33 __date__ = "2010-02-02"
34 __copyright__ = "ESRF"
35
36
37
38
39
40
41 import sys, os.path
42 cwd = os.getcwd()
43 pyStrProgramPath = os.path.abspath(sys.argv[0])
44 pyStrBinPath = os.path.split(pyStrProgramPath)[0]
45 pyStrKernelPath = os.path.split(pyStrBinPath)[0]
46 pyStrEdnaHomePath = os.path.split(pyStrKernelPath)[0]
47 os.environ["EDNA_HOME"] = pyStrEdnaHomePath
48
49
50 profiling = False
51 verbose = False
52 if len(sys.argv) > 1:
53 for argument in sys.argv[1:]:
54 if argument.lower().find("--verbose") in [1, 0]:
55 verbose = True
56 elif argument.lower().find("-profile") in [1, 0]:
57 profiling = True
58 import cProfile
59 elif argument.endswith(".py"):
60 sys.argv[sys.argv.index(argument)] = argument[:-3]
61 else:
62 print('\nThis is the EDNA testing utility.\n\nYou did not provide any test to execute, like \n %s --test EDTestSuiteKernel\nto execute the test suite of the EDNA kernel.' % sys.argv[0])
63 print('Other useful options are --profile and --DEBUG\n')
64
65 if not verbose:
66 sys.argv.append("--verbose")
67
68
69
70 sys.path.append(os.path.join(pyStrEdnaHomePath, "kernel", "src"))
71 sys.path.append(os.path.join(pyStrEdnaHomePath, "kernel", "tests", "src"))
72
73
74
75
76 from EDTestLauncher import EDTestLauncher
77 edTestLauncher = EDTestLauncher()
78
79 if profiling == True:
80 print("Running in Profiling Mode")
81 cProfile.run('edTestLauncher.execute()', filename=os.path.join(cwd, 'profile.log'))
82 else:
83 edTestLauncher.execute()
84
85 if edTestLauncher.isFailure():
86 sys.exit(1)
87