diff options
author | Petr Mrázek <peterix@gmail.com> | 2016-03-03 22:47:41 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2016-03-03 22:47:41 +0100 |
commit | 3d8728f52f220845fc4079d34b97458a122ac031 (patch) | |
tree | c259e26ce41af59d2bea32d33efaf15fb6f22351 /tests | |
parent | 2e4fa7ec13fa8a255cebcd023ab17dbd65e8c2cb (diff) | |
download | MultiMC-3d8728f52f220845fc4079d34b97458a122ac031.tar MultiMC-3d8728f52f220845fc4079d34b97458a122ac031.tar.gz MultiMC-3d8728f52f220845fc4079d34b97458a122ac031.tar.lz MultiMC-3d8728f52f220845fc4079d34b97458a122ac031.tar.xz MultiMC-3d8728f52f220845fc4079d34b97458a122ac031.zip |
NOISSUE no issue. with unit tests.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/CMakeLists.txt | 20 | ||||
-rw-r--r-- | tests/copy_tests.cmake | 13 | ||||
-rw-r--r-- | tests/data/1.json | 6 | ||||
-rw-r--r-- | tests/data/2.json | 4 | ||||
-rw-r--r-- | tests/data/channels.json | 4 | ||||
-rw-r--r-- | tests/test_config.h.in | 2 | ||||
-rw-r--r-- | tests/tst_UpdateChecker.cpp | 4 |
7 files changed, 32 insertions, 21 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 0b5bfc90..1061f911 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -100,20 +100,18 @@ set(MultiMC_TEST_DATA_PATH "${CMAKE_CURRENT_BINARY_DIR}/data") set(MultiMC_TEST_DATA_PATH_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/data") set(MultiMC_TEST_DATA_PATH_SOURCE_RAW "${CMAKE_CURRENT_SOURCE_DIR}/data_raw") -# clean and replace test data -add_custom_command( - TARGET test_data - COMMAND ${CMAKE_COMMAND} -E remove_directory ${MultiMC_TEST_DATA_PATH} - COMMAND ${CMAKE_COMMAND} -E copy_directory ${MultiMC_TEST_DATA_PATH_SOURCE} ${MultiMC_TEST_DATA_PATH} - COMMAND ${CMAKE_COMMAND} -E copy_directory ${MultiMC_TEST_DATA_PATH_SOURCE_RAW} ${MultiMC_TEST_DATA_PATH} -) - -message("${CMAKE_CURRENT_BINARY_DIR}/data") if(UNIX) # on unix we get the third / from the filename - set(MultiMC_TEST_DATA_PATH "file://${MultiMC_TEST_DATA_PATH}") + set(MultiMC_TEST_DATA_URL "file://${MultiMC_TEST_DATA_PATH}") else() # we don't on windows, so we have to add it ourselves - set(MultiMC_TEST_DATA_PATH "file:///${MultiMC_TEST_DATA_PATH}") + set(MultiMC_TEST_DATA_URL "file:///${MultiMC_TEST_DATA_PATH}") endif() + +# clean and replace test data +add_custom_command( + TARGET test_data + COMMAND ${CMAKE_COMMAND} -DMultiMC_TEST_DATA_URL=${MultiMC_TEST_DATA_URL} -DMultiMC_TEST_DATA_PATH=${MultiMC_TEST_DATA_PATH} -DMultiMC_TEST_DATA_PATH_SOURCE=${MultiMC_TEST_DATA_PATH_SOURCE} -DMultiMC_TEST_DATA_PATH_SOURCE_RAW=${MultiMC_TEST_DATA_PATH_SOURCE_RAW} -P ${CMAKE_CURRENT_SOURCE_DIR}/copy_tests.cmake +) + configure_file(test_config.h.in test_config.h @ONLY) diff --git a/tests/copy_tests.cmake b/tests/copy_tests.cmake new file mode 100644 index 00000000..0af7f730 --- /dev/null +++ b/tests/copy_tests.cmake @@ -0,0 +1,13 @@ +file(GLOB data_files "${MultiMC_TEST_DATA_PATH_SOURCE}/*") +foreach(data_file ${data_files}) + get_filename_component(filename ${data_file} NAME) + configure_file( + ${data_file} + ${MultiMC_TEST_DATA_PATH}/${filename} + @ONLY + NEWLINE_STYLE LF + ) +endforeach() + +file(GLOB raw_data_files "${MultiMC_TEST_DATA_PATH_SOURCE_RAW}/*") +file(COPY ${raw_data_files} DESTINATION ${MultiMC_TEST_DATA_PATH}/) diff --git a/tests/data/1.json b/tests/data/1.json index 0f2d6ced..7eda1618 100644 --- a/tests/data/1.json +++ b/tests/data/1.json @@ -8,7 +8,7 @@ "Sources": [ { "SourceType": "http", - "Url": "@MultiMC_TEST_DATA_PATH@/fileOneA" + "Url": "@MultiMC_TEST_DATA_URL@/fileOneA" } ], "Executable": true, @@ -20,7 +20,7 @@ "Sources": [ { "SourceType": "http", - "Url": "@MultiMC_TEST_DATA_PATH@/fileTwo" + "Url": "@MultiMC_TEST_DATA_URL@/fileTwo" } ], "Executable": false, @@ -32,7 +32,7 @@ "Sources": [ { "SourceType": "http", - "Url": "@MultiMC_TEST_DATA_PATH@/fileThree" + "Url": "@MultiMC_TEST_DATA_URL@/fileThree" } ], "Executable": false, diff --git a/tests/data/2.json b/tests/data/2.json index 6e2b0d3c..de7d0e07 100644 --- a/tests/data/2.json +++ b/tests/data/2.json @@ -8,7 +8,7 @@ "Sources": [ { "SourceType": "http", - "Url": "@MultiMC_TEST_DATA_PATH@/fileOneB" + "Url": "@MultiMC_TEST_DATA_URL@/fileOneB" } ], "Executable": true, @@ -20,7 +20,7 @@ "Sources": [ { "SourceType": "http", - "Url": "@MultiMC_TEST_DATA_PATH@/fileTwo" + "Url": "@MultiMC_TEST_DATA_URL@/fileTwo" } ], "Executable": false, diff --git a/tests/data/channels.json b/tests/data/channels.json index 3ad504b0..10eede82 100644 --- a/tests/data/channels.json +++ b/tests/data/channels.json @@ -5,13 +5,13 @@ "id": "develop", "name": "Develop", "description": "The channel called \"develop\"", - "url": "@MultiMC_TEST_DATA_PATH@" + "url": "@MultiMC_TEST_DATA_URL@" }, { "id": "stable", "name": "Stable", "description": "It's stable at least", - "url": "@MultiMC_TEST_DATA_PATH@" + "url": "@MultiMC_TEST_DATA_URL@" }, { "id": "42", diff --git a/tests/test_config.h.in b/tests/test_config.h.in index 69dd38e7..cf59f3e2 100644 --- a/tests/test_config.h.in +++ b/tests/test_config.h.in @@ -1,3 +1,3 @@ #pragma once -#define MultiMC_TEST_DATA_PATH "@MultiMC_TEST_DATA_PATH@" +#define MultiMC_TEST_DATA_URL "@MultiMC_TEST_DATA_URL@" diff --git a/tests/tst_UpdateChecker.cpp b/tests/tst_UpdateChecker.cpp index 42d44e77..de1ad718 100644 --- a/tests/tst_UpdateChecker.cpp +++ b/tests/tst_UpdateChecker.cpp @@ -76,8 +76,8 @@ slots: << true << true << (QList<UpdateChecker::ChannelListEntry>() - << UpdateChecker::ChannelListEntry{"develop", "Develop", "The channel called \"develop\"", MultiMC_TEST_DATA_PATH} - << UpdateChecker::ChannelListEntry{"stable", "Stable", "It's stable at least", MultiMC_TEST_DATA_PATH} + << UpdateChecker::ChannelListEntry{"develop", "Develop", "The channel called \"develop\"", MultiMC_TEST_DATA_URL} + << UpdateChecker::ChannelListEntry{"stable", "Stable", "It's stable at least", MultiMC_TEST_DATA_URL} << UpdateChecker::ChannelListEntry{"42", "The Channel", "This is the channel that is going to answer all of your questions", "https://dent.me/tea"}); } void tst_ChannelListParsing() |