Skip to content

Commit

Permalink
Merge eb9bbbe into e4ba41a
Browse files Browse the repository at this point in the history
  • Loading branch information
mispencer committed Feb 2, 2016
2 parents e4ba41a + eb9bbbe commit 5a304dd
Show file tree
Hide file tree
Showing 21 changed files with 125 additions and 39 deletions.
14 changes: 12 additions & 2 deletions TESTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on Travis CI. These can be found in `.travis.yml` and `./travis` directory.
You need to have installed:

* nose (pip install nose)
* nose-exclude (pip install nose-exclude)
* mock (pip install mock)
* flake8 (pip install flake8)
* webtest (pip install webtest)
Expand All @@ -34,6 +35,10 @@ installation guide for details, but typically this involves manually installing:
* node
* npm

If you are unwilling or unable to install the requirements for all of the
completers, you can exclude certain completers with the `--no-completer`
option.

### mono non-standard path

Note: if your installation of mono is in a non-standard location,
Expand All @@ -46,8 +51,13 @@ To run the full suite, just run `run_tests.py`. Options are:

* `--skip-build`: don't attempt to run the build `build.py`, e.g. if you use
a non-standard build environment (e.g. `cmake28`, self-build of clang, etc.)
* `--no-clang-completer`: don't attempt to test the clang completer. Can also
be set via environment variable `USE_CLANG_COMPLETER`.
* `--no-completers`: Do not build or test with listed semantic completion engine(s).
* `--completers`: Only build and test with listed semantic completion engine(s).
* `--msvc`: The Microsoft Visual Studio version to build with.
(default: 14). Windows only.
* `--arch`: Force architecture to 32 or 64 bits on Windows (default: python
interpreter architecture). Windows Only.
* `--coverage`: Output test coverage report

Remaining arguments are passed to "nosetests" directly. This means that you
can run a specific script or a specific test as follows:
Expand Down
101 changes: 88 additions & 13 deletions run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,73 @@ def RunFlake8():
] )


COMPLETERS = {
'cfamily': {
'build': [ '--clang-completer' ],
'test': [ '--exclude-dir=ycmd/tests/clang' ],
'aliases': [ 'c', 'cpp', 'c++', 'objc', 'clang', ]
},
'cs': {
'build': [ '--omnisharp-completer' ],
'test': [ '--exclude-dir=ycmd/tests/cs' ],
'aliases': [ 'omnisharp', 'csharp', 'c#' ]
},
'javascript': {
'build': [ '--tern-completer' ],
'test': [ '--exclude-dir=ycmd/tests/javascript' ],
'aliases': [ 'js', 'tern' ]
},
'go': {
'build': [ '--gocode-completer' ],
'test': [ '--exclude-dir=ycmd/tests/go' ],
'aliases': [ 'gocode' ]
},
'rust': {
'build': [ '--racer-completer' ],
'test': [ '--exclude-dir=ycmd/tests/rust' ],
'aliases': [ 'racer', 'racerd', ]
},
'typescript': {
'build': [],
'test': [ '--exclude-dir=ycmd/tests/typescript' ],
'aliases': []
},
'python': {
'build': [],
'test': [ '--exclude-dir=ycmd/tests/python' ],
'aliases': [ 'jedi', 'jedihttp', ]
},
}


def CompleterType( value ):
value = value.lower()
if value in COMPLETERS:
return value
else:
aliases_to_completer = dict( (i,k) for k,v in COMPLETERS.iteritems()
for i in v[ 'aliases' ] )
if value in aliases_to_completer:
return aliases_to_completer[ value ];
else:
raise argparse.ArgumentTypeError(
'{0} is not a valid completer - should be one of {1}'.format(
value, COMPLETERS.keys() ) )


def ParseArguments():
parser = argparse.ArgumentParser()
parser.add_argument( '--no-clang-completer', action = 'store_true',
help = 'Do not test C-family '
'semantic completion engine.' )
group = parser.add_mutually_exclusive_group()
group.add_argument( '--no-clang-completer', action = 'store_true',
help = argparse.SUPPRESS ) # deprecated
group.add_argument( '--no-completers', nargs ='*', type = CompleterType,
help = 'Do not build or test with listed semantic '
'completion engine(s). Valid values: {0}'.format(
COMPLETERS.keys()) )
group.add_argument( '--completers', nargs ='*', type = CompleterType,
help = 'Only build and test with listed semantic '
'completion engine(s). Valid values: {0}'.format(
COMPLETERS.keys()) )
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 ],
Expand All @@ -49,9 +111,22 @@ def ParseArguments():

parsed_args, nosetests_args = parser.parse_known_args()

completers = set( COMPLETERS.keys() )
if parsed_args.completers is not None:
completers = set( parsed_args.completers )
elif parsed_args.no_completers is not None:
completers = completers.difference( parsed_args.no_completers )
elif parsed_args.no_clang_completer:
print( 'WARNING: The "--no-clang-completer" flag is deprecated. Please use "--no-completer cfamily" instead.' )
completers.remove( 'cfamily' )

