meson: add tests (#1044)

This integrates the "main" test suite (test/test.cc) in Meson.

This allows to run the tests in the CI with the Meson-built version of
the library to ensure that nothing breaks unexpectedly.

It also simplifies life of downstream packagers, that do not have to
write a custom build script to split the library and run tests but can
instead just let Meson do that for them.
This commit is contained in:
Andrea Pappacoda 2021-09-11 20:26:48 +02:00 committed by GitHub
parent 4e05368086
commit e3e28c6231
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 179 additions and 5 deletions

View file

@ -39,3 +39,55 @@ jobs:
cd test
msbuild.exe test.sln /verbosity:minimal /t:Build "/p:Configuration=Release;Platform=x64"
x64\Release\test.exe
meson-build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
steps:
- name: Prepare Git for checkout on Windows
if: matrix.os == 'windows-latest'
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- uses: actions/checkout@v2
- name: Install dependencies on Linux
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get -qq update && sudo apt-get -qq install meson libssl-dev zlib1g-dev libbrotli-dev libgtest-dev
- name: Install dependencies on MacOS
if: matrix.os == 'macos-latest'
run: brew install meson openssl brotli googletest
- name: Setup MSVC on Windows
if: matrix.os == 'windows-latest'
uses: ilammy/msvc-dev-cmd@v1
# It is necessary to remove MinGW and StrawberryPerl as they both provide
# GCC. This causes issues because CMake prefers to use MSVC, while Meson
# uses GCC, if found, causing linking errors.
- name: Install dependencies on Windows
if: matrix.os == 'windows-latest'
run: |
choco uninstall mingw strawberryperl --yes --all-versions --remove-dependencies --skip-autouninstaller --no-color
Remove-Item -Path C:\Strawberry -Recurse
choco install pkgconfiglite --yes --skip-virus-check --no-color
pip install meson ninja
Invoke-WebRequest -Uri https://github.com/google/googletest/archive/refs/heads/master.zip -OutFile googletest-master.zip
Expand-Archive -Path googletest-master.zip
cd googletest-master\googletest-master
cmake -S . -B build -DINSTALL_GTEST=ON -DBUILD_GMOCK=OFF -Dgtest_hide_internal_symbols=ON -DCMAKE_INSTALL_PREFIX=C:/googletest
cmake --build build --config=Release
cmake --install build --config=Release
cd ..\..
- name: Build and test
run: |
meson setup build -Dcpp-httplib_test=true -Dpkg_config_path=C:\googletest\lib\pkgconfig -Db_vscrt=static_from_buildtype
meson test --no-stdsplit --print-errorlogs -C build