2015-04-25 16:30:32 -04:00
|
|
|
#!/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' )
|
|
|
|
DIR_OF_YCMD_THIRD_PARTY = p.join( DIR_OF_THIRD_PARTY, 'ycmd', '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 ) ) )
|
|
|
|
for folder in os.listdir( DIR_OF_YCMD_THIRD_PARTY ):
|
|
|
|
python_path.append( p.abspath( p.join( DIR_OF_YCMD_THIRD_PARTY, folder ) ) )
|
|
|
|
if os.environ.get( 'PYTHONPATH' ):
|
|
|
|
python_path.append( os.environ[ 'PYTHONPATH' ] )
|
|
|
|
os.environ[ 'PYTHONPATH' ] = os.pathsep.join( python_path )
|
|
|
|
|
2015-11-08 17:26:28 -05:00
|
|
|
sys.path.insert( 1, p.abspath( p.join( DIR_OF_YCMD_THIRD_PARTY,
|
|
|
|
'argparse' ) ) )
|
2015-04-25 16:30:32 -04:00
|
|
|
|
2015-11-08 17:26:28 -05:00
|
|
|
import argparse
|
2015-04-25 16:30:32 -04:00
|
|
|
|
|
|
|
def RunFlake8():
|
|
|
|
print( 'Running flake8' )
|
|
|
|
subprocess.check_call( [
|
|
|
|
'flake8',
|
|
|
|
'--select=F,C9',
|
|
|
|
'--max-complexity=10',
|
|
|
|
p.join( DIR_OF_THIS_SCRIPT, 'python' )
|
|
|
|
] )
|
|
|
|
|
|
|
|
|
|
|
|
def ParseArguments():
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
parser.add_argument( '--skip-build', action = 'store_true',
|
|
|
|
help = 'Do not build ycmd before testing.' )
|
|
|
|
|
2015-12-21 14:40:51 -05:00
|
|
|
return parser.parse_known_args()
|
2015-04-25 16:30:32 -04:00
|
|
|
|
|
|
|
|
|
|
|
def BuildYcmdLibs( args ):
|
|
|
|
if not args.skip_build:
|
|
|
|
subprocess.check_call( [
|
|
|
|
sys.executable,
|
|
|
|
p.join( DIR_OF_THIS_SCRIPT, 'third_party', 'ycmd', 'build.py' )
|
|
|
|
] )
|
|
|
|
|
|
|
|
|
2015-12-21 14:40:51 -05:00
|
|
|
def NoseTests( extra_args ):
|
2015-04-25 16:30:32 -04:00
|
|
|
subprocess.check_call( [
|
|
|
|
'nosetests',
|
|
|
|
'-v',
|
2015-12-21 14:40:51 -05:00
|
|
|
'-w',
|
2015-04-25 16:30:32 -04:00
|
|
|
p.join( DIR_OF_THIS_SCRIPT, 'python' )
|
2015-12-21 14:40:51 -05:00
|
|
|
] + extra_args )
|
2015-04-25 16:30:32 -04:00
|
|
|
|
|
|
|
|
|
|
|
def Main():
|
2015-12-21 14:40:51 -05:00
|
|
|
( parsed_args, extra_args ) = ParseArguments()
|
2015-04-25 16:30:32 -04:00
|
|
|
RunFlake8()
|
|
|
|
BuildYcmdLibs( parsed_args )
|
2015-12-21 14:40:51 -05:00
|
|
|
NoseTests( extra_args )
|
2015-04-25 16:30:32 -04:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
Main()
|