Skip to content

Commit 6138592

Browse files
committed
tests: sample images files can run from a locally sourced file archive
1 parent 598cc6a commit 6138592

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

Jenkinsfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,7 @@ pipeline {
536536
-Wdev \
537537
-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON \
538538
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=true \
539+
-DSAMPLE_IMAGES_ARCHIVE=${SAMPLE_IMAGES_ARCHIVE} \
539540
-DBUILD_TESTING:BOOL=true \
540541
-DCMAKE_CXX_FLAGS="-fno-inline -fno-omit-frame-pointer -fprofile-arcs -ftest-coverage -Wall -Wextra" \
541542
-DMEMORYCHECK_COMMAND=$(which drmemory) \

tests/CMakeLists.txt

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
11
if (BUILD_TESTING AND Catch2_FOUND)
22
include(FetchContent)
33
include(Catch)
4+
set(SAMPLE_IMAGES_ARCHIVE "" CACHE FILEPATH "Path to sample images archive. If not set, it will be downloaded from the internet.")
45

56
# Get sample images
6-
if(NOT EXISTS ${PROJECT_BINARY_DIR}/metadata_test_images.tar.gz)
7-
file(DOWNLOAD https://nexus.library.illinois.edu/repository/sample-data/images/metadata_test_images.tar.gz ${PROJECT_BINARY_DIR}/metadata_test_images.tar.gz SHOW_PROGRESS)
8-
endif()
9-
FetchContent_Declare(
10-
test_images
11-
URL ${PROJECT_BINARY_DIR}/metadata_test_images.tar.gz
12-
)
13-
FetchContent_MakeAvailable(test_images)
7+
if(SAMPLE_IMAGES_ARCHIVE)
8+
set(TEST_IMAGE_PATH "${CMAKE_CURRENT_BINARY_DIR}/metadata_test_images/")
9+
file(ARCHIVE_EXTRACT
10+
INPUT "${SAMPLE_IMAGES_ARCHIVE}"
11+
DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/"
12+
)
13+
else ()
14+
FetchContent_Declare(
15+
test_images
16+
URL ${PROJECT_BINARY_DIR}/metadata_test_images.tar.gz
17+
)
18+
FetchContent_MakeAvailable(test_images)
19+
set(TEST_IMAGE_PATH ${test_images_SOURCE_DIR})
20+
endif ()
1421
add_executable(tester test-basic.cpp test_exceptions.cpp)
1522
target_include_directories(tester PRIVATE ${PROJECT_SOURCE_DIR}/uiucprescon/imagevalidate)
1623

17-
target_compile_definitions(tester PRIVATE TEST_IMAGE_PATH="${test_images_SOURCE_DIR}")
24+
target_compile_definitions(tester PRIVATE TEST_IMAGE_PATH="${TEST_IMAGE_PATH}")
1825
target_link_libraries(tester PRIVATE Catch2::Catch2WithMain imagevalidate::glue)
1926
catch_discover_tests(tester
2027
TEST_PREFIX imagevalidate.
@@ -24,7 +31,7 @@ if (BUILD_TESTING AND Catch2_FOUND)
2431

2532
add_executable(tester-internal tester-internal.cpp)
2633
target_compile_definitions(tester-internal
27-
PRIVATE TEST_IMAGE_PATH="${test_images_SOURCE_DIR}")
34+
PRIVATE TEST_IMAGE_PATH="${TEST_IMAGE_PATH}")
2835

2936

3037
target_link_libraries(tester-internal

0 commit comments

Comments
 (0)