if 'USE_CLANG_COMPLETER' in os.environ:
parsed_args.no_clang_completer = ( os.environ[ 'USE_CLANG_COMPLETER' ]
== 'false' )
if os.environ[ 'USE_CLANG_COMPLETER' ] == 'false':
completers.remove( 'cfamily' )
else:
completers.add( 'cfamily' )

parsed_args.completers = list( completers )

if 'COVERAGE' in os.environ:
parsed_args.coverage = ( os.environ[ 'COVERAGE' ] == 'true' )
Expand All @@ -62,21 +137,19 @@ def ParseArguments():
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' ),
'--omnisharp-completer',
'--gocode-completer',
'--tern-completer',
'--racer-completer',
]

for key in COMPLETERS:
if key in args.completers:
build_cmd.extend( COMPLETERS[ key ][ 'build' ] )

if args.msvc:
build_cmd.extend( [ '--msvc', str( args.msvc ) ] )

Expand All @@ -88,8 +161,10 @@ def BuildYcmdLibs( args ):

def NoseTests( parsed_args, extra_nosetests_args ):
nosetests_args = [ '-v' ]
if parsed_args.no_clang_completer:
nosetests_args.append( '--exclude=.*Clang.*' )

for key in COMPLETERS:
if key not in parsed_args.completers:
nosetests_args.extend( COMPLETERS[ key ][ 'test' ] )

