forked from ycm-core/ycmd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_tests.py
executable file
·147 lines (118 loc) · 5.19 KB
/
run_tests.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/usr/bin/env python
import os
import subprocess
import os.path as p
import sys
DIR_OF_THIS_SCRIPT = p.dirname( p.abspath( __file__ ) )
DIR_OF_THIRD_PARTY = p.join( DIR_OF_THIS_SCRIPT, 'third_party' )
python_path = []
for folder in os.listdir( DIR_OF_THIRD_PARTY ):
python_path.append( p.abspath( p.join( DIR_OF_THIRD_PARTY, folder ) ) )
if os.environ.get( 'PYTHONPATH' ) is not None:
python_path.append( os.environ['PYTHONPATH'] )
os.environ[ 'PYTHONPATH' ] = os.pathsep.join( python_path )
sys.path.insert( 1, p.abspath( p.join( DIR_OF_THIRD_PARTY, 'argparse' ) ) )
import argparse
def RunFlake8():
print( 'Running flake8' )
subprocess.check_call( [
'flake8',
'--select=F,C9',
'--max-complexity=10',
'--exclude=testdata',
p.join( DIR_OF_THIS_SCRIPT, 'ycmd' )
] )
def ParseArguments():
parser = argparse.ArgumentParser()
parser.add_argument( '--no-clang-completer', action = 'store_true',
help = 'Do not test C-family '
'semantic completion engine.' )
parser.add_argument( '--no-omnisharp-completer', action = 'store_true',
help = 'Do not test C# '
'semantic completion engine.' )
parser.add_argument( '--no-tern-completer', action = 'store_true',
help = 'Do not test Javascript '
'semantic completion engine.' )
parser.add_argument( '--no-gocode-completer', action = 'store_true',
help = 'Do not test GoCode '
'semantic completion engine.' )
parser.add_argument( '--no-racer-completer', action = 'store_true',
help = 'Do not test Racer '
'semantic completion engine.' )
parser.add_argument( '--no-typescript-completer', action = 'store_true',
help = 'Do not test TypeScript '
'semantic completion engine.' )
parser.add_argument( '--no-python-completer', action = 'store_true',
help = 'Do not test Jedi'
'semantic completion engine.' )
parser.add_argument( '--skip-build', action = 'store_true',
help = 'Do not build ycmd before testing.' )
parser.add_argument( '--msvc', type = int, choices = [ 11, 12, 14 ],
help = 'Choose the Microsoft Visual '
'Studio version. (default: 14).' )
parser.add_argument( '--arch', type = int, choices = [ 32, 64 ],
help = 'Force architecture to 32 or 64 bits on '
'Windows (default: python interpreter architecture).' )
parser.add_argument( '--coverage', action = 'store_true',
help = 'Enable coverage report (requires coverage pkg)' )
parsed_args, nosetests_args = parser.parse_known_args()
if 'USE_CLANG_COMPLETER' in os.environ:
parsed_args.no_clang_completer = ( os.environ[ 'USE_CLANG_COMPLETER' ]
== 'false' )
if 'COVERAGE' in os.environ:
parsed_args.coverage = ( os.environ[ 'COVERAGE' ] == 'true' )
return parsed_args, nosetests_args
def BuildYcmdLibs( args ):
if not args.skip_build:
extra_cmake_args = [ '-DUSE_DEV_FLAGS=ON' ]
if not args.no_clang_completer:
extra_cmake_args.append( '-DUSE_CLANG_COMPLETER=ON' )
os.environ[ 'EXTRA_CMAKE_ARGS' ] = ' '.join(extra_cmake_args)
os.environ[ 'YCM_TESTRUN' ] = '1'
build_cmd = [
sys.executable,
p.join( DIR_OF_THIS_SCRIPT, 'build.py' ),
]
if not args.no_omnisharp_completer:
build_cmd.extend( [ '--omnisharp-completer' ] )
if not args.no_tern_completer:
build_cmd.extend( [ '--tern-completer' ] )
if not args.no_gocode_completer:
build_cmd.extend( [ '--gocode-completer' ] )
if not args.no_racer_completer:
build_cmd.extend( [ '--racer-completer' ] )
if args.msvc:
build_cmd.extend( [ '--msvc', str( args.msvc ) ] )
if args.arch:
build_cmd.extend( [ '--arch', str( args.arch ) ] )
subprocess.check_call( build_cmd )
def NoseTests( parsed_args, extra_nosetests_args ):
nosetests_args = [ '-v' ]
if parsed_args.no_clang_completer:
nosetests_args.append( '--exclude=.*Clang.*' )
if parsed_args.no_tern_completer:
nosetests_args.append( '--exclude=.*Javascript.*' )
if parsed_args.no_gocode_completer:
nosetests_args.append( '--exclude=.*GoCode.*' )
if parsed_args.no_racer_completer:
nosetests_args.append( '--exclude=.*Rust.*' )
if parsed_args.no_typescript_completer:
nosetests_args.append( '--exclude=.*TypeScript.*' )
if parsed_args.no_omnisharp_completer:
nosetests_args.append( '--exclude=.*Cs.*' )
if parsed_args.no_python_completer:
nosetests_args.append( '--exclude=.*Python.*' )
if parsed_args.coverage:
nosetests_args += [ '--with-coverage', '--cover-package=ycmd' ]
if extra_nosetests_args:
nosetests_args.extend( extra_nosetests_args )
else:
nosetests_args.append( p.join( DIR_OF_THIS_SCRIPT, 'ycmd' ) )
subprocess.check_call( [ 'nosetests' ] + nosetests_args )
def Main():
parsed_args, nosetests_args = ParseArguments()
RunFlake8()
BuildYcmdLibs( parsed_args )
NoseTests( parsed_args, nosetests_args )
if __name__ == "__main__":
Main()