NOISSUE remove dead unit tests and reorganize CMake code related to unit tests

This commit is contained in:
Petr Mrázek
2016-04-13 01:24:55 +02:00
parent ed3884fd38
commit e8ba5dafc6
15 changed files with 159 additions and 127 deletions

View File

@ -1,66 +1,82 @@
# run the unit tests with `make test`
find_package(Qt5Test)
include(UnitTest)
add_custom_target(test_data)
add_unit_test(gradlespecifier
SOURCES tst_gradlespecifier.cpp
LIBS MultiMC_logic
)
unset(MultiMC_TESTS)
macro(add_unit_test name)
unset(srcs)
foreach(arg ${testname} ${ARGN})
list(APPEND srcs ${CMAKE_CURRENT_SOURCE_DIR}/${arg})
endforeach()
if(WIN32)
list(APPEND srcs ${CMAKE_CURRENT_SOURCE_DIR}/test.rc)
endif()
add_executable(tst_${name} ${srcs})
add_dependencies(tst_${name} test_data)
target_link_libraries(tst_${name} MultiMC_logic)
qt5_use_modules(tst_${name} Test Core Network)
list(APPEND MultiMC_TESTS tst_${name})
add_test(NAME ${name} COMMAND tst_${name})
endmacro()
add_unit_test(userutils
SOURCES tst_userutils.cpp
LIBS MultiMC_logic
)
# Tests BEGIN #
add_unit_test(modutils
SOURCES tst_modutils.cpp
LIBS MultiMC_logic
)
add_unit_test(gradlespecifier tst_gradlespecifier.cpp)
add_unit_test(userutils tst_userutils.cpp)
add_unit_test(modutils tst_modutils.cpp)
add_unit_test(inifile tst_inifile.cpp)
add_unit_test(FileSystem tst_FileSystem.cpp)
add_unit_test(Library tst_Library.cpp)
add_unit_test(UpdateChecker tst_UpdateChecker.cpp)
add_unit_test(DownloadTask tst_DownloadTask.cpp)
add_unit_test(filematchers tst_filematchers.cpp)
add_unit_test(ModList tst_ModList.cpp)
# add_unit_test(Resource tst_Resource.cpp)
add_unit_test(GZip tst_GZip.cpp)
add_unit_test(JavaVersion tst_JavaVersion.cpp)
add_unit_test(ParseUtils tst_ParseUtils.cpp)
add_unit_test(MojangVersionFormat tst_MojangVersionFormat.cpp)
add_unit_test(BaseWonkoEntityLocalLoadTask tst_BaseWonkoEntityLocalLoadTask.cpp)
add_unit_test(BaseWonkoEntityRemoteLoadTask tst_BaseWonkoEntityRemoteLoadTask.cpp)
add_unit_test(WonkoVersionList tst_WonkoVersionList.cpp)
add_unit_test(WonkoIndex tst_WonkoIndex.cpp)
add_unit_test(inifile
SOURCES tst_inifile.cpp
LIBS MultiMC_logic
)
# Tests END #
add_unit_test(FileSystem
SOURCES tst_FileSystem.cpp
LIBS MultiMC_logic
)
add_unit_test(Library
SOURCES tst_Library.cpp
LIBS MultiMC_logic
)
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")
add_unit_test(UpdateChecker
SOURCES tst_UpdateChecker.cpp
LIBS MultiMC_logic
DATA data
)
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()
add_unit_test(DownloadTask
SOURCES tst_DownloadTask.cpp
LIBS MultiMC_logic
DATA data_raw
)
# 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
)
add_unit_test(filematchers
SOURCES tst_filematchers.cpp
LIBS MultiMC_logic
)
configure_file(test_config.h.in test_config.h @ONLY)
add_unit_test(ModList
SOURCES tst_ModList.cpp
LIBS MultiMC_logic
)
# add_unit_test(Resource
# SOURCES tst_Resource.cpp
# )
add_unit_test(GZip
SOURCES tst_GZip.cpp
LIBS MultiMC_logic
)
add_unit_test(JavaVersion
SOURCES tst_JavaVersion.cpp
LIBS MultiMC_logic
)
add_unit_test(ParseUtils
SOURCES tst_ParseUtils.cpp
LIBS MultiMC_logic
)
add_unit_test(MojangVersionFormat
SOURCES tst_MojangVersionFormat.cpp
LIBS MultiMC_logic
)
add_unit_test(WonkoIndex
SOURCES tst_WonkoIndex.cpp
LIBS MultiMC_logic
)

View File

