This readme documents instructions on running the test suite.
An alternative (canonical) reference is the scripts used for running the tests
on Travis, CircleCI, and AppVeyor. These can be found in
.travis.yml
, appveyor.yml
, and the ci
and .circleci
directories.
You need to have installed all the requirements in test_requirements.txt
. The
simplest way to set this up is to use a virtualenv, for example:
$ mkdir ~/YouCompleteMe/tests
$ virtualenv ~/YouCompleteMe/tests
$ source ~/YouCompleteMe/tests/bin/activate
$ pip install -r test_requirements.txt
You also need to have all of ycmd's completers' requirements. See the installation guide for details, but typically this involves manually installing:
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.
Note: if your installation of mono is in a non-standard location,
OmniSharpServer will not start. Ensure that it is in a standard location, or
change the paths in OmniSharpServer/OmniSharp/Solution/CSharpProject.cs
To run the full suite, just run run_tests.py
. Options are:
--skip-build
: don't attempt to run the build.py
script. Useful once
everything is built;--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 C++ version to build with (default: 15).
Windows only;--coverage
: generate code coverage data.Remaining arguments are passed to "pytest" directly. This means that you can run a specific script or a specific test as follows:
./run_tests.py ycmd/tests/<module_name>.py
./run_tests.py ycmd/tests/<module_name>.py:<function name>
For example:
./run_tests.py ycmd/tests/subcommands_test.py
./run_tests.py ycmd/tests/subcommands_test.py:Subcommands_Basic_test
NOTE: you must have UTF-8 support in your terminal when you do this, e.g.:
LANG=en_GB.utf8 ./run_tests.py --skip-build
We can generate coverage data for both the C++ layer and the Python layer. The CI system will pass this coverage data to [codecov.io][] where you can view coverage after pushing a branch.
C++ coverage testing is available only on Linux/Mac and uses gcov.
Stricly speaking, we use the -coverage
option to your compiler, which in the
case of GNU and LLVM compilers, generate gcov-compatible data.
For Python, there's a coverage module which works nicely with pytest
. This
is very useful for highlighting areas of your code which are not covered by the
automated integration tests.
Run it like this:
./run_tests.py --coverage
This will print a summary and generate HTML output in ./cover
.
More information: https://coverage.readthedocs.org and https://pytest-cov.readthedocs.io/en/stable/
Make sure you have installed all the packages in test_requirements.txt
with
pip install -r test_requirements.txt
.
Likely to be a problem with the OmniSharpServer.
third-party/OmniSharpServer
ycmd/tests/cs/testdata
with
mono ../../../third_party/OmniSharpServer/OmniSharp/bin/Debug/OmniSharp.exe -s testy/testy.sln
ERROR: ycmd.tests.cs.get_completions_test.GetCompletions_PathWithSpace_test
FAIL: ycmd.tests.filename_completer_test.FilenameCompleter_test.SystemPathCompletion_test
Ensure that you have UTF-8 support in your environment (see above).
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。