Skip to content

Commit ed4b6c3

Browse files
committed
initial changes
should be longer build time on this pr as it is rebuilding the engine twice, will begin removing unnecessary files and possibly removing the preproc so the unit tests could use the same result as the engine build.
1 parent c2c5674 commit ed4b6c3

10 files changed

Lines changed: 230 additions & 68 deletions

File tree

.github/workflows/build-linux-gcc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ jobs:
9797
- name: Unit Tests
9898
run: |
9999
cd "${{github.workspace}}/My Projects/Torque3D/game"
100-
./Torque3D runTests.tscript
100+
./Torque3D_unittests
101101
102102
- name: Test Reporter
103103
uses: phoenix-actions/test-reporting@v14

.github/workflows/build-macos-clang.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
- name: Unit Tests
6868
run: |
6969
cd "${{github.workspace}}/My Projects/Torque3D/game"
70-
./Torque3D.app/Contents/MacOS/Torque3D runTests.tscript
70+
./Torque3D_unittests
7171
7272
- name: Test Reporter
7373
uses: phoenix-actions/test-reporting@v14

.github/workflows/build-windows-msvc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
- name: Unit Tests
6464
run: |
6565
cd "${{github.workspace}}/My Projects/Torque3D/game"
66-
./Torque3D.exe runTests.tscript
66+
./Torque3D_unittests.exe
6767
6868
- name: Test Reporter
6969
uses: phoenix-actions/test-reporting@v14

Engine/source/CMakeLists.txt

Lines changed: 105 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ forwardDef(TORQUE_BASIC_LIGHTING)
3131
set(TORQUE_SDL ON) # we need sdl to do our platform interop
3232
forwardDef(TORQUE_SDL)
3333

34-
if(TORQUE_TESTING)
35-
set(TORQUE_COMPILE_DEFINITIONS ${TORQUE_COMPILE_DEFINITIONS} TORQUE_TESTS_ENABLED)
36-
set(TORQUE_COMPILE_DEFINITIONS ${TORQUE_COMPILE_DEFINITIONS} "_VARIADIC_MAX=10")
37-
endif()
38-
3934
# On Windows we disable CRT Security warnings - this comes from recommendations to use non-portable functions.
4035
if (WIN32)
4136
set(TORQUE_COMPILE_DEFINITIONS ${TORQUE_COMPILE_DEFINITIONS} _CRT_SECURE_NO_WARNINGS WIN32)
@@ -253,11 +248,6 @@ if (UNIX AND NOT APPLE)
253248
torqueAddSourceDirectories("platformX11")
254249
endif (UNIX AND NOT APPLE)
255250

256-
if(TORQUE_TESTING)
257-
torqueAddSourceDirectories("testing")
258-
set(TORQUE_COMPILE_DEFINITIONS ${TORQUE_COMPILE_DEFINITIONS} TORQUE_SHARED SDL_MAIN_HANDLED)
259-
endif(TORQUE_TESTING)
260-
261251
# Add the collected files to our engine group
262252
source_group(TREE "${CMAKE_SOURCE_DIR}/Engine/source" PREFIX "Engine" FILES ${TORQUE_SOURCE_FILES})
263253
file(GLOB_RECURSE TORQUE_APP_GAME_SOURCES "${TORQUE_APP_ROOT_DIRECTORY}/source/*.cpp" "${TORQUE_APP_ROOT_DIRECTORY}/source/*.h")
@@ -389,10 +379,6 @@ if (APPLE)
389379
"${TORQUE_APP_GAME_DIRECTORY}/${TORQUE_APP_NAME}.torsion"
390380
"${TORQUE_APP_GAME_DIRECTORY}/Template.torsion.exports")
391381

392-
if(TORQUE_TESTING)
393-
set(MACOSX_RESOURCES ${MACOSX_RESOURCES} "${TORQUE_APP_GAME_DIRECTORY}/runTests.${TORQUE_SCRIPT_EXTENSION}")
394-
endif()
395-
396382
set(TORQUE_SOURCE_FILES ${TORQUE_SOURCE_FILES} ${TORQUE_PLATFORM_MAC_SOURCES} ${MACOSX_RESOURCES})
397383

398384
source_group("Resources" FILES ${MACOSX_RESOURCES})
@@ -426,7 +412,7 @@ if (NOT TORQUE_NET_CURL)
426412
endif()
427413

428414
################# Executable Generation ###################
429-
if (TORQUE_DYNAMIC_LIBRARY AND NOT TORQUE_TESTING)
415+
if (TORQUE_DYNAMIC_LIBRARY)
430416
set(TORQUE_COMPILE_DEFINITIONS ${TORQUE_COMPILE_DEFINITIONS} TORQUE_SHARED)
431417

