Add explicit -DTEST_MYSQL

Since the setup is a bit more manual and not as self-contained, so most
probably don't want to test it locally.
This commit is contained in:
def 2021-11-28 01:49:08 +01:00
parent 04594397ca
commit f464f148ac
4 changed files with 21 additions and 9 deletions

View file

@ -130,7 +130,7 @@ jobs:
run: |
mkdir fancy
cd fancy
${{ matrix.cmake-path }}cmake ${{ matrix.cmake-args }} -DCMAKE_BUILD_TYPE=RelWithDebInfo -DANTIBOT=ON -DMYSQL=ON -DWEBSOCKETS=ON -DMYSQL=ON ..
${{ matrix.cmake-path }}cmake ${{ matrix.cmake-args }} -DCMAKE_BUILD_TYPE=RelWithDebInfo -DANTIBOT=ON -DTEST_MYSQL=ON -DWEBSOCKETS=ON ..
${{ matrix.cmake-path }}cmake --build . --config RelWithDebInfo --target everything ${{ matrix.build-args }}
- name: Test fancy
if: matrix.fancy

View file

@ -101,6 +101,7 @@ endif()
option(WEBSOCKETS "Enable websockets support" OFF)
option(MYSQL "Enable mysql support" OFF)
option(TEST_MYSQL "Test mysql support in unit tests (also sets -DMYSQL=ON)" OFF)
option(AUTOUPDATE "Enable the autoupdater" OFF)
option(INFORM_UPDATE "Inform about available updates" ON)
option(VIDEORECORDER "Enable video recording support via FFmpeg" OFF)
@ -117,6 +118,10 @@ option(DISCORD_DYNAMIC "Enable discovering Discord rich presence libraries at ru
option(PREFER_BUNDLED_LIBS "Prefer bundled libraries over system libraries" ${AUTO_DEPENDENCIES_DEFAULT})
option(DEV "Don't generate stuff necessary for packaging" OFF)
if(TEST_MYSQL)
set(MYSQL ON)
endif()
# Set version if not explicitly set
if(NOT VERSION)
set(VERSION ${PROJECT_VERSION})
@ -2819,6 +2824,9 @@ foreach(target ${TARGETS_OWN})
target_compile_definitions(${target} PRIVATE CONF_MYSQL)
target_include_directories(${target} PRIVATE ${MYSQL_INCLUDE_DIRS})
endif()
if(TEST_MYSQL)
target_compile_definitions(${target} PRIVATE CONF_TEST_MYSQL)
endif()
if(AUTOUPDATE AND NOT STEAM)
target_compile_definitions(${target} PRIVATE CONF_AUTOUPDATE)
endif()

View file

@ -72,6 +72,16 @@ Whether to enable MySQL/MariaDB support for server. Requires at least MySQL 8.0
Note that the bundled MySQL libraries might not work properly on your system. If you run into connection problems with the MySQL server, for example that it connects as root while you chose another user, make sure to install your system libraries for the MySQL client. Make sure that the CMake configuration summary says that it found MySQL libs that were not bundled (no "using bundled libs").
* **-DTEST_MYSQL=[ON|OFF]** <br>
Whether to test MySQL/MariaDB support in GTest based tests. Note that this requires a running MySQL/MariaDB database on localhost with this setup:
```
CREATE DATABASE ddnet;
CREATE USER 'ddnet'@'localhost' IDENTIFIED BY 'thebestpassword';
GRANT ALL PRIVILEGES ON ddnet.* TO 'ddnet'@'localhost';
FLUSH PRIVILEGES;
```
* **-DAUTOUPDATE=[ON|OFF]** <br>
Whether to enable the autoupdater. Packagers may want to disable this for their packages. Default value is ON for Windows and Linux.

View file

@ -7,13 +7,7 @@
#include <sqlite3.h>
#if defined(CONF_MYSQL)
// For MySQL this setup is required on localhost:
// CREATE DATABASE ddnet;
// CREATE USER 'ddnet'@'localhost' IDENTIFIED BY 'thebestpassword';
// GRANT ALL PRIVILEGES ON ddnet.* TO 'ddnet'@'localhost';
// FLUSH PRIVILEGES;
#if defined(CONF_TEST_MYSQL)
int DummyMysqlInit = (MysqlInit(), 1);
#endif
@ -463,7 +457,7 @@ TEST_P(RandomMap, UnfinishedDoesntExist)
auto testValues
{
testing::Values(CreateSqliteConnection(":memory:", true)
#if defined(CONF_MYSQL)
#if defined(CONF_TEST_MYSQL)
,
CreateMysqlConnection("ddnet", "record", "ddnet", "thebestpassword", "localhost", 3306, true)
#endif