From 4c7d3a103ca9cfd3af0b3acf2877561150c5ac60 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Sun, 11 Sep 2022 22:25:18 +0200 Subject: [PATCH] refactor: restructure tests Signed-off-by: Sefa Eyeoglu --- CMakeLists.txt | 5 +- launcher/CMakeLists.txt | 62 +----------------- tests/CMakeLists.txt | 43 ++++++++++++ {launcher => tests}/FileSystem_test.cpp | 4 +- {launcher => tests}/GZip_test.cpp | 2 +- .../GradleSpecifier_test.cpp | 2 +- {launcher/settings => tests}/INIFile_test.cpp | 2 +- {launcher/meta => tests}/Index_test.cpp | 4 +- {launcher/java => tests}/JavaVersion_test.cpp | 2 +- .../minecraft => tests}/Library_test.cpp | 48 +++++++------- .../MojangVersionFormat_test.cpp | 6 +- .../mojang => tests}/PackageManifest_test.cpp | 8 +-- .../packwiz => tests}/Packwiz_test.cpp | 6 +- .../minecraft => tests}/ParseUtils_test.cpp | 2 +- .../ResourceFolderModel_test.cpp | 18 ++--- .../mod => tests}/ResourcePackParse_test.cpp | 12 ++-- {launcher/tasks => tests}/Task_test.cpp | 8 +-- {launcher => tests}/Version_test.cpp | 2 +- .../FileSystem-test_createShortcut-unix | Bin .../assets/minecraft/textures/blah.txt | Bin .../FileSystem}/test_folder/pack.mcmeta | Bin .../testdata/FileSystem}/test_folder/pack.nfo | Bin tests/testdata/Library | 1 + .../MojangVersionFormat}/1.9-simple.json | Bin .../testdata/MojangVersionFormat}/1.9.json | Bin .../codecwav-20101023.jar | Bin .../MojangVersionFormat}/lib-native-arch.json | Bin .../MojangVersionFormat}/lib-native.json | Bin .../MojangVersionFormat}/lib-simple.json | Bin .../testname-testversion-linux-32.jar | Bin .../PackageManifest}/1.8.0_202-x64.json | Bin .../testdata/PackageManifest}/inspect/a/b.txt | Bin .../PackageManifest}/inspect/a/b/b.txt | 0 .../PackageManifest}/inspect_win/a/b.txt | Bin .../PackageManifest}/inspect_win/a/b/b.txt | Bin .../Packwiz}/borderless-mining.pw.toml | Bin .../screenshot-to-clipboard-fabric.pw.toml | Bin tests/testdata/ResourceFolderModel | 1 + .../another_test_folder/pack.mcmeta | Bin .../ResourcePackParse}/supercoolmod.jar | Bin .../assets/minecraft/textures/blah.txt | Bin .../test_folder/pack.mcmeta | Bin .../ResourcePackParse}/test_folder/pack.nfo | Bin .../test_resource_pack_idk.zip | Bin 44 files changed, 113 insertions(+), 125 deletions(-) create mode 100644 tests/CMakeLists.txt rename {launcher => tests}/FileSystem_test.cpp (97%) rename {launcher => tests}/GZip_test.cpp (98%) rename {launcher/minecraft => tests}/GradleSpecifier_test.cpp (98%) rename {launcher/settings => tests}/INIFile_test.cpp (97%) rename {launcher/meta => tests}/Index_test.cpp (96%) rename {launcher/java => tests}/JavaVersion_test.cpp (99%) rename {launcher/minecraft => tests}/Library_test.cpp (88%) rename {launcher/minecraft => tests}/MojangVersionFormat_test.cpp (85%) rename {launcher/mojang => tests}/PackageManifest_test.cpp (97%) rename {launcher/modplatform/packwiz => tests}/Packwiz_test.cpp (94%) rename {launcher/minecraft => tests}/ParseUtils_test.cpp (96%) rename {launcher/minecraft/mod => tests}/ResourceFolderModel_test.cpp (92%) rename {launcher/minecraft/mod => tests}/ResourcePackParse_test.cpp (86%) rename {launcher/tasks => tests}/Task_test.cpp (97%) rename {launcher => tests}/Version_test.cpp (99%) rename {launcher/testdata => tests/testdata/FileSystem}/FileSystem-test_createShortcut-unix (100%) rename {launcher/minecraft/mod/testdata => tests/testdata/FileSystem}/test_folder/assets/minecraft/textures/blah.txt (100%) rename {launcher/minecraft/mod/testdata => tests/testdata/FileSystem}/test_folder/pack.mcmeta (100%) rename {launcher/minecraft/mod/testdata => tests/testdata/FileSystem}/test_folder/pack.nfo (100%) create mode 120000 tests/testdata/Library rename {launcher/minecraft/testdata => tests/testdata/MojangVersionFormat}/1.9-simple.json (100%) rename {launcher/minecraft/testdata => tests/testdata/MojangVersionFormat}/1.9.json (100%) rename {launcher/minecraft/testdata => tests/testdata/MojangVersionFormat}/codecwav-20101023.jar (100%) rename {launcher/minecraft/testdata => tests/testdata/MojangVersionFormat}/lib-native-arch.json (100%) rename {launcher/minecraft/testdata => tests/testdata/MojangVersionFormat}/lib-native.json (100%) rename {launcher/minecraft/testdata => tests/testdata/MojangVersionFormat}/lib-simple.json (100%) rename {launcher/minecraft/testdata => tests/testdata/MojangVersionFormat}/testname-testversion-linux-32.jar (100%) rename {launcher/mojang/testdata => tests/testdata/PackageManifest}/1.8.0_202-x64.json (100%) rename {launcher/mojang/testdata => tests/testdata/PackageManifest}/inspect/a/b.txt (100%) rename {launcher/mojang/testdata => tests/testdata/PackageManifest}/inspect/a/b/b.txt (100%) rename {launcher/mojang/testdata => tests/testdata/PackageManifest}/inspect_win/a/b.txt (100%) rename {launcher/mojang/testdata => tests/testdata/PackageManifest}/inspect_win/a/b/b.txt (100%) rename {launcher/modplatform/packwiz/testdata => tests/testdata/Packwiz}/borderless-mining.pw.toml (100%) rename {launcher/modplatform/packwiz/testdata => tests/testdata/Packwiz}/screenshot-to-clipboard-fabric.pw.toml (100%) create mode 120000 tests/testdata/ResourceFolderModel rename {launcher/minecraft/mod/testdata => tests/testdata/ResourcePackParse}/another_test_folder/pack.mcmeta (100%) rename {launcher/minecraft/mod/testdata => tests/testdata/ResourcePackParse}/supercoolmod.jar (100%) rename {launcher/testdata => tests/testdata/ResourcePackParse}/test_folder/assets/minecraft/textures/blah.txt (100%) rename {launcher/testdata => tests/testdata/ResourcePackParse}/test_folder/pack.mcmeta (100%) rename {launcher/testdata => tests/testdata/ResourcePackParse}/test_folder/pack.nfo (100%) rename {launcher/minecraft/mod/testdata => tests/testdata/ResourcePackParse}/test_resource_pack_idk.zip (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6cb806a3..7100ab1b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,7 +67,7 @@ find_package(ECM REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH "${ECM_MODULE_PATH};${CMAKE_MODULE_PATH}") include(CTest) include(ECMAddTests) -if (BUILD_TESTING) +if(BUILD_TESTING) enable_testing() endif() @@ -321,5 +321,8 @@ add_subdirectory(libraries/murmur2) # Hash for usage with the CurseForge API add_subdirectory(buildconfig) +if(BUILD_TESTING) + add_subdirectory(tests) +endif() # NOTE: this must always be last to appease the CMake deity of quirky install command evaluation order. add_subdirectory(launcher) diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index a5303e94..6e93b530 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -88,12 +88,6 @@ set(CORE_SOURCES MMCTime.cpp ) -ecm_add_test(FileSystem_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test - TEST_NAME FileSystem) # TODO: needs testdata - -ecm_add_test(GZip_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test - TEST_NAME GZip) - set(PATHMATCHER_SOURCES # Path matchers pathmatcher/FSTreeMatcher.h @@ -355,46 +349,6 @@ set(MINECRAFT_SOURCES mojang/PackageManifest.cpp minecraft/Agent.h) -ecm_add_test(minecraft/GradleSpecifier_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test - TEST_NAME GradleSpecifier) - -if(BUILD_TESTING) - add_executable(PackageManifest - mojang/PackageManifest_test.cpp - ) - target_link_libraries(PackageManifest - Launcher_logic - Qt${QT_VERSION_MAJOR}::Test - ) - target_include_directories(PackageManifest - PRIVATE ../cmake/UnitTest/ - ) - add_test( - NAME PackageManifest - COMMAND PackageManifest - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - ) -endif() - -# TODO: needs minecraft/testdata -ecm_add_test(minecraft/MojangVersionFormat_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test - TEST_NAME MojangVersionFormat) - -ecm_add_test(minecraft/Library_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test - TEST_NAME Library) - -# FIXME: shares data with FileSystem test -# TODO: needs testdata -ecm_add_test(minecraft/mod/ResourceFolderModel_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test - TEST_NAME ResourceFolderModel) - -ecm_add_test(minecraft/mod/ResourcePackParse_test.cpp - LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test - TEST_NAME ResourcePackParse) - -ecm_add_test(minecraft/ParseUtils_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test - TEST_NAME ParseUtils) - # the screenshots feature set(SCREENSHOTS_SOURCES screenshots/Screenshot.h @@ -416,9 +370,6 @@ set(TASKS_SOURCES tasks/MultipleOptionsTask.cpp ) -ecm_add_test(tasks/Task_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test - TEST_NAME Task) - set(SETTINGS_SOURCES # Settings settings/INIFile.cpp @@ -435,9 +386,6 @@ set(SETTINGS_SOURCES settings/SettingsObject.h ) -ecm_add_test(settings/INIFile_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test - TEST_NAME INIFile) - set(JAVA_SOURCES java/JavaChecker.h java/JavaChecker.cpp @@ -453,9 +401,6 @@ set(JAVA_SOURCES java/JavaVersion.cpp ) -ecm_add_test(java/JavaVersion_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test - TEST_NAME JavaVersion) - set(TRANSLATIONS_SOURCES translations/TranslationsModel.h translations/TranslationsModel.cpp @@ -558,9 +503,6 @@ set(PACKWIZ_SOURCES modplatform/packwiz/Packwiz.cpp ) -# TODO: needs modplatform/packwiz/testdata -ecm_add_test(modplatform/packwiz/Packwiz_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test - TEST_NAME Packwiz) set(TECHNIC_SOURCES modplatform/technic/SingleZipPackInstallTask.h @@ -584,9 +526,6 @@ set(ATLAUNCHER_SOURCES modplatform/atlauncher/ATLShareCode.h ) -ecm_add_test(meta/Index_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test - TEST_NAME Index) - ################################ COMPILE ################################ # we need zlib @@ -1005,6 +944,7 @@ endif() # Add executable add_library(Launcher_logic STATIC ${LOGIC_SOURCES} ${LAUNCHER_SOURCES} ${LAUNCHER_UI} ${LAUNCHER_RESOURCES}) +target_include_directories(Launcher_logic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_link_libraries(Launcher_logic systeminfo Launcher_classparser diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 00000000..1265d7a5 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,43 @@ +project(tests) + +ecm_add_test(FileSystem_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test + TEST_NAME FileSystem) + +ecm_add_test(GZip_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test + TEST_NAME GZip) + +ecm_add_test(GradleSpecifier_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test + TEST_NAME GradleSpecifier) + +ecm_add_test(PackageManifest_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test + TEST_NAME PackageManifest) + +ecm_add_test(MojangVersionFormat_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test + TEST_NAME MojangVersionFormat) + +ecm_add_test(Library_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test + TEST_NAME Library) + +ecm_add_test(ResourceFolderModel_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test + TEST_NAME ResourceFolderModel) + +ecm_add_test(ResourcePackParse_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test + TEST_NAME ResourcePackParse) + +ecm_add_test(ParseUtils_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test + TEST_NAME ParseUtils) + +ecm_add_test(Task_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test + TEST_NAME Task) + +ecm_add_test(INIFile_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test + TEST_NAME INIFile) + +ecm_add_test(JavaVersion_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test + TEST_NAME JavaVersion) + +ecm_add_test(Packwiz_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test + TEST_NAME Packwiz) + +ecm_add_test(Index_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test + TEST_NAME Index) diff --git a/launcher/FileSystem_test.cpp b/tests/FileSystem_test.cpp similarity index 97% rename from launcher/FileSystem_test.cpp rename to tests/FileSystem_test.cpp index 99ae9269..6df13e80 100644 --- a/launcher/FileSystem_test.cpp +++ b/tests/FileSystem_test.cpp @@ -2,7 +2,7 @@ #include #include -#include "FileSystem.h" +#include class FileSystemTest : public QObject { @@ -80,7 +80,7 @@ slots: void test_copy() { - QString folder = QFINDTESTDATA("testdata/test_folder"); + QString folder = QFINDTESTDATA("testdata/FileSystem/test_folder"); auto f = [&folder]() { QTemporaryDir tempDir; diff --git a/launcher/GZip_test.cpp b/tests/GZip_test.cpp similarity index 98% rename from launcher/GZip_test.cpp rename to tests/GZip_test.cpp index 73859fbc..1e762b2e 100644 --- a/launcher/GZip_test.cpp +++ b/tests/GZip_test.cpp @@ -1,6 +1,6 @@ #include -#include "GZip.h" +#include #include void fib(int &prev, int &cur) diff --git a/launcher/minecraft/GradleSpecifier_test.cpp b/tests/GradleSpecifier_test.cpp similarity index 98% rename from launcher/minecraft/GradleSpecifier_test.cpp rename to tests/GradleSpecifier_test.cpp index a062dfac..850f8388 100644 --- a/launcher/minecraft/GradleSpecifier_test.cpp +++ b/tests/GradleSpecifier_test.cpp @@ -1,6 +1,6 @@ #include -#include "minecraft/GradleSpecifier.h" +#include class GradleSpecifierTest : public QObject { diff --git a/launcher/settings/INIFile_test.cpp b/tests/INIFile_test.cpp similarity index 97% rename from launcher/settings/INIFile_test.cpp rename to tests/INIFile_test.cpp index d23f9fdf..b64b031b 100644 --- a/launcher/settings/INIFile_test.cpp +++ b/tests/INIFile_test.cpp @@ -1,6 +1,6 @@ #include -#include "settings/INIFile.h" +#include class IniFileTest : public QObject { diff --git a/launcher/meta/Index_test.cpp b/tests/Index_test.cpp similarity index 96% rename from launcher/meta/Index_test.cpp rename to tests/Index_test.cpp index 261858c4..436b753e 100644 --- a/launcher/meta/Index_test.cpp +++ b/tests/Index_test.cpp @@ -1,7 +1,7 @@ #include -#include "meta/Index.h" -#include "meta/VersionList.h" +#include +#include class IndexTest : public QObject { diff --git a/launcher/java/JavaVersion_test.cpp b/tests/JavaVersion_test.cpp similarity index 99% rename from launcher/java/JavaVersion_test.cpp rename to tests/JavaVersion_test.cpp index 545947ef..76d9af2f 100644 --- a/launcher/java/JavaVersion_test.cpp +++ b/tests/JavaVersion_test.cpp @@ -1,6 +1,6 @@ #include -#include "java/JavaVersion.h" +#include class JavaVersionTest : public QObject { diff --git a/launcher/minecraft/Library_test.cpp b/tests/Library_test.cpp similarity index 88% rename from launcher/minecraft/Library_test.cpp rename to tests/Library_test.cpp index 834dd558..869c7673 100644 --- a/launcher/minecraft/Library_test.cpp +++ b/tests/Library_test.cpp @@ -1,10 +1,10 @@ #include -#include "minecraft/MojangVersionFormat.h" -#include "minecraft/OneSixVersionFormat.h" -#include "minecraft/Library.h" -#include "net/HttpMetaCache.h" -#include "FileSystem.h" +#include +#include +#include +#include +#include class LibraryTest : public QObject { @@ -30,7 +30,7 @@ slots: { cache.reset(new HttpMetaCache()); cache->addBase("libraries", QDir("libraries").absolutePath()); - dataDir = QDir(QFINDTESTDATA("testdata")).absolutePath(); + dataDir = QDir(QFINDTESTDATA("testdata/Library")).absolutePath(); } void test_legacy() { @@ -72,14 +72,14 @@ slots: QCOMPARE(test.isNative(), false); QStringList failedFiles; test.setHint("local"); - auto downloads = test.getDownloads(currentSystem, cache.get(), failedFiles, QFINDTESTDATA("testdata")); + auto downloads = test.getDownloads(currentSystem, cache.get(), failedFiles, QFINDTESTDATA("testdata/Library")); QCOMPARE(downloads.size(), 0); qDebug() << failedFiles; QCOMPARE(failedFiles.size(), 0); QStringList jar, native, native32, native64; - test.getApplicableFiles(currentSystem, jar, native, native32, native64, QFINDTESTDATA("testdata")); - QCOMPARE(jar, {QFileInfo(QFINDTESTDATA("testdata/codecwav-20101023.jar")).absoluteFilePath()}); + test.getApplicableFiles(currentSystem, jar, native, native32, native64, QFINDTESTDATA("testdata/Library")); + QCOMPARE(jar, {QFileInfo(QFINDTESTDATA("testdata/Library/codecwav-20101023.jar")).absoluteFilePath()}); QCOMPARE(native, {}); QCOMPARE(native32, {}); QCOMPARE(native64, {}); @@ -165,20 +165,20 @@ slots: test.setRepositoryURL("file://foo/bar"); { QStringList jar, native, native32, native64; - test.getApplicableFiles(Os_Linux, jar, native, native32, native64, QFINDTESTDATA("testdata")); + test.getApplicableFiles(Os_Linux, jar, native, native32, native64, QFINDTESTDATA("testdata/Library")); QCOMPARE(jar, {}); QCOMPARE(native, {}); - QCOMPARE(native32, {QFileInfo(QFINDTESTDATA("testdata/testname-testversion-linux-32.jar")).absoluteFilePath()}); - QCOMPARE(native64, {QFileInfo(QFINDTESTDATA("testdata") + "/testname-testversion-linux-64.jar").absoluteFilePath()}); + QCOMPARE(native32, {QFileInfo(QFINDTESTDATA("testdata/Library/testname-testversion-linux-32.jar")).absoluteFilePath()}); + QCOMPARE(native64, {QFileInfo(QFINDTESTDATA("testdata/Library") + "/testname-testversion-linux-64.jar").absoluteFilePath()}); QStringList failedFiles; - auto dls = test.getDownloads(Os_Linux, cache.get(), failedFiles, QFINDTESTDATA("testdata")); + auto dls = test.getDownloads(Os_Linux, cache.get(), failedFiles, QFINDTESTDATA("testdata/Library")); QCOMPARE(dls.size(), 0); - QCOMPARE(failedFiles, {QFileInfo(QFINDTESTDATA("testdata") + "/testname-testversion-linux-64.jar").absoluteFilePath()}); + QCOMPARE(failedFiles, {QFileInfo(QFINDTESTDATA("testdata/Library") + "/testname-testversion-linux-64.jar").absoluteFilePath()}); } } void test_onenine() { - auto test = readMojangJson(QFINDTESTDATA("testdata/lib-simple.json")); + auto test = readMojangJson(QFINDTESTDATA("testdata/Library/lib-simple.json")); { QStringList jar, native, native32, native64; test->getApplicableFiles(Os_OSX, jar, native, native32, native64, QString()); @@ -197,41 +197,41 @@ slots: test->setHint("local"); { QStringList jar, native, native32, native64; - test->getApplicableFiles(Os_OSX, jar, native, native32, native64, QFINDTESTDATA("testdata")); - QCOMPARE(jar, {QFileInfo(QFINDTESTDATA("testdata/codecwav-20101023.jar")).absoluteFilePath()}); + test->getApplicableFiles(Os_OSX, jar, native, native32, native64, QFINDTESTDATA("testdata/Library")); + QCOMPARE(jar, {QFileInfo(QFINDTESTDATA("testdata/Library/codecwav-20101023.jar")).absoluteFilePath()}); QCOMPARE(native, {}); QCOMPARE(native32, {}); QCOMPARE(native64, {}); } { QStringList failedFiles; - auto dls = test->getDownloads(Os_Linux, cache.get(), failedFiles, QFINDTESTDATA("testdata")); + auto dls = test->getDownloads(Os_Linux, cache.get(), failedFiles, QFINDTESTDATA("testdata/Library")); QCOMPARE(dls.size(), 0); QCOMPARE(failedFiles, {}); } } void test_onenine_local_override() { - auto test = readMojangJson(QFINDTESTDATA("testdata/lib-simple.json")); + auto test = readMojangJson(QFINDTESTDATA("testdata/Library/lib-simple.json")); test->setHint("local"); { QStringList jar, native, native32, native64; - test->getApplicableFiles(Os_OSX, jar, native, native32, native64, QFINDTESTDATA("testdata")); - QCOMPARE(jar, {QFileInfo(QFINDTESTDATA("testdata/codecwav-20101023.jar")).absoluteFilePath()}); + test->getApplicableFiles(Os_OSX, jar, native, native32, native64, QFINDTESTDATA("testdata/Library")); + QCOMPARE(jar, {QFileInfo(QFINDTESTDATA("testdata/Library/codecwav-20101023.jar")).absoluteFilePath()}); QCOMPARE(native, {}); QCOMPARE(native32, {}); QCOMPARE(native64, {}); } { QStringList failedFiles; - auto dls = test->getDownloads(Os_Linux, cache.get(), failedFiles, QFINDTESTDATA("testdata")); + auto dls = test->getDownloads(Os_Linux, cache.get(), failedFiles, QFINDTESTDATA("testdata/Library")); QCOMPARE(dls.size(), 0); QCOMPARE(failedFiles, {}); } } void test_onenine_native() { - auto test = readMojangJson(QFINDTESTDATA("testdata/lib-native.json")); + auto test = readMojangJson(QFINDTESTDATA("testdata/Library/lib-native.json")); QStringList jar, native, native32, native64; test->getApplicableFiles(Os_OSX, jar, native, native32, native64, QString()); QCOMPARE(jar, QStringList()); @@ -246,7 +246,7 @@ slots: } void test_onenine_native_arch() { - auto test = readMojangJson(QFINDTESTDATA("testdata/lib-native-arch.json")); + auto test = readMojangJson(QFINDTESTDATA("testdata/Library/lib-native-arch.json")); QStringList jar, native, native32, native64; test->getApplicableFiles(Os_Windows, jar, native, native32, native64, QString()); QCOMPARE(jar, {}); diff --git a/launcher/minecraft/MojangVersionFormat_test.cpp b/tests/MojangVersionFormat_test.cpp similarity index 85% rename from launcher/minecraft/MojangVersionFormat_test.cpp rename to tests/MojangVersionFormat_test.cpp index 71df784b..219fbfa2 100644 --- a/launcher/minecraft/MojangVersionFormat_test.cpp +++ b/tests/MojangVersionFormat_test.cpp @@ -1,7 +1,7 @@ #include #include -#include "minecraft/MojangVersionFormat.h" +#include class MojangVersionFormatTest : public QObject { @@ -29,7 +29,7 @@ private slots: void test_Through_Simple() { - QJsonDocument doc = readJson(QFINDTESTDATA("testdata/1.9-simple.json")); + QJsonDocument doc = readJson(QFINDTESTDATA("testdata/MojangVersionFormat/1.9-simple.json")); auto vfile = MojangVersionFormat::versionFileFromJson(doc, "1.9-simple.json"); auto doc2 = MojangVersionFormat::versionFileToJson(vfile); writeJson("1.9-simple-passthorugh.json", doc2); @@ -39,7 +39,7 @@ slots: void test_Through() { - QJsonDocument doc = readJson(QFINDTESTDATA("testdata/1.9.json")); + QJsonDocument doc = readJson(QFINDTESTDATA("testdata/MojangVersionFormat/1.9.json")); auto vfile = MojangVersionFormat::versionFileFromJson(doc, "1.9.json"); auto doc2 = MojangVersionFormat::versionFileToJson(vfile); writeJson("1.9-passthorugh.json", doc2); diff --git a/launcher/mojang/PackageManifest_test.cpp b/tests/PackageManifest_test.cpp similarity index 97% rename from launcher/mojang/PackageManifest_test.cpp rename to tests/PackageManifest_test.cpp index e8da4266..e38abf80 100644 --- a/launcher/mojang/PackageManifest_test.cpp +++ b/tests/PackageManifest_test.cpp @@ -1,7 +1,7 @@ #include #include -#include "mojang/PackageManifest.h" +#include using namespace mojang_files; @@ -82,14 +82,14 @@ void PackageManifestTest::test_parse() } void PackageManifestTest::test_parse_file() { - auto path = QFINDTESTDATA("testdata/1.8.0_202-x64.json"); + auto path = QFINDTESTDATA("testdata/PackageManifest/1.8.0_202-x64.json"); auto manifest = Package::fromManifestFile(path); QVERIFY(manifest.valid == true); } void PackageManifestTest::test_inspect() { - auto path = QFINDTESTDATA("testdata/inspect_win/"); + auto path = QFINDTESTDATA("testdata/PackageManifest/inspect_win/"); auto manifest = Package::fromInspectedFolder(path); QVERIFY(manifest.valid == true); QVERIFY(manifest.files.size() == 2); @@ -112,7 +112,7 @@ void PackageManifestTest::test_inspect() { #ifndef Q_OS_WIN32 void PackageManifestTest::test_inspect_symlinks() { - auto path = QFINDTESTDATA("testdata/inspect/"); + auto path = QFINDTESTDATA("testdata/PackageManifest/inspect/"); auto manifest = Package::fromInspectedFolder(path); QVERIFY(manifest.valid == true); QVERIFY(manifest.files.size() == 1); diff --git a/launcher/modplatform/packwiz/Packwiz_test.cpp b/tests/Packwiz_test.cpp similarity index 94% rename from launcher/modplatform/packwiz/Packwiz_test.cpp rename to tests/Packwiz_test.cpp index aa0c35df..098e8f89 100644 --- a/launcher/modplatform/packwiz/Packwiz_test.cpp +++ b/tests/Packwiz_test.cpp @@ -20,7 +20,7 @@ #include #include -#include "Packwiz.h" +#include class PackwizTest : public QObject { Q_OBJECT @@ -29,7 +29,7 @@ class PackwizTest : public QObject { // Files taken from https://github.com/packwiz/packwiz-example-pack void loadFromFile_Modrinth() { - QString source = QFINDTESTDATA("testdata"); + QString source = QFINDTESTDATA("testdata/Packwiz"); QDir index_dir(source); QString slug_mod("borderless-mining"); @@ -55,7 +55,7 @@ class PackwizTest : public QObject { void loadFromFile_Curseforge() { - QString source = QFINDTESTDATA("testdata"); + QString source = QFINDTESTDATA("testdata/Packwiz"); QDir index_dir(source); QString name_mod("screenshot-to-clipboard-fabric.pw.toml"); diff --git a/launcher/minecraft/ParseUtils_test.cpp b/tests/ParseUtils_test.cpp similarity index 96% rename from launcher/minecraft/ParseUtils_test.cpp rename to tests/ParseUtils_test.cpp index 7721a46d..02208fdf 100644 --- a/launcher/minecraft/ParseUtils_test.cpp +++ b/tests/ParseUtils_test.cpp @@ -1,6 +1,6 @@ #include -#include "minecraft/ParseUtils.h" +#include class ParseUtilsTest : public QObject { diff --git a/launcher/minecraft/mod/ResourceFolderModel_test.cpp b/tests/ResourceFolderModel_test.cpp similarity index 92% rename from launcher/minecraft/mod/ResourceFolderModel_test.cpp rename to tests/ResourceFolderModel_test.cpp index aa78e502..3f0f3ba1 100644 --- a/launcher/minecraft/mod/ResourceFolderModel_test.cpp +++ b/tests/ResourceFolderModel_test.cpp @@ -37,10 +37,10 @@ #include #include -#include "FileSystem.h" +#include -#include "minecraft/mod/ModFolderModel.h" -#include "minecraft/mod/ResourceFolderModel.h" +#include +#include #define EXEC_UPDATE_TASK(EXEC, VERIFY) \ QEventLoop loop; \ @@ -70,7 +70,7 @@ slots: void test_1178() { // source - QString source = QFINDTESTDATA("testdata/test_folder"); + QString source = QFINDTESTDATA("testdata/ResourceFolderModel/test_folder"); // sanity check QVERIFY(!source.endsWith('/')); @@ -135,7 +135,7 @@ slots: void test_addFromWatch() { - QString source = QFINDTESTDATA("testdata"); + QString source = QFINDTESTDATA("testdata/ResourceFolderModel"); ModFolderModel model(source); @@ -154,8 +154,8 @@ slots: void test_removeResource() { - QString folder_resource = QFINDTESTDATA("testdata/test_folder"); - QString file_mod = QFINDTESTDATA("testdata/supercoolmod.jar"); + QString folder_resource = QFINDTESTDATA("testdata/ResourceFolderModel/test_folder"); + QString file_mod = QFINDTESTDATA("testdata/ResourceFolderModel/supercoolmod.jar"); QTemporaryDir tmp; @@ -206,8 +206,8 @@ slots: void test_enable_disable() { - QString folder_resource = QFINDTESTDATA("testdata/test_folder"); - QString file_mod = QFINDTESTDATA("testdata/supercoolmod.jar"); + QString folder_resource = QFINDTESTDATA("testdata/ResourceFolderModel/test_folder"); + QString file_mod = QFINDTESTDATA("testdata/ResourceFolderModel/supercoolmod.jar"); QTemporaryDir tmp; ResourceFolderModel model(tmp.path()); diff --git a/launcher/minecraft/mod/ResourcePackParse_test.cpp b/tests/ResourcePackParse_test.cpp similarity index 86% rename from launcher/minecraft/mod/ResourcePackParse_test.cpp rename to tests/ResourcePackParse_test.cpp index a49582d6..568c3b63 100644 --- a/launcher/minecraft/mod/ResourcePackParse_test.cpp +++ b/tests/ResourcePackParse_test.cpp @@ -19,10 +19,10 @@ #include #include -#include "FileSystem.h" +#include -#include "ResourcePack.h" -#include "tasks/LocalResourcePackParseTask.h" +#include +#include class ResourcePackParseTest : public QObject { Q_OBJECT @@ -30,7 +30,7 @@ class ResourcePackParseTest : public QObject { private slots: void test_parseZIP() { - QString source = QFINDTESTDATA("testdata"); + QString source = QFINDTESTDATA("testdata/ResourcePackParse"); QString zip_rp = FS::PathCombine(source, "test_resource_pack_idk.zip"); ResourcePack pack { QFileInfo(zip_rp) }; @@ -43,7 +43,7 @@ class ResourcePackParseTest : public QObject { void test_parseFolder() { - QString source = QFINDTESTDATA("testdata"); + QString source = QFINDTESTDATA("testdata/ResourcePackParse"); QString folder_rp = FS::PathCombine(source, "test_folder"); ResourcePack pack { QFileInfo(folder_rp) }; @@ -56,7 +56,7 @@ class ResourcePackParseTest : public QObject { void test_parseFolder2() { - QString source = QFINDTESTDATA("testdata"); + QString source = QFINDTESTDATA("testdata/ResourcePackParse"); QString folder_rp = FS::PathCombine(source, "another_test_folder"); ResourcePack pack { QFileInfo(folder_rp) }; diff --git a/launcher/tasks/Task_test.cpp b/tests/Task_test.cpp similarity index 97% rename from launcher/tasks/Task_test.cpp rename to tests/Task_test.cpp index b56ee8a6..80bba02f 100644 --- a/launcher/tasks/Task_test.cpp +++ b/tests/Task_test.cpp @@ -1,9 +1,9 @@ #include -#include "ConcurrentTask.h" -#include "MultipleOptionsTask.h" -#include "SequentialTask.h" -#include "Task.h" +#include +#include +#include +#include /* Does nothing. Only used for testing. */ class BasicTask : public Task { diff --git a/launcher/Version_test.cpp b/tests/Version_test.cpp similarity index 99% rename from launcher/Version_test.cpp rename to tests/Version_test.cpp index b2d657a6..734528b7 100644 --- a/launcher/Version_test.cpp +++ b/tests/Version_test.cpp @@ -15,7 +15,7 @@ #include -#include "TestUtil.h" +#include #include class ModUtilsTest : public QObject diff --git a/launcher/testdata/FileSystem-test_createShortcut-unix b/tests/testdata/FileSystem/FileSystem-test_createShortcut-unix similarity index 100% rename from launcher/testdata/FileSystem-test_createShortcut-unix rename to tests/testdata/FileSystem/FileSystem-test_createShortcut-unix diff --git a/launcher/minecraft/mod/testdata/test_folder/assets/minecraft/textures/blah.txt b/tests/testdata/FileSystem/test_folder/assets/minecraft/textures/blah.txt similarity index 100% rename from launcher/minecraft/mod/testdata/test_folder/assets/minecraft/textures/blah.txt rename to tests/testdata/FileSystem/test_folder/assets/minecraft/textures/blah.txt diff --git a/launcher/minecraft/mod/testdata/test_folder/pack.mcmeta b/tests/testdata/FileSystem/test_folder/pack.mcmeta similarity index 100% rename from launcher/minecraft/mod/testdata/test_folder/pack.mcmeta rename to tests/testdata/FileSystem/test_folder/pack.mcmeta diff --git a/launcher/minecraft/mod/testdata/test_folder/pack.nfo b/tests/testdata/FileSystem/test_folder/pack.nfo similarity index 100% rename from launcher/minecraft/mod/testdata/test_folder/pack.nfo rename to tests/testdata/FileSystem/test_folder/pack.nfo diff --git a/tests/testdata/Library b/tests/testdata/Library new file mode 120000 index 00000000..0e7a2286 --- /dev/null +++ b/tests/testdata/Library @@ -0,0 +1 @@ +MojangVersionFormat/ \ No newline at end of file diff --git a/launcher/minecraft/testdata/1.9-simple.json b/tests/testdata/MojangVersionFormat/1.9-simple.json similarity index 100% rename from launcher/minecraft/testdata/1.9-simple.json rename to tests/testdata/MojangVersionFormat/1.9-simple.json diff --git a/launcher/minecraft/testdata/1.9.json b/tests/testdata/MojangVersionFormat/1.9.json similarity index 100% rename from launcher/minecraft/testdata/1.9.json rename to tests/testdata/MojangVersionFormat/1.9.json diff --git a/launcher/minecraft/testdata/codecwav-20101023.jar b/tests/testdata/MojangVersionFormat/codecwav-20101023.jar similarity index 100% rename from launcher/minecraft/testdata/codecwav-20101023.jar rename to tests/testdata/MojangVersionFormat/codecwav-20101023.jar diff --git a/launcher/minecraft/testdata/lib-native-arch.json b/tests/testdata/MojangVersionFormat/lib-native-arch.json similarity index 100% rename from launcher/minecraft/testdata/lib-native-arch.json rename to tests/testdata/MojangVersionFormat/lib-native-arch.json diff --git a/launcher/minecraft/testdata/lib-native.json b/tests/testdata/MojangVersionFormat/lib-native.json similarity index 100% rename from launcher/minecraft/testdata/lib-native.json rename to tests/testdata/MojangVersionFormat/lib-native.json diff --git a/launcher/minecraft/testdata/lib-simple.json b/tests/testdata/MojangVersionFormat/lib-simple.json similarity index 100% rename from launcher/minecraft/testdata/lib-simple.json rename to tests/testdata/MojangVersionFormat/lib-simple.json diff --git a/launcher/minecraft/testdata/testname-testversion-linux-32.jar b/tests/testdata/MojangVersionFormat/testname-testversion-linux-32.jar similarity index 100% rename from launcher/minecraft/testdata/testname-testversion-linux-32.jar rename to tests/testdata/MojangVersionFormat/testname-testversion-linux-32.jar diff --git a/launcher/mojang/testdata/1.8.0_202-x64.json b/tests/testdata/PackageManifest/1.8.0_202-x64.json similarity index 100% rename from launcher/mojang/testdata/1.8.0_202-x64.json rename to tests/testdata/PackageManifest/1.8.0_202-x64.json diff --git a/launcher/mojang/testdata/inspect/a/b.txt b/tests/testdata/PackageManifest/inspect/a/b.txt similarity index 100% rename from launcher/mojang/testdata/inspect/a/b.txt rename to tests/testdata/PackageManifest/inspect/a/b.txt diff --git a/launcher/mojang/testdata/inspect/a/b/b.txt b/tests/testdata/PackageManifest/inspect/a/b/b.txt similarity index 100% rename from launcher/mojang/testdata/inspect/a/b/b.txt rename to tests/testdata/PackageManifest/inspect/a/b/b.txt diff --git a/launcher/mojang/testdata/inspect_win/a/b.txt b/tests/testdata/PackageManifest/inspect_win/a/b.txt similarity index 100% rename from launcher/mojang/testdata/inspect_win/a/b.txt rename to tests/testdata/PackageManifest/inspect_win/a/b.txt diff --git a/launcher/mojang/testdata/inspect_win/a/b/b.txt b/tests/testdata/PackageManifest/inspect_win/a/b/b.txt similarity index 100% rename from launcher/mojang/testdata/inspect_win/a/b/b.txt rename to tests/testdata/PackageManifest/inspect_win/a/b/b.txt diff --git a/launcher/modplatform/packwiz/testdata/borderless-mining.pw.toml b/tests/testdata/Packwiz/borderless-mining.pw.toml similarity index 100% rename from launcher/modplatform/packwiz/testdata/borderless-mining.pw.toml rename to tests/testdata/Packwiz/borderless-mining.pw.toml diff --git a/launcher/modplatform/packwiz/testdata/screenshot-to-clipboard-fabric.pw.toml b/tests/testdata/Packwiz/screenshot-to-clipboard-fabric.pw.toml similarity index 100% rename from launcher/modplatform/packwiz/testdata/screenshot-to-clipboard-fabric.pw.toml rename to tests/testdata/Packwiz/screenshot-to-clipboard-fabric.pw.toml diff --git a/tests/testdata/ResourceFolderModel b/tests/testdata/ResourceFolderModel new file mode 120000 index 00000000..c653d859 --- /dev/null +++ b/tests/testdata/ResourceFolderModel @@ -0,0 +1 @@ +ResourcePackParse \ No newline at end of file diff --git a/launcher/minecraft/mod/testdata/another_test_folder/pack.mcmeta b/tests/testdata/ResourcePackParse/another_test_folder/pack.mcmeta similarity index 100% rename from launcher/minecraft/mod/testdata/another_test_folder/pack.mcmeta rename to tests/testdata/ResourcePackParse/another_test_folder/pack.mcmeta diff --git a/launcher/minecraft/mod/testdata/supercoolmod.jar b/tests/testdata/ResourcePackParse/supercoolmod.jar similarity index 100% rename from launcher/minecraft/mod/testdata/supercoolmod.jar rename to tests/testdata/ResourcePackParse/supercoolmod.jar diff --git a/launcher/testdata/test_folder/assets/minecraft/textures/blah.txt b/tests/testdata/ResourcePackParse/test_folder/assets/minecraft/textures/blah.txt similarity index 100% rename from launcher/testdata/test_folder/assets/minecraft/textures/blah.txt rename to tests/testdata/ResourcePackParse/test_folder/assets/minecraft/textures/blah.txt diff --git a/launcher/testdata/test_folder/pack.mcmeta b/tests/testdata/ResourcePackParse/test_folder/pack.mcmeta similarity index 100% rename from launcher/testdata/test_folder/pack.mcmeta rename to tests/testdata/ResourcePackParse/test_folder/pack.mcmeta diff --git a/launcher/testdata/test_folder/pack.nfo b/tests/testdata/ResourcePackParse/test_folder/pack.nfo similarity index 100% rename from launcher/testdata/test_folder/pack.nfo rename to tests/testdata/ResourcePackParse/test_folder/pack.nfo diff --git a/launcher/minecraft/mod/testdata/test_resource_pack_idk.zip b/tests/testdata/ResourcePackParse/test_resource_pack_idk.zip similarity index 100% rename from launcher/minecraft/mod/testdata/test_resource_pack_idk.zip rename to tests/testdata/ResourcePackParse/test_resource_pack_idk.zip