@ -1,27 +0,0 @@
#pragma once
#include <QFile>
#include <QCoreApplication>
#include <QTest>
#include <QDir>
#include "test_config.h"
class TestsInternal
{
public:
static QByteArray readFile(const QString &fileName)
{
QFile f(fileName);
f.open(QFile::ReadOnly);
return f.readAll();
}
static QString readFileUtf8(const QString &fileName)
{
return QString::fromUtf8(readFile(fileName));
}
};
#define MULTIMC_GET_TEST_FILE(file) TestsInternal::readFile(QFINDTESTDATA(file))
#define MULTIMC_GET_TEST_FILE_UTF8(file) TestsInternal::readFileUtf8(QFINDTESTDATA(file))

View File

@ -1,13 +0,0 @@
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_URL@/fileOneA"
"Url": "@TEST_DATA_URL@/fileOneA"
}
],
"Executable": true,
@ -20,7 +20,7 @@
"Sources": [
{
"SourceType": "http",
"Url": "@MultiMC_TEST_DATA_URL@/fileTwo"
"Url": "@TEST_DATA_URL@/fileTwo"
}
],
"Executable": false,
@ -32,7 +32,7 @@
"Sources": [
{
"SourceType": "http",
"Url": "@MultiMC_TEST_DATA_URL@/fileThree"
"Url": "@TEST_DATA_URL@/fileThree"
}
],
"Executable": false,

View File

@ -8,7 +8,7 @@
"Sources": [
{
"SourceType": "http",
"Url": "@MultiMC_TEST_DATA_URL@/fileOneB"
"Url": "@TEST_DATA_URL@/fileOneB"
}
],
"Executable": true,
@ -20,7 +20,7 @@
"Sources": [
{
"SourceType": "http",
"Url": "@MultiMC_TEST_DATA_URL@/fileTwo"
"Url": "@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_URL@"
"url": "@TEST_DATA_URL@"
},
{
"id": "stable",
"name": "Stable",
"description": "It's stable at least",
"url": "@MultiMC_TEST_DATA_URL@"
"url": "@TEST_DATA_URL@"
},
{
"id": "42",

View File

@ -1,27 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<assemblyIdentity name="MultiMC.Test.0" type="win32" version="5.0.0.0" />
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="x86" publicKeyToken="6595b64144ccf1df" language="*"/>
</dependentAssembly>
</dependency>
<description>Custom Minecraft launcher for managing multiple installs.</description>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!--The ID below indicates app support for Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!--The ID below indicates app support for Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!--The ID below indicates app support for Windows Developer Preview / Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
</application>
</compatibility>
</assembly>

View File

@ -1,28 +0,0 @@
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
1 RT_MANIFEST "test.manifest"
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,0
FILEOS VOS_NT_WINDOWS32
FILETYPE VFT_APP
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "000004b0"
BEGIN
VALUE "CompanyName", "MultiMC Contributors"
VALUE "FileDescription", "Testcase"
VALUE "FileVersion", "1.0.0.0"
VALUE "ProductName", "MultiMC Testcase"
VALUE "ProductVersion", "5"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0000, 0x04b0 // Unicode
END
END

View File

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

View File

@ -1,15 +0,0 @@
#include <QTest>
#include "TestUtil.h"
#include "wonko/tasks/BaseWonkoEntityLocalLoadTask.h"
class BaseWonkoEntityLocalLoadTaskTest : public QObject
{
Q_OBJECT
private
slots:
};
QTEST_GUILESS_MAIN(BaseWonkoEntityLocalLoadTaskTest)
#include "tst_BaseWonkoEntityLocalLoadTask.moc"

View File

@ -1,15 +0,0 @@
#include <QTest>
#include "TestUtil.h"
#include "wonko/tasks/BaseWonkoEntityRemoteLoadTask.h"
class BaseWonkoEntityRemoteLoadTaskTest : public QObject
{
Q_OBJECT
private
slots:
};
QTEST_GUILESS_MAIN(BaseWonkoEntityRemoteLoadTaskTest)
#include "tst_BaseWonkoEntityRemoteLoadTask.moc"

View File

@ -8,6 +8,7 @@ Q_DECLARE_METATYPE(UpdateChecker::ChannelListEntry)
bool operator==(const UpdateChecker::ChannelListEntry &e1, const UpdateChecker::ChannelListEntry &e2)
{
qDebug() << e1.url << "vs" << e2.url;
return e1.id == e2.id &&
e1.name == e2.name &&
e1.description == e2.description &&
@ -76,8 +77,8 @@ slots:
<< true
<< true
<< (QList<UpdateChecker::ChannelListEntry>()
<< 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{"develop", "Develop", "The channel called \"develop\"", findTestDataUrl("tests/data")}
<< UpdateChecker::ChannelListEntry{"stable", "Stable", "It's stable at least", findTestDataUrl("tests/data")}
<< 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()

View File

@ -1,15 +0,0 @@
#include <QTest>
#include "TestUtil.h"
#include "wonko/WonkoVersionList.h"
class WonkoVersionListTest : public QObject
{
Q_OBJECT
private
slots:
};
QTEST_GUILESS_MAIN(WonkoVersionListTest)
#include "tst_WonkoVersionList.moc"