NOISSUE no issue. with unit tests.

This commit is contained in:
Petr Mrázek 2016-03-03 22:47:41 +01:00
parent 2e4fa7ec13
commit 3d8728f52f
7 changed files with 32 additions and 21 deletions

View File

@ -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")
if(UNIX)
# on unix we get the third / from the filename
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_URL "file:///${MultiMC_TEST_DATA_PATH}")
endif()
# 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}
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
)
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}")
else()
# we don't on windows, so we have to add it ourselves
set(MultiMC_TEST_DATA_PATH "file:///${MultiMC_TEST_DATA_PATH}")
endif()
configure_file(test_config.h.in test_config.h @ONLY)

13
tests/copy_tests.cmake Normal file
View File

@ -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}/)

View File

@ -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,

View File

@ -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,

View File

@ -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",

View File

@ -1,3 +1,3 @@
#pragma once
#define MultiMC_TEST_DATA_PATH "@MultiMC_TEST_DATA_PATH@"
#define MultiMC_TEST_DATA_URL "@MultiMC_TEST_DATA_URL@"

View File

@ -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()