-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathruntestmodule.py
executable file
·52 lines (48 loc) · 2.03 KB
/
runtestmodule.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python3
#
# Copyright (C) 2019 Mark Jenkins <[email protected]>
# This file is part of knightpies
#
# knightpies is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# knightpies is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with knightpies. If not, see <http://www.gnu.org/licenses/>.
from sys import argv
from os.path import split as path_split, join as path_join, splitext, exists
from unittest import main
from itertools import chain
import knighttests.testflags
def recursively_get_package_components(path):
if exists(path_join(path, "__init__.py")):
parent, child = path_split(path)
yield from recursively_get_package_components(parent)
yield child
def get_module_for_file(filepath):
path_to, filename = path_split(filepath)
modulename, ext = splitext(filename)
return '.'.join(
chain(recursively_get_package_components(path_to),
(modulename,)
) # chain
) # join
if __name__ == "__main__":
if len(argv)>1:
sys_argv_after_prog = argv[1:]
if '--skip-optimize' in sys_argv_after_prog:
knighttests.testflags.OPTIMIZE_SKIP = True
sys_argv_after_prog = [a for a in sys_argv_after_prog
if a != '--skip-optimize' ]
if '--skip-diff-reg-size' in sys_argv_after_prog:
knighttests.testflags.DIFF_REG_SIZE_SKIP = True
sys_argv_after_prog = [ a for a in sys_argv_after_prog
if a != '--skip-diff-reg-size' ]
main( module=get_module_for_file(
sys_argv_after_prog[0]), argv=(argv[0],) )