AndroidTestUtilities: do not require ExternalData unconditionally

Attempting to use AndroidTestUtilities to simply install some local
files on device can result in the following error:

    Neither ExternalData_URL_TEMPLATES nor ExternalData_OBJECT_STORES is set

We no longer require these ExternalData-specific variables to be set if
no such remote data files are requested.

Fixes: #16529
This commit is contained in:
Zack Galbreath
2017-02-03 15:44:51 -05:00
committed by Brad King
parent 9d34e51cdb
commit 8a5cb84b0e
4 changed files with 31 additions and 5 deletions

View File

@@ -110,11 +110,18 @@ function(android_add_test_data test_name)
endforeach()
set(DATA_TARGET_NAME "${test_name}")
ExternalData_Expand_Arguments(
${DATA_TARGET_NAME}
extern_data_output
${AST_FILES})
ExternalData_Add_Target(${DATA_TARGET_NAME})
string(FIND "${AST_FILES}" "DATA{" data_files_found)
if(${data_files_found} GREATER "-1")
# Use ExternalData if any DATA{} files were found.
ExternalData_Expand_Arguments(
${DATA_TARGET_NAME}
extern_data_output
${AST_FILES})
ExternalData_Add_Target(${DATA_TARGET_NAME})
else()
add_custom_target(${DATA_TARGET_NAME} ALL)
set(extern_data_output ${AST_FILES})
endif()
# For regular files on Linux, just copy them directly.
foreach(path ${AST_FILES})

View File

@@ -18,3 +18,4 @@ endfunction()
run_ATU(SetupTest1 "")
run_ATU(SetupTest2 "tests")
run_ATU(SetupTest3 "tests")
run_ATU(SetupTest4 "")

View File

@@ -0,0 +1,13 @@
enable_testing()
include(AndroidTestUtilities)
find_program(adb_executable adb)
set(test_files "data/a.txt")
set(ANDROID 1)
android_add_test_data(setup_test
FILES ${test_files}
DEVICE_TEST_DIR "/data/local/tests/example1"
DEVICE_OBJECT_STORE "/sdcard/.ExternalData/SHA")

View File

@@ -0,0 +1,5 @@
include(${CMAKE_CURRENT_LIST_DIR}/check.cmake)
compare_build_to_expected(FILES
"data/a.txt"
)
check_for_setup_test()