432418
# Build the main engine library
@@ -438,10 +424,8 @@ if (TORQUE_DYNAMIC_LIBRARY AND NOT TORQUE_TESTING)
438424
set(TORQUE_SOURCE_FILES "main/main.cpp")
439425
set(TORQUE_LINK_LIBRARIES TorqueEngine)
440426
else()
441-
if(NOT TORQUE_TESTING)
442-
set(TORQUE_SOURCE_FILES "main/main.cpp" ${TORQUE_SOURCE_FILES})
443-
endif()
444-
endif (TORQUE_DYNAMIC_LIBRARY AND NOT TORQUE_TESTING)
427+
set(TORQUE_SOURCE_FILES "main/main.cpp" ${TORQUE_SOURCE_FILES})
428+
endif (TORQUE_DYNAMIC_LIBRARY)
445429

446430
if (APPLE)
447431
add_executable(${TORQUE_APP_NAME} MACOSX_BUNDLE
@@ -486,9 +470,9 @@ elseif (WIN32)
486470

487471
# NOTE: On Windows, /Zc:wchar_t- is necessary otherwise you get unicode errors
488472
set_target_properties(${TORQUE_APP_NAME} PROPERTIES COMPILE_FLAGS "${TORQUE_CXX_FLAGS}")
489-
if (TORQUE_DYNAMIC_LIBRARY AND NOT TORQUE_TESTING)
473+
if (TORQUE_DYNAMIC_LIBRARY)
490474
set_target_properties(TorqueEngine PROPERTIES COMPILE_FLAGS "${TORQUE_CXX_FLAGS_COMMON_DEFAULT}")
491-
endif (TORQUE_DYNAMIC_LIBRARY AND NOT TORQUE_TESTING)
475+
endif (TORQUE_DYNAMIC_LIBRARY)
492476
else()
493477
add_executable(${TORQUE_APP_NAME} ${TORQUE_SOURCE_FILES})
494478

@@ -539,6 +523,13 @@ if(IS_ARM)
539523
add_math_backend(neon MATH_SIMD_NEON)
540524
endif()
541525

526+
foreach(MATH_BACKEND ${TORQUE_MATH_BACKENDS})
527+
target_sources(${TORQUE_APP_NAME}
528+
PRIVATE
529+
$<TARGET_OBJECTS:${MATH_BACKEND}>
530+
)
531+
endforeach()
532+
542533
if(MSVC)
543534
# Match projectGenerator naming for executables
544535
set(OUTPUT_CONFIG DEBUG MINSIZEREL RELWITHDEBINFO)
@@ -547,10 +538,10 @@ if(MSVC)
547538
list(GET OUTPUT_CONFIG ${INDEX} CONF)
548539
list(GET OUTPUT_SUFFIX ${INDEX} SUFFIX)
549540
set_property(TARGET ${TORQUE_APP_NAME} PROPERTY OUTPUT_NAME_${CONF} ${TORQUE_APP_NAME}_${SUFFIX})
550-
if (TORQUE_DYNAMIC_LIBRARY AND NOT TORQUE_TESTING)
541+
if (TORQUE_DYNAMIC_LIBRARY)
551542
set_property(TARGET TorqueEngine PROPERTY ${CONF}_POSTFIX "_${SUFFIX}")
552543
set_property(TARGET TorqueEngine PROPERTY ${CONF}_OUTPUT_NAME ${TORQUE_APP_NAME})
553-
endif (TORQUE_DYNAMIC_LIBRARY AND NOT TORQUE_TESTING)
544+
endif (TORQUE_DYNAMIC_LIBRARY)
554545
endforeach()
555546
# Set Visual Studio startup project
556547
set_property(DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${TORQUE_APP_NAME})
@@ -591,14 +582,6 @@ if (TORQUE_TARGET_PROPERTIES)
591582
endif (TORQUE_TARGET_PROPERTIES)
592583
target_include_directories(${TORQUE_APP_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} "${CMAKE_BINARY_DIR}/temp" ${TORQUE_INCLUDE_DIRECTORIES})
593584

594-
if(TORQUE_TESTING)
595-
if(WIN32)
596-
target_link_options(${TORQUE_APP_NAME} PRIVATE "/SUBSYSTEM:CONSOLE")
597-
set_target_properties(gtest PROPERTIES COMPILE_FLAGS "/Zc:wchar_t-")
598-
set_target_properties(gmock PROPERTIES COMPILE_FLAGS "/Zc:wchar_t-")
599-
endif()
600-
endif(TORQUE_TESTING)
601-
602585
append_defs()
603586

604587
# Process library binaries - these are coming from modules that are providing links to external, precompiled code that should be included
@@ -645,3 +628,94 @@ if (UNIX)
645628
endif()
646629
endforeach()
647630
endif (UNIX)
631+
632+
if(TORQUE_TESTING)
633+
634+
enable_testing()
635+
636+
# Start with the same sources as the main application
637+
set(TORQUE_TEST_SOURCES ${TORQUE_SOURCE_FILES})
638+
639+
# Add test sources
640+
file(GLOB_RECURSE TORQUE_TEST_FILES
641+
"${CMAKE_CURRENT_SOURCE_DIR}/testing/*.cpp"
642+
"${CMAKE_CURRENT_SOURCE_DIR}/testing/*.h"
643+
)
644+
645+
list(APPEND TORQUE_TEST_SOURCES ${TORQUE_TEST_FILES})
646+
647+
list(FILTER TORQUE_TEST_SOURCES EXCLUDE REGEX "main/main\\.cpp$")
648+
649+
add_executable(${TORQUE_APP_NAME}_unittests
650+
${TORQUE_TEST_SOURCES}
651+
)
652+
653+
foreach(MATH_BACKEND ${TORQUE_MATH_BACKENDS})
654+
target_sources(${TORQUE_APP_NAME}_unittests
655+
PRIVATE
656+
$<TARGET_OBJECTS:${MATH_BACKEND}>
657+
)
658+
endforeach()
659+
660+
target_include_directories(${TORQUE_APP_NAME}_unittests
661+
PUBLIC
662+
${CMAKE_CURRENT_SOURCE_DIR}
663+
"${CMAKE_BINARY_DIR}/temp"
664+
${TORQUE_INCLUDE_DIRECTORIES}
665+
)
666+
667+
target_compile_definitions(${TORQUE_APP_NAME}_unittests
668+
PUBLIC
669+
${TORQUE_COMPILE_DEFINITIONS}
670+
TORQUE_TESTS_ENABLED
671+
"_VARIADIC_MAX=10"
672+
TORQUE_SHARED
673+
SDL_MAIN_HANDLED
674+
)
675+
676+
target_link_libraries(${TORQUE_APP_NAME}_unittests
677+
PRIVATE
678+
${TORQUE_LINK_LIBRARIES}
679+
${TORQUE_LINK_THIRDPARTY}
680+
gtest
681+
gmock
682+
)
683+
684+
target_link_options(${TORQUE_APP_NAME}_unittests
685+
PUBLIC
686+
${TORQUE_LINK_OPTIONS}
687+
)
688+
689+
if(APPLE)
690+
target_link_libraries(${TORQUE_APP_NAME}_unittests
691+
PRIVATE
692+
${TORQUE_LINK_FRAMEWORKS}
693+
)
694+
endif()
695+
696+
if(WIN32)
697+
target_link_libraries(${TORQUE_APP_NAME}_unittests
698+
PRIVATE
699+
${TORQUE_LINK_WINDOWS}
700+
)
701+
set_target_properties(${TORQUE_APP_NAME}_unittests
702+
PROPERTIES COMPILE_FLAGS
703+
"${TORQUE_CXX_FLAGS}"
704+
)
705+
706+
target_link_options(${TORQUE_APP_NAME}_unittests PRIVATE "/SUBSYSTEM:CONSOLE")
707+
set_target_properties(gtest PROPERTIES COMPILE_FLAGS "/Zc:wchar_t-")
708+
set_target_properties(gmock PROPERTIES COMPILE_FLAGS "/Zc:wchar_t-")
709+
endif()
710+
711+
if(UNIX AND NOT APPLE)
712+
target_link_libraries(${TORQUE_APP_NAME}_unittests
713+
PRIVATE
714+
${TORQUE_LINK_LINUX}
715+
)
716+
endif()
717+
718+
include(GoogleTest)
719+
gtest_discover_tests(${TORQUE_APP_NAME}_unittests)
720+
721+
endif()

Engine/source/testing/dataChunkerTest.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// SPDX-License-Identifier: MIT
66
//-----------------------------------------------------------------------------
77

8-
#ifdef TORQUE_TESTS_ENABLED
98
#include "testing/unitTesting.h"
109
#include "core/dataChunker.h"
1110

@@ -343,5 +342,3 @@ TEST(ThreeTieredChunkerTest,ThreeTieredChunker_Should_Function_Correctly)
343342
EXPECT_TRUE(threeChunker.getT3Chunker().getFreeListHead().isEmpty());
344343
}
345344

346-
347-
#endif

Engine/source/testing/frameAllocatorTest.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// SPDX-License-Identifier: MIT
66
//-----------------------------------------------------------------------------
77

8-
#ifdef TORQUE_TESTS_ENABLED
98
#include "testing/unitTesting.h"
109
#include "core/frameAllocator.h"
1110

@@ -192,4 +191,3 @@ TEST(FrameTempTest, FrameTempShould_Function_Correctly)
192191
}
193192

194193

195-
#endif

0 commit comments

Comments
 (0)