if parsed_args.coverage:
nosetests_args += [ '--with-coverage', '--cover-package=ycmd' ]
Expand Down
1 change: 1 addition & 0 deletions test_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ nose>=1.3.0
PyHamcrest>=1.8.0
WebTest>=2.0.9
ordereddict>=1.1
nose-exclude>=0.4.1
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
comment"""

from nose.tools import eq_
from .. import clang_completer
from ycmd.completers.cpp import clang_completer


def _Check_FormatRawComment( comment, expected ):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from nose.tools import eq_
from nose.tools import ok_
from .. import flags
from ycmd.completers.cpp import flags


def SanitizeFlags_Passthrough_test():
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from ycmd import user_options_store

TEST_DIR = os.path.dirname( os.path.abspath( __file__ ) )
DATA_DIR = os.path.join( TEST_DIR, "testdata", "filename_completer" )
DATA_DIR = os.path.join( TEST_DIR, "testdata", "filename_completer", "inner_dir" )
PATH_TO_TEST_FILE = os.path.join( DATA_DIR, "test.cpp" )

REQUEST_DATA = {
Expand Down Expand Up @@ -132,11 +132,11 @@ def EnvVar_AtStart_File_test( self ):
def EnvVar_AtStart_File_Partial_test( self ):
# The reason all entries in the directory are returned is that the
# RequestWrapper tells the completer to effectively return results for
# $YCM_TEST_DIR/testdata/filename_completer/ and the client filters based
# $YCM_TEST_DIR/testdata/filename_completer/inner_dir/ and the client filters based
# on the additional characters.
os.environ[ 'YCM_TEST_DIR' ] = TEST_DIR
data = sorted( self._CompletionResultsForLine(
'set x = $YCM_TEST_DIR/testdata/filename_completer/te' ) )
'set x = $YCM_TEST_DIR/testdata/filename_completer/inner_dir/te' ) )
os.environ.pop( 'YCM_TEST_DIR' )

eq_( [
Expand All @@ -151,26 +151,26 @@ def EnvVar_AtStart_Dir_test( self ):
os.environ[ 'YCMTESTDIR' ] = TEST_DIR

data = sorted( self._CompletionResultsForLine(
'set x = $YCMTESTDIR/testdata/' ) )
'set x = $YCMTESTDIR/testdata/filename_completer/' ) )

os.environ.pop( 'YCMTESTDIR' )

eq_( [ ('filename_completer', '[Dir]') ], data )
eq_( [ ('inner_dir', '[Dir]') ], data )


def EnvVar_AtStart_Dir_Partial_test( self ):
os.environ[ 'ycm_test_dir' ] = TEST_DIR
data = sorted( self._CompletionResultsForLine(
'set x = $ycm_test_dir/testdata/fil' ) )
'set x = $ycm_test_dir/testdata/filename_completer/inn' ) )

os.environ.pop( 'ycm_test_dir' )
eq_( [ ('filename_completer', '[Dir]') ], data )
eq_( [ ('inner_dir', '[Dir]') ], data )


def EnvVar_InMiddle_File_test( self ):
os.environ[ 'YCM_TEST_filename_completer' ] = 'filename_completer'
os.environ[ 'YCM_TEST_filename_completer' ] = 'inner_dir'
data = sorted( self._CompletionResultsForLine(
'set x = ' + TEST_DIR + '/testdata/$YCM_TEST_filename_completer/' ) )
'set x = ' + TEST_DIR + '/testdata/filename_completer/$YCM_TEST_filename_completer/' ) )
os.environ.pop( 'YCM_TEST_filename_completer' )
eq_( [
( u'foo漢字.txt', '[File]' ),
Expand All @@ -181,9 +181,9 @@ def EnvVar_InMiddle_File_test( self ):


def EnvVar_InMiddle_File_Partial_test( self ):
os.environ[ 'YCM_TEST_filename_c0mpleter' ] = 'filename_completer'
os.environ[ 'YCM_TEST_filename_c0mpleter' ] = 'inner_dir'
data = sorted( self._CompletionResultsForLine(
'set x = ' + TEST_DIR + '/testdata/$YCM_TEST_filename_c0mpleter/te' ) )
'set x = ' + TEST_DIR + '/testdata/filename_completer/$YCM_TEST_filename_c0mpleter/te' ) )
os.environ.pop( 'YCM_TEST_filename_c0mpleter' )
eq_( [
( u'foo漢字.txt', '[File]' ),
Expand All @@ -196,39 +196,39 @@ def EnvVar_InMiddle_File_Partial_test( self ):
def EnvVar_InMiddle_Dir_test( self ):
os.environ[ 'YCM_TEST_td' ] = 'testd'
data = sorted( self._CompletionResultsForLine(
'set x = ' + TEST_DIR + '/${YCM_TEST_td}ata/' ) )
'set x = ' + TEST_DIR + '/${YCM_TEST_td}ata/filename_completer/' ) )

os.environ.pop( 'YCM_TEST_td' )
eq_( [ ('filename_completer', '[Dir]') ], data )
eq_( [ ('inner_dir', '[Dir]') ], data )


def EnvVar_InMiddle_Dir_Partial_test( self ):
os.environ[ 'YCM_TEST_td' ] = 'tdata'
data = sorted( self._CompletionResultsForLine(
'set x = ' + TEST_DIR + '/tes${YCM_TEST_td}/' ) )
'set x = ' + TEST_DIR + '/tes${YCM_TEST_td}/filename_completer/' ) )
os.environ.pop( 'YCM_TEST_td' )

eq_( [ ('filename_completer', '[Dir]') ], data )
eq_( [ ('inner_dir', '[Dir]') ], data )


def EnvVar_Undefined_test( self ):
data = sorted( self._CompletionResultsForLine(
'set x = ' + TEST_DIR + '/testdata${YCM_TEST_td}/' ) )
'set x = ' + TEST_DIR + '/testdata/filename_completer${YCM_TEST_td}/' ) )

eq_( [ ], data )


def EnvVar_Empty_Matches_test( self ):
os.environ[ 'YCM_empty_var' ] = ''
data = sorted( self._CompletionResultsForLine(
'set x = ' + TEST_DIR + '/testdata${YCM_empty_var}/' ) )
'set x = ' + TEST_DIR + '/testdata/filename_completer${YCM_empty_var}/' ) )
os.environ.pop( 'YCM_empty_var' )

eq_( [ ('filename_completer', '[Dir]') ], data )
eq_( [ ('inner_dir', '[Dir]') ], data )


def EnvVar_Undefined_Garbage_test( self ):
os.environ[ 'YCM_TEST_td' ] = 'testdata'
os.environ[ 'YCM_TEST_td' ] = 'testdata/filename_completer'
data = sorted( self._CompletionResultsForLine(
'set x = ' + TEST_DIR + '/$YCM_TEST_td}/' ) )

Expand All @@ -237,7 +237,7 @@ def EnvVar_Undefined_Garbage_test( self ):


def EnvVar_Undefined_Garbage_2_test( self ):
os.environ[ 'YCM_TEST_td' ] = 'testdata'
os.environ[ 'YCM_TEST_td' ] = 'testdata/filename_completer'
data = sorted( self._CompletionResultsForLine(
'set x = ' + TEST_DIR + '/${YCM_TEST_td/' ) )

Expand All @@ -246,7 +246,7 @@ def EnvVar_Undefined_Garbage_2_test( self ):


def EnvVar_Undefined_Garbage_3_test( self ):
os.environ[ 'YCM_TEST_td' ] = 'testdata'
os.environ[ 'YCM_TEST_td' ] = 'testdata/filename_completer'
data = sorted( self._CompletionResultsForLine(
'set x = ' + TEST_DIR + '/$ YCM_TEST_td/' ) )

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

TEST_DIR = os.path.dirname( os.path.abspath( __file__ ) )
DATA_DIR = os.path.join( TEST_DIR, 'testdata' )
PATH_TO_TEST_FILE = os.path.join( DATA_DIR, 'test.go' )
PATH_TO_TEST_FILE = os.path.join( DATA_DIR, 'test2.go' )
# Use test file as dummy binary
DUMMY_BINARY = PATH_TO_TEST_FILE
PATH_TO_POS121_RES = os.path.join( DATA_DIR, 'gocode_output_offset_121.json' )
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 5a304dd

Please sign in to comment.