ci(tests): add test framework (#1603)
This commit is contained in:
parent
934f81182a
commit
89e8b9628c
43 changed files with 1519 additions and 136 deletions
|
|
@ -12,14 +12,14 @@ MacPorts
|
|||
Install Requirements
|
||||
.. code-block:: bash
|
||||
|
||||
sudo port install avahi boost180 cmake curl libopus miniupnpc npm9 pkgconfig
|
||||
sudo port install avahi boost180 cmake curl doxygen graphviz libopus miniupnpc npm9 pkgconfig python311 py311-pip
|
||||
|
||||
Homebrew
|
||||
""""""""
|
||||
Install Requirements
|
||||
.. code-block:: bash
|
||||
|
||||
brew install boost cmake miniupnpc node opus pkg-config
|
||||
brew install boost cmake doxygen graphviz miniupnpc node opus pkg-config python@3.11
|
||||
|
||||
If there are issues with an SSL header that is not found:
|
||||
.. tab:: Intel
|
||||
|
|
@ -45,7 +45,7 @@ Build
|
|||
.. code-block:: bash
|
||||
|
||||
cmake ..
|
||||
make -j ${nproc}
|
||||
make -j $(sysctl -n hw.ncpu)
|
||||
|
||||
cpack -G DragNDrop # optionally, create a macOS dmg package
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ Install dependencies:
|
|||
base-devel \
|
||||
cmake \
|
||||
diffutils \
|
||||
doxygen \
|
||||
gcc \
|
||||
git \
|
||||
make \
|
||||
|
|
@ -25,13 +26,17 @@ Install dependencies:
|
|||
mingw-w64-x86_64-boost \
|
||||
mingw-w64-x86_64-cmake \
|
||||
mingw-w64-x86_64-curl \
|
||||
mingw-w64-x86_64-graphviz \
|
||||
mingw-w64-x86_64-miniupnpc \
|
||||
mingw-w64-x86_64-nlohmann-json \
|
||||
mingw-w64-x86_64-nodejs \
|
||||
mingw-w64-x86_64-onevpl \
|
||||
mingw-w64-x86_64-openssl \
|
||||
mingw-w64-x86_64-opus \
|
||||
mingw-w64-x86_64-toolchain
|
||||
mingw-w64-x86_64-rust \
|
||||
mingw-w64-x86_64-toolchain \
|
||||
python \
|
||||
python-pip
|
||||
|
||||
Build
|
||||
-----
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
# standard imports
|
||||
from datetime import datetime
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
|
||||
|
|
@ -27,16 +26,8 @@ project_copyright = f'{datetime.now ().year}, {project}'
|
|||
author = 'ReenigneArcher'
|
||||
|
||||
# The full version, including alpha/beta/rc tags
|
||||
with open(os.path.join(root_dir, 'CMakeLists.txt'), 'r') as f:
|
||||
version = re.search(r"project\(Sunshine VERSION ((\d+)\.(\d+)\.(\d+))", str(f.read())).group(1)
|
||||
"""
|
||||
To use cmake method for obtaining version instead of regex,
|
||||
1. Within CMakeLists.txt add the following line without backticks:
|
||||
``configure_file(docs/source/conf.py.in "${CMAKE_CURRENT_SOURCE_DIR}/docs/source/conf.py" @ONLY)``
|
||||
2. Rename this file to ``conf.py.in``
|
||||
3. Uncomment the next line
|
||||
"""
|
||||
# version = '@PROJECT_VERSION@' # use this for cmake configure_file method
|
||||
# https://docs.readthedocs.io/en/stable/reference/environment-variables.html#envvar-READTHEDOCS_VERSION
|
||||
version = os.getenv('READTHEDOCS_VERSION', 'dirty')
|
||||
|
||||
# -- General configuration ---------------------------------------------------
|
||||
|
||||
|
|
@ -105,6 +96,17 @@ doxy_proc = subprocess.run('doxygen --version', shell=True, cwd=source_dir, capt
|
|||
doxy_version = doxy_proc.stdout.decode('utf-8').strip()
|
||||
print('doxygen version: ' + doxy_version)
|
||||
|
||||
# create build directories, as doxygen fails to create it in macports and docker
|
||||
directories = [
|
||||
os.path.join(source_dir, 'build'),
|
||||
os.path.join(source_dir, 'build', 'doxyxml'),
|
||||
]
|
||||
for d in directories:
|
||||
os.makedirs(
|
||||
name=d,
|
||||
exist_ok=True,
|
||||
)
|
||||
|
||||
# run doxygen
|
||||
doxy_proc = subprocess.run('doxygen Doxyfile', shell=True, cwd=source_dir)
|
||||
if doxy_proc.returncode != 0:
|
||||
|
|
|
|||
|
|
@ -59,5 +59,81 @@ Format inplace with rstfmt
|
|||
|
||||
Unit Testing
|
||||
------------
|
||||
.. todo:: Sunshine does not currently have any unit tests. If you would like to help us improve please get in contact
|
||||
with us, or make a PR with suggested changes.
|
||||
Sunshine uses `Google Test <https://github.com/google/googletest>`__ for unit testing. Google Test is included in the
|
||||
repo as a submodule. The test sources are located in the `./tests` directory.
|
||||
|
||||
The tests need to be compiled into an executable, and then run. The tests are built using the normal build process, but
|
||||
can be disabled by setting the `BUILD_TESTS` CMake option to `OFF`.
|
||||
|
||||
To run the tests, execute the following command from the build directory:
|
||||
|
||||
.. tab:: Linux
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
pushd tests
|
||||
./test_sunshine
|
||||
popd
|
||||
|
||||
.. tab:: macOS
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
pushd tests
|
||||
./test_sunshine
|
||||
popd
|
||||
|
||||
.. tab:: Windows
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
pushd tests
|
||||
test_sunshine.exe
|
||||
popd
|
||||
|
||||
To see all available options, run the tests with the `--help` option.
|
||||
|
||||
.. tab:: Linux
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
pushd tests
|
||||
./test_sunshine --help
|
||||
popd
|
||||
|
||||
.. tab:: macOS
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
pushd tests
|
||||
./test_sunshine --help
|
||||
popd
|
||||
|
||||
.. tab:: Windows
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
pushd tests
|
||||
test_sunshine.exe --help
|
||||
popd
|
||||
|
||||
Some tests rely on Python to run. CMake will search for Python and enable the docs tests if it is found, otherwise
|
||||
cmake will fail. You can manually disable the tests by setting the `TESTS_ENABLE_PYTHON_TESTS` CMake option to
|
||||
`OFF`.
|
||||
|
||||
.. tip::
|
||||
|
||||
See the googletest `FAQ <https://google.github.io/googletest/faq.html>`__ for more information on how to use
|
||||
Google Test.
|
||||
|
||||
We use `gcovr <https://www.gcovr.com/>`__ to generate code coverage reports,
|
||||
and `Codecov <https://about.codecov.io/>`__ to analyze the reports for all PRs and commits.
|
||||
|
||||
Codecov will fail a PR if the total coverage is reduced too much, or if not enough of the diff is covered by tests.
|
||||
In some cases, the code cannot be covered when running the tests inside of GitHub runners. For example, any test that
|
||||
needs access to the GPU will not be able to run. In these cases, the coverage can be omitted by adding comments to the
|
||||
code. See the `gcovr documentation <https://gcovr.com/en/stable/guide/exclusion-markers.html#exclusion-markers>`__ for
|
||||
more information.
|
||||
|
||||
Even if your changes cannot be covered in the CI, we still encourage you to write the tests for them. This will allow
|
||||
maintainers to run the tests locally.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue