mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-02 17:46:48 +01:00
38b1110d1b
Staging's 7 commits since62f7a29b. Two of them changed files this branch split up, so their changes are carried into the new files by hand: - #445 (the decisions of an uphill start in uphill_start::): the changes to TController::control_tractive_force() and control_uphill_start() of vehicle/Driver.cpp go into vehicle/ai/force.cpp, with the names of this branch (VehicleEnd::front, ->physics) - #530 (the lowpoly driver figure follows the direction in single desk vehicles): the figure in ABuLittleUpdate() goes into vehicle/dynamic/visual.cpp; the reading of cab1model:/cab2model: and of driverNpos:/driverNsitpos: goes into the helpers of the internaldata: section in vehicle/dynamic/mmd.cpp, which pass the cab places along (loadInternalDataKeyword, loadInternalDataDeviceKeyword, loadInternalDataCabKeyword); read_driver_position() takes the tokens no group of keywords knows, as the last else of the chain did vehicle/Driver.cpp and vehicle/DynObj.cpp stay deleted. The rest merged on its own. 1185/1185 tests, golden traces exact against staging62f7a29b.
89 lines
4.5 KiB
CMake
89 lines
4.5 KiB
CMake
# Unit tests of the simulation, built and run without the game data: the test vehicles are JSON
|
|
# definitions in data/ (see vehicle.h), loaded from memory by the game's own vehicle loader. The code
|
|
# under test is the game's core library (eu07_core), the very objects the game links; the rest of the
|
|
# engine it reaches for is replaced with stubs (engine_stubs.cpp). They run as part of the build,
|
|
# from the IDE, or with ctest.
|
|
|
|
set(UNIT_TESTS_NAME eu07_unit_tests)
|
|
|
|
# a new test_*.cpp file or file in data/ (definitions, real vehicles, golden traces) is picked up on its own
|
|
file(GLOB UNIT_TEST_CASES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/test_*.cpp")
|
|
file(GLOB_RECURSE UNIT_TEST_DATA CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/data/*")
|
|
|
|
add_executable(${UNIT_TESTS_NAME}
|
|
main.cpp
|
|
vehicle.cpp
|
|
fiz.cpp
|
|
drive.cpp
|
|
consist.cpp
|
|
scenario.cpp
|
|
golden.cpp
|
|
invariants.cpp
|
|
figures.cpp
|
|
engine_stubs.cpp
|
|
editor_stubs.cpp
|
|
# the geometry of the lines the track editor designs, standing on its own
|
|
"${CMAKE_SOURCE_DIR}/editor/editorAlignment.cpp"
|
|
# and the heights of the tracks laid
|
|
"${CMAKE_SOURCE_DIR}/editor/editorGroundFollow.cpp"
|
|
"${CMAKE_SOURCE_DIR}/editor/editorProfile.cpp"
|
|
# and the switches laid into the curves
|
|
"${CMAKE_SOURCE_DIR}/editor/editorSwitchCurve.cpp"
|
|
# and the fouling points of the switches, widened in the curves as the gauge is
|
|
"${CMAKE_SOURCE_DIR}/editor/editorGauge.cpp"
|
|
"${CMAKE_SOURCE_DIR}/editor/editorFouling.cpp"
|
|
# which textures the shadow maps draw without the alpha test
|
|
"${CMAKE_SOURCE_DIR}/rendering/common/texturealpha.cpp"
|
|
# and the movement of the free camera the motion blur takes
|
|
"${CMAKE_SOURCE_DIR}/rendering/common/freecameramotion.cpp"
|
|
# and the http client the editor fetches its aids with
|
|
"${CMAKE_SOURCE_DIR}/editor/editorHttp.cpp"
|
|
"${CMAKE_SOURCE_DIR}/utilities/asciiname.cpp"
|
|
# and what the switch tool tells of the drives of the switches
|
|
"${CMAKE_SOURCE_DIR}/editor/editorSwitchDrives.cpp"
|
|
# the camera, for the order of its rotations (test_camera.cpp)
|
|
"${CMAKE_SOURCE_DIR}/vehicle/Camera.cpp"
|
|
${UNIT_TEST_CASES})
|
|
|
|
# the core library brings the game's build settings along
|
|
target_link_libraries(${UNIT_TESTS_NAME} PRIVATE eu07_core)
|
|
|
|
# a precompiled header, as the game has: the system and library headers of stdafx.h and doctest are parsed once, not
|
|
# again in each of the files. the vehicle physics stays out of it, its unscoped enums (end::front...) would clash with
|
|
# the names of the tests. main.cpp defines the implementation of doctest before it includes doctest.h, so it goes without
|
|
if(USE_PCH)
|
|
target_precompile_headers(${UNIT_TESTS_NAME} PRIVATE
|
|
"$<$<COMPILE_LANGUAGE:CXX>:${CMAKE_SOURCE_DIR}/stdafx.h>"
|
|
"$<$<COMPILE_LANGUAGE:CXX>:${CMAKE_SOURCE_DIR}/ref/doctest/doctest.h>")
|
|
set_source_files_properties(main.cpp PROPERTIES SKIP_PRECOMPILE_HEADERS TRUE)
|
|
endif()
|
|
|
|
# the script screen host, tested with the real runtimes (test_script_screen_host.cpp)
|
|
target_sources(${UNIT_TESTS_NAME} PRIVATE "${CMAKE_SOURCE_DIR}/scripting/scriptscreens.cpp")
|
|
if (WITH_LUA)
|
|
target_sources(${UNIT_TESTS_NAME} PRIVATE "${CMAKE_SOURCE_DIR}/scripting/luaprogram.cpp" "${CMAKE_SOURCE_DIR}/scripting/luasandbox.cpp" "${CMAKE_SOURCE_DIR}/stb/stb_image.c")
|
|
endif()
|
|
if (WITH_WASM)
|
|
target_sources(${UNIT_TESTS_NAME} PRIVATE "${CMAKE_SOURCE_DIR}/scripting/wasmprogram.cpp")
|
|
target_link_libraries(${UNIT_TESTS_NAME} PRIVATE eu07_wamr)
|
|
endif()
|
|
target_include_directories(${UNIT_TESTS_NAME} PRIVATE "${DEPS_DIR}/doctest")
|
|
# the names the tests CAPTURE are often C strings, shown as text rather than pointers
|
|
target_compile_definitions(${UNIT_TESTS_NAME} PRIVATE EU07_UNIT_TESTS_DATA="${CMAKE_CURRENT_SOURCE_DIR}/data" DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING)
|
|
# the folders of the tests that write files (the scripts of test_script_screen_host.cpp) are made in the build folder,
|
|
# and removed by the test that made them
|
|
target_compile_definitions(${UNIT_TESTS_NAME} PRIVATE EU07_UNIT_TESTS_SCRATCH="${CMAKE_CURRENT_BINARY_DIR}")
|
|
if (MSVC)
|
|
target_compile_options(${UNIT_TESTS_NAME} PRIVATE /bigobj)
|
|
endif()
|
|
set_target_properties(${UNIT_TESTS_NAME} PROPERTIES FOLDER "tests")
|
|
|
|
add_test(NAME ${UNIT_TESTS_NAME} COMMAND ${UNIT_TESTS_NAME})
|
|
if (WIN32)
|
|
# the libraries of the game (lua51.dll) are next to the game, see run_tests.cmake
|
|
set_tests_properties(${UNIT_TESTS_NAME} PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:eu07>")
|
|
endif()
|
|
|
|
# for running the tests at the end of building the game, see the main CMakeLists.txt
|
|
set(UNIT_TEST_DATA ${UNIT_TEST_DATA} PARENT_SCOPE)
|