Skip to content

Commit

Permalink
Better CMake integration of test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
dokempf committed Mar 3, 2025
1 parent e684dce commit 341d2a6
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 40 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,14 @@ jobs:
- name: Install Helios
run: |
python -m pip install --no-build-isolation --config-settings=cmake.build-type="Debug" --config-settings=build-dir="build" -v .
python -m pip install --no-build-isolation --config-settings=cmake.build-type="Debug" --config-settings=build-dir="build" --config-settings=cmake.define.BUILD_TESTING="ON" -v .
env:
SETUPTOOLS_SCM_SUBPROCESS_TIMEOUT: "120"

- name: Run C++ test suite
working-directory: ./build
run: |
./build/src/test/helios_test
ctest --output-on-failure
# Do not run on MacOS for now - we do not yet officially support it and we need to invest a bit
# more efforts into investigating broken LAZ files written by Helios on MacOS.
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@ jobs:
- name: Install Helios (editable)
run: |
python -m pip install --no-build-isolation --config-settings=cmake.build-type="Debug" --config-settings=build-dir="build" --config-settings=cmake.define.CMAKE_CXX_FLAGS="--coverage" -v -e .
python -m pip install --no-build-isolation --config-settings=cmake.build-type="Debug" --config-settings=build-dir="build" --config-settings=cmake.define.BUILD_TESTING="ON" --config-settings=cmake.define.CMAKE_CXX_FLAGS="--coverage" -v -e .
env:
SETUPTOOLS_SCM_SUBPROCESS_TIMEOUT: "120"

- name: Run C++ test suite
working-directory: ./build
run: |
./build/src/test/helios_test
ctest --output-on-failure
- name: Run PyTest test suite
run: |
Expand Down
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,13 @@ if(BUILD_PYTHON)
install(TARGETS _helios DESTINATION .)
endif()


# Create test suite
include(CTest)
if(BUILD_TESTING)
add_executable(helios_test)
add_test(NAME helios_test COMMAND helios_test ${CMAKE_SOURCE_DIR})
target_link_libraries(helios_test PUBLIC helios)
endif()

