forked from arrayfire/arrayfire-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__main__.py
More file actions
51 lines (38 loc) · 1.31 KB
/
__main__.py
File metadata and controls
51 lines (38 loc) · 1.31 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python
#######################################################
# Copyright (c) 2019, ArrayFire
# All rights reserved.
#
# This file is distributed under 3-clause BSD license.
# The complete license agreement can be obtained at:
# http://arrayfire.com/licenses/BSD-3-Clause
########################################################
from __future__ import absolute_import
import sys
from . import simple
tests = {}
tests['simple'] = simple.tests
def assert_valid(name, name_list, name_str):
is_valid = any([name == val for val in name_list])
if is_valid:
return
err_str = "The first argument needs to be a %s name\n" % name_str
err_str += "List of supported %ss: %s" % (name_str, str(list(name_list)))
raise RuntimeError(err_str)
if __name__ == "__main__":
module_name = None
num_args = len(sys.argv)
if num_args > 1:
module_name = sys.argv[1].lower()
assert_valid(sys.argv[1].lower(), tests.keys(), "module")
if module_name is None:
for name in tests:
tests[name].run()
else:
test = tests[module_name]
test_list = None
if num_args > 2:
test_list = sys.argv[2:]
for test_name in test_list:
assert_valid(test_name.lower(), test.keys(), "test")
test.run(test_list)