Tests: Refactor tests with better names, etc.
The basic tests now run on Windows correctly without needing to manually copy any files -- the executables are output in the same location as the necessary DLLs. However, tests that require *.pyd files (all code in the Mod subdirectory, basically) still do not work on Windows as the test executables cannot find those files. This is a work in progress.
This commit is contained in:
committed by
Chris Hennes
parent
376b162239
commit
98eee8a563
@@ -44,7 +44,8 @@ protected:
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
_tempDir = std::filesystem::temp_directory_path() / ("fc_backup_policy-" + randomString(16));
|
||||
_tempDir =
|
||||
std::filesystem::temp_directory_path() / ("fc_backup_policy-" + randomString(16));
|
||||
std::filesystem::create_directory(_tempDir);
|
||||
}
|
||||
|
||||
@@ -79,13 +80,11 @@ protected:
|
||||
|
||||
|
||||
private:
|
||||
|
||||
std::string randomString(size_t length)
|
||||
{
|
||||
static constexpr std::string_view chars =
|
||||
"0123456789"
|
||||
"abcdefghijklmnopqrstuvwxyz"
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
static constexpr std::string_view chars = "0123456789"
|
||||
"abcdefghijklmnopqrstuvwxyz"
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
|
||||
std::random_device rd;
|
||||
std::mt19937 gen(rd());
|
||||
@@ -103,7 +102,6 @@ private:
|
||||
|
||||
App::BackupPolicy _policy;
|
||||
std::filesystem::path _tempDir;
|
||||
|
||||
};
|
||||
|
||||
TEST_F(BackupPolicyTest, StandardSourceDoesNotExist)
|
||||
@@ -113,4 +111,4 @@ TEST_F(BackupPolicyTest, StandardSourceDoesNotExist)
|
||||
|
||||
// Act & Assert
|
||||
EXPECT_THROW(apply("nonexistent.fcstd", "backup.fcstd"), Base::FileException);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
target_compile_definitions(Tests_run PRIVATE DATADIR="${CMAKE_SOURCE_DIR}/data")
|
||||
|
||||
target_sources(Tests_run PRIVATE
|
||||
add_executable(App_tests_run
|
||||
Application.cpp
|
||||
BackupPolicy.cpp
|
||||
Branding.cpp
|
||||
ComplexGeoData.cpp
|
||||
Document.cpp
|
||||
@@ -24,3 +23,12 @@ target_sources(Tests_run PRIVATE
|
||||
VarSet.cpp
|
||||
VRMLObject.cpp
|
||||
)
|
||||
|
||||
target_compile_definitions(App_tests_run PRIVATE DATADIR="${CMAKE_SOURCE_DIR}/data")
|
||||
|
||||
target_link_libraries(App_tests_run PRIVATE
|
||||
GTest::gtest_main
|
||||
GTest::gmock_main
|
||||
${Google_Tests_LIBS}
|
||||
FreeCADApp
|
||||
)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
target_sources(Tests_run PRIVATE
|
||||
add_executable(Base_tests_run
|
||||
Axis.cpp
|
||||
Base64.cpp
|
||||
Bitmask.cpp
|
||||
@@ -31,3 +31,10 @@ target_sources(Tests_run PRIVATE
|
||||
)
|
||||
|
||||
setup_qt_test(InventorBuilder)
|
||||
|
||||
target_link_libraries(Base_tests_run PRIVATE
|
||||
GTest::gtest_main
|
||||
GTest::gmock_main
|
||||
${Google_Tests_LIBS}
|
||||
FreeCADApp
|
||||
)
|
||||
|
||||
@@ -1,8 +1,17 @@
|
||||
# Standard C++ GTest tests
|
||||
target_sources(Tests_run PRIVATE
|
||||
add_executable(Gui_tests_run
|
||||
Assistant.cpp
|
||||
Camera.cpp
|
||||
)
|
||||
|
||||
# Qt tests
|
||||
setup_qt_test(QuantitySpinBox)
|
||||
|
||||
|
||||
target_link_libraries(Gui_tests_run PRIVATE
|
||||
GTest::gtest_main
|
||||
GTest::gmock_main
|
||||
${Google_Tests_LIBS}
|
||||
FreeCADApp
|
||||
FreeCADGui
|
||||
)
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
target_sources(Tests_run PRIVATE
|
||||
add_executable(Misc_tests_run
|
||||
fmt.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(Misc_tests_run PRIVATE
|
||||
GTest::gtest_main
|
||||
GTest::gmock_main
|
||||
${Google_Tests_LIBS}
|
||||
fmt::fmt
|
||||
)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "fmt/format.h"
|
||||
#include "fmt/printf.h"
|
||||
#include <fmt/format.h>
|
||||
#include <fmt/printf.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <stdexcept>
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
target_sources(Assembly_tests_run PRIVATE
|
||||
add_executable(Assembly_tests_run
|
||||
AssemblyObject.cpp
|
||||
)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
add_subdirectory(App)
|
||||
|
||||
if (NOT FREECAD_USE_EXTERNAL_ONDSELSOLVER)
|
||||
target_include_directories(Assembly_tests_run PUBLIC
|
||||
@@ -10,5 +11,3 @@ target_link_libraries(Assembly_tests_run
|
||||
${Google_Tests_LIBS}
|
||||
Assembly
|
||||
)
|
||||
|
||||
add_subdirectory(App)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
target_sources(Material_tests_run PRIVATE
|
||||
add_executable(Material_tests_run
|
||||
TestMaterialCards.cpp
|
||||
TestMaterialFilter.cpp
|
||||
TestMaterialProperties.cpp
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
add_subdirectory(App)
|
||||
|
||||
target_link_libraries(Material_tests_run
|
||||
gtest_main
|
||||
${Google_Tests_LIBS}
|
||||
Materials
|
||||
)
|
||||
|
||||
add_subdirectory(App)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
target_sources(Measure_tests_run PRIVATE
|
||||
add_executable(Measure_tests_run
|
||||
MeasureDistance.cpp
|
||||
)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
add_subdirectory(App)
|
||||
|
||||
target_link_libraries(Measure_tests_run
|
||||
gtest_main
|
||||
${Google_Tests_LIBS}
|
||||
Measure
|
||||
)
|
||||
|
||||
add_subdirectory(App)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
target_compile_definitions(Mesh_tests_run PRIVATE DATADIR="${CMAKE_SOURCE_DIR}/data")
|
||||
|
||||
target_sources(Mesh_tests_run PRIVATE
|
||||
add_executable(Mesh_tests_run
|
||||
Core/KDTree.cpp
|
||||
Exporter.cpp
|
||||
Importer.cpp
|
||||
Mesh.cpp
|
||||
MeshFeature.cpp
|
||||
)
|
||||
|
||||
target_compile_definitions(Mesh_tests_run PRIVATE DATADIR="${CMAKE_SOURCE_DIR}/data")
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
add_subdirectory(App)
|
||||
|
||||
target_link_libraries(Mesh_tests_run
|
||||
gtest_main
|
||||
${Google_Tests_LIBS}
|
||||
Mesh
|
||||
)
|
||||
|
||||
add_subdirectory(App)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
target_sources(MeshPart_tests_run PRIVATE
|
||||
add_executable(MeshPart_tests_run
|
||||
MeshPart.cpp
|
||||
)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
add_subdirectory(App)
|
||||
|
||||
target_link_libraries(MeshPart_tests_run
|
||||
gtest_main
|
||||
${Google_Tests_LIBS}
|
||||
MeshPart
|
||||
)
|
||||
|
||||
add_subdirectory(App)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
target_sources(Part_tests_run PRIVATE
|
||||
add_executable(Part_tests_run
|
||||
Attacher.cpp
|
||||
AttachExtension.cpp
|
||||
BRepMesh.cpp
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
add_subdirectory(App)
|
||||
|
||||
target_link_libraries(Part_tests_run
|
||||
gtest_main
|
||||
${Google_Tests_LIBS}
|
||||
Part
|
||||
)
|
||||
|
||||
add_subdirectory(App)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
target_sources(PartDesign_tests_run PRIVATE
|
||||
add_executable(PartDesign_tests_run
|
||||
BackwardCompatibility.cpp
|
||||
DatumPlane.cpp
|
||||
ShapeBinder.cpp
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
add_subdirectory(App)
|
||||
|
||||
target_link_libraries(PartDesign_tests_run
|
||||
gtest_main
|
||||
${Google_Tests_LIBS}
|
||||
PartDesign
|
||||
Sketcher
|
||||
)
|
||||
|
||||
add_subdirectory(App)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
target_sources(Points_tests_run PRIVATE
|
||||
add_executable(Points_tests_run
|
||||
Points.cpp
|
||||
PointsFeature.cpp
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
add_subdirectory(App)
|
||||
|
||||
target_link_libraries(Points_tests_run
|
||||
gtest_main
|
||||
${Google_Tests_LIBS}
|
||||
Points
|
||||
)
|
||||
|
||||
add_subdirectory(App)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
target_sources(Sketcher_tests_run PRIVATE
|
||||
add_executable(Sketcher_tests_run
|
||||
SketcherTestHelpers.cpp
|
||||
SketchObject.cpp
|
||||
SketchObjectChanges.cpp
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
add_subdirectory(App)
|
||||
|
||||
target_link_libraries(Sketcher_tests_run
|
||||
gtest_main
|
||||
${Google_Tests_LIBS}
|
||||
Sketcher
|
||||
)
|
||||
|
||||
add_subdirectory(App)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
target_sources(Spreadsheet_tests_run PRIVATE
|
||||
add_executable(Spreadsheet_tests_run
|
||||
PropertySheet.cpp
|
||||
RenameProperty.cpp
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
add_subdirectory(App)
|
||||
|
||||
target_link_libraries(Spreadsheet_tests_run
|
||||
gtest_main
|
||||
${Google_Tests_LIBS}
|
||||
Spreadsheet
|
||||
)
|
||||
|
||||
add_subdirectory(App)
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
target_sources(
|
||||
Start_tests_run
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/FileUtilities.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ThumbnailSource.cpp
|
||||
add_executable(Start_tests_run
|
||||
FileUtilities.cpp
|
||||
ThumbnailSource.cpp
|
||||
)
|
||||
|
||||
target_include_directories(
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
add_subdirectory(App)
|
||||
|
||||
target_include_directories(Start_tests_run PUBLIC
|
||||
${Python3_INCLUDE_DIRS}
|
||||
@@ -8,5 +9,3 @@ target_link_libraries(Start_tests_run
|
||||
${Google_Tests_LIBS}
|
||||
Start
|
||||
)
|
||||
|
||||
add_subdirectory(App)
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
target_sources(
|
||||
Tests_run
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/collectioncollection.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/zipfile.cpp
|
||||
add_executable(Zipios_tests_run
|
||||
collectioncollection.cpp
|
||||
zipfile.cpp
|
||||
)
|
||||
|
||||
|
||||
target_link_libraries(Zipios_tests_run PRIVATE
|
||||
GTest::gtest_main
|
||||
GTest::gmock_main
|
||||
${Google_Tests_LIBS}
|
||||
FreeCADApp
|
||||
)
|
||||
|
||||
target_include_directories(
|
||||
Zipios_tests_run PRIVATE
|
||||
${ZIPIOS_INCLUDES}
|
||||
${ZLIB_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user