# Traverse the source tree to add all relevant sources
add_subdirectory(src)
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ minimum-version = "3.18"
[tool.scikit-build.cmake.define]
BUILD_DOCS = "OFF"
BUILD_PYTHON = "ON"
BUILD_TESTING = "OFF"
HELIOS_DATA_ANALYTICS = "0"
HELIOS_BUDDING_METRICS = "0"
# Executable built and installed during "pip install" should
Expand Down
9 changes: 5 additions & 4 deletions src/test/AssetLoadingTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ class AssetLoadingTest : public BaseTest{
* @brief Decimal precision tolerance
*/
double const eps = 0.00001;
std::string testDir;

// *** CONSTRUCTOR *** //
// ********************* //
/**
* @brief Asset loading test constructor
*/
AssetLoadingTest() : BaseTest("Asset loading test"){}
AssetLoadingTest(const std::string& testDir) : BaseTest("Asset loading test"), testDir(testDir) {}

// *** R U N *** //
// *************** //
Expand Down Expand Up @@ -121,7 +122,7 @@ bool AssetLoadingTest::run(){
bool AssetLoadingTest::testScannerLoading(){
// Prepare scanner loading
std::string testScannersPath = "data/test/test_scanners.xml";
std::vector<std::string> assetsPath = { "assets/" };
std::vector<std::string> assetsPath = { testDir, "assets/" };
XmlAssetsLoader loader(testScannersPath, assetsPath);
// Load and validate Leica ALS50
std::shared_ptr<Scanner> scanner = std::static_pointer_cast<Scanner>(
Expand Down Expand Up @@ -524,7 +525,7 @@ bool AssetLoadingTest::testScannerLoading(){
bool AssetLoadingTest::testPlatformLoading(){
// Prepare platform loading
std::string testPlatformsPath = "data/test/test_platforms.xml";
std::vector<std::string> assetsPath = { "assets/" };
std::vector<std::string> assetsPath = { testDir, "assets/" };
XmlAssetsLoader loader(testPlatformsPath, assetsPath);
// Load and validate Quadrocopter UAV
std::shared_ptr<Platform> platf = std::dynamic_pointer_cast<Platform>(
Expand Down Expand Up @@ -728,4 +729,4 @@ bool AssetLoadingTest::testSurveyLoading(){
}


}
}
27 changes: 9 additions & 18 deletions src/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
target_include_directories(
helios
PUBLIC
"."
)

target_sources(
helios
PRIVATE
"Tests.cpp"
)

add_executable(
helios_test
"Main.cpp"
)

target_link_libraries(helios_test PUBLIC helios)
if(BUILD_TESTING)
target_sources(
helios_test
PRIVATE
"Main.cpp"
"Tests.cpp"
)
target_include_directories(helios_test PRIVATE ".")
endif()
18 changes: 9 additions & 9 deletions src/test/FluxionumTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,10 @@ bool FluxionumTest::testDesignMatrixBuilding(){
"0.3 0.3 0.1;"
"0.3 0.3 0.2"
);
string const dmf1Path = testDir + "design_matrix_header.txt";
string const dmf1Path = testDir + "data/test/design_matrix_header.txt";
DesignMatrix<double> dmf1(dmf1Path);
if(!validateDesignMatrix(dmf1, hf1, Xf1)) return false;
string const dmf2Path = testDir + "design_matrix_nonheader.txt";
string const dmf2Path = testDir + "data/test/design_matrix_nonheader.txt";
DesignMatrix<double> dmf2(dmf2Path);
if(!validateDesignMatrix(dmf2, vector<string>(0), Xf1)) return false;

Expand All @@ -286,11 +286,11 @@ bool FluxionumTest::testDesignMatrixBuilding(){
"0.3 0.3"
);
arma::Col<double> ttf1("0 0.1 0.2 0.3 0.4 0.5 0.6 0.8 1.0");
string const tdmf1Path = testDir + "temporal_design_matrix_header.txt";
string const tdmf1Path = testDir + "data/test/temporal_design_matrix_header.txt";
TemporalDesignMatrix<double, double> tdmf1(tdmf1Path);
if(!validateTemporalDesignMatrix(tdmf1, "t", htf1, ttf1, Xtf1))
return false;
string const tdmf2Path = testDir + "temporal_design_matrix_nonheader.txt";
string const tdmf2Path = testDir + "data/test/temporal_design_matrix_nonheader.txt";
TemporalDesignMatrix<double, double> tdmf2(tdmf2Path);
if(!validateTemporalDesignMatrix(
tdmf2, "time", vector<string>(0), ttf1, Xtf1
Expand All @@ -310,11 +310,11 @@ bool FluxionumTest::testDesignMatrixBuilding(){
"0.3 0.3"
);
vector<int> iif1({0, 1, 2, 3, 4, 6, 8, 7, 5});
string const idmf1Path = testDir + "indexed_design_matrix_header.txt";
string const idmf1Path = testDir + "data/test/indexed_design_matrix_header.txt";
IndexedDesignMatrix<int, double> idmf1(idmf1Path);
if(!validateIndexedDesignMatrix(idmf1, "idx", hif1, iif1, Xif1))
return false;
string const idmf2Path = testDir + "indexed_design_matrix_nonheader.txt";
string const idmf2Path = testDir + "data/test/indexed_design_matrix_nonheader.txt";
IndexedDesignMatrix<int, double> idmf2(idmf2Path);
if(!validateIndexedDesignMatrix(
idmf2, "index", vector<string>(0), iif1, Xif1
Expand Down Expand Up @@ -616,13 +616,13 @@ bool FluxionumTest::testDiffDesignMatrix(){
)) return false;

// Load diff design matrix from file
string const ddmf1Path = testDir + "diff_design_matrix_header.txt";
string const ddmf1Path = testDir + "data/test/diff_design_matrix_header.txt";
DiffDesignMatrix<double, double> ddmf1(ddmf1Path);
if(!validateDiffDesignMatrix(
ddmf1, EtimeName1, EcolNames1, Et1, EA1,
DiffDesignMatrixType::FORWARD_FINITE_DIFFERENCES
)) return false;
string const ddmf2Path = testDir + "diff_design_matrix_nonheader.txt";
string const ddmf2Path = testDir + "data/test/diff_design_matrix_nonheader.txt";
DiffDesignMatrix<double, double> ddmf2(ddmf2Path);
if(!validateDiffDesignMatrix(
ddmf2, EtimeName2, vector<string>(0), Et3, EA3,
Expand Down Expand Up @@ -798,4 +798,4 @@ bool FluxionumTest::testDesignFunctions(){
return true;
}

}
}
2 changes: 1 addition & 1 deletion src/test/LadLutTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ bool LadLutTest::run(){
double g3 = 0.673911;

// Load spherical
std::string llPath = testDir + "spherical.txt";
std::string llPath = testDir + "data/test/spherical.txt";
LadLutLoader loader;
std::shared_ptr<LadLut> ladlut = loader.load(llPath);
if(!validateLadLut(*ladlut)) return false;
Expand Down
2 changes: 1 addition & 1 deletion src/test/Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void doTests(std::string const & testDir){
SerializationTest serializationTest;
passed &= serializationTest.test(std::cout, TEST_COLOR);

AssetLoadingTest assetLoadingTest;
AssetLoadingTest assetLoadingTest(testDir);
passed &= assetLoadingTest.test(std::cout, TEST_COLOR);

SurveyCopyTest surveyCopyTest;
Expand Down
4 changes: 2 additions & 2 deletions src/test/VoxelParsingTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class VoxelParsingTest : public BaseTest {

bool VoxelParsingTest::run(){
double eps = 0.0001;
std::string vfPath = testDir + "semitransparent_voxels.vox";
std::string vfPath = testDir + "data/test/semitransparent_voxels.vox";
VoxelFileParser vfp;
std::vector<std::shared_ptr<DetailedVoxel>> dvoxels = vfp.parseDetailed(
vfPath,
Expand Down Expand Up @@ -157,4 +157,4 @@ bool VoxelParsingTest::run(){
}


}
}

0 comments on commit 341d2a6

Please sign in to comment.