Skip to content

Commit 771dd6f

Browse files
committed
NOISSUE reorganize unit tests to be placed next to the code they test. Nuke more dead tests.
1 parent e8ba5da commit 771dd6f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+267
-305
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
*.pem -crlf
2+
**/testdata/** -text -diff

CMakeLists.txt

-8
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
2020
######## Set module path ########
2121
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/")
2222

23-
# Output all executables and shared libs in the main build folder, not in subfolders.
24-
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
25-
if(UNIX)
26-
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
27-
endif()
28-
2923
set(CMAKE_JAVA_TARGET_OUTPUT_DIR ${PROJECT_BINARY_DIR}/jars)
3024

3125
######## Set compiler flags ########
@@ -103,8 +97,6 @@ add_subdirectory(libraries/iconfix) # fork of Qt's QIcon loader
10397

10498
############################### Built Artifacts ###############################
10599

106-
add_subdirectory(tests)
107-
108100
add_subdirectory(api/logic)
109101
add_subdirectory(api/gui)
110102

api/gui/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
project(MultiMC_logic)
1+
project(MultiMC_gui LANGUAGES CXX)
22

33
set(GUI_SOURCES
44
DesktopServices.h

api/logic/CMakeLists.txt

+170-50
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
project(MultiMC_logic)
22

3-
set(LOGIC_SOURCES
3+
include (UnitTest)
4+
5+
set(CORE_SOURCES
46
# LOGIC - Base classes and infrastructure
57
BaseInstaller.h
68
BaseInstaller.cpp
@@ -42,12 +44,6 @@ set(LOGIC_SOURCES
4244
# a smart pointer wrapper intended for safer use with Qt signal/slot mechanisms
4345
QObjectPtr.h
4446

45-
# Path matchers
46-
pathmatcher/FSTreeMatcher.h
47-
pathmatcher/IPathMatcher.h
48-
pathmatcher/MultiMatcher.h
49-
pathmatcher/RegexpMatcher.h
50-
5147
# Compression support
5248
GZip.h
5349
GZip.cpp
@@ -60,6 +56,31 @@ set(LOGIC_SOURCES
6056
Version.h
6157
Version.cpp
6258

59+
# A Recursive file system watcher
60+
RecursiveFileSystemWatcher.h
61+
RecursiveFileSystemWatcher.cpp
62+
)
63+
64+
add_unit_test(FileSystem
65+
SOURCES FileSystem_test.cpp
66+
LIBS MultiMC_logic
67+
DATA testdata
68+
)
69+
70+
add_unit_test(GZip
71+
SOURCES GZip_test.cpp
72+
LIBS MultiMC_logic
73+
)
74+
75+
set(PATHMATCHER_SOURCES
76+
# Path matchers
77+
pathmatcher/FSTreeMatcher.h
78+
pathmatcher/IPathMatcher.h
79+
pathmatcher/MultiMatcher.h
80+
pathmatcher/RegexpMatcher.h
81+
)
82+
83+
set(NET_SOURCES
6384
# network stuffs
6485
net/NetAction.h
6586
net/MD5EtagDownload.h
@@ -76,24 +97,10 @@ set(LOGIC_SOURCES
7697
net/PasteUpload.cpp
7798
net/URLConstants.h
7899
net/URLConstants.cpp
100+
)
79101

80-
# Yggdrasil login stuff
81-
minecraft/auth/AuthSession.h
82-
minecraft/auth/AuthSession.cpp
83-
minecraft/auth/MojangAccountList.h
84-
minecraft/auth/MojangAccountList.cpp
85-
minecraft/auth/MojangAccount.h
86-
minecraft/auth/MojangAccount.cpp
87-
minecraft/auth/YggdrasilTask.h
88-
minecraft/auth/YggdrasilTask.cpp
89-
minecraft/auth/flows/AuthenticateTask.h
90-
minecraft/auth/flows/AuthenticateTask.cpp
91-
minecraft/auth/flows/RefreshTask.cpp
92-
minecraft/auth/flows/RefreshTask.cpp
93-
minecraft/auth/flows/ValidateTask.h
94-
minecraft/auth/flows/ValidateTask.cpp
95-
96-
# Game launch logic
102+
# Game launch logic
103+
set(LAUNCH_SOURCES
97104
launch/steps/PostLaunchCommand.cpp
98105
launch/steps/PostLaunchCommand.h
99106
launch/steps/PreLaunchCommand.cpp
@@ -110,30 +117,70 @@ set(LOGIC_SOURCES
110117
launch/LoggedProcess.h
111118
launch/MessageLevel.cpp
112119
launch/MessageLevel.h
120+
)
113121

114-
# Update system
122+
# Old update system
123+
set(UPDATE_SOURCES
115124
updater/GoUpdate.h
116125
updater/GoUpdate.cpp
117126
updater/UpdateChecker.h
118127
updater/UpdateChecker.cpp
119128
updater/DownloadTask.h
120129
updater/DownloadTask.cpp
130+
)
131+
132+
add_unit_test(UpdateChecker
133+
SOURCES updater/UpdateChecker_test.cpp
134+
LIBS MultiMC_logic
135+
DATA updater/testdata
136+
)
137+
138+
add_unit_test(DownloadTask
139+
SOURCES updater/DownloadTask_test.cpp
140+
LIBS MultiMC_logic
141+
DATA updater/testdata
142+
)
121143

144+
# Rarely used notifications
145+
set(NOTIFICATIONS_SOURCES
122146
# Notifications - short warning messages
123147
notifications/NotificationChecker.h
124148
notifications/NotificationChecker.cpp
149+
)
125150

151+
# Backend for the news bar... there's usually no news.
152+
set(NEWS_SOURCES
126153
# News System
127154
news/NewsChecker.h
128155
news/NewsChecker.cpp
129156
news/NewsEntry.h
130157
news/NewsEntry.cpp
158+
)
131159

160+
# Minecraft services status checker
161+
set(STATUS_SOURCES
132162
# Status system
133163
status/StatusChecker.h
134164
status/StatusChecker.cpp
165+
)
135166

167+
# Support for Minecraft instances and launch
168+
set(MINECRAFT_SOURCES
136169
# Minecraft support
170+
minecraft/auth/AuthSession.h
171+
minecraft/auth/AuthSession.cpp
172+
minecraft/auth/MojangAccountList.h
173+
minecraft/auth/MojangAccountList.cpp
174+
minecraft/auth/MojangAccount.h
175+
minecraft/auth/MojangAccount.cpp
176+
minecraft/auth/YggdrasilTask.h
177+
minecraft/auth/YggdrasilTask.cpp
178+
minecraft/auth/flows/AuthenticateTask.h
179+
minecraft/auth/flows/AuthenticateTask.cpp
180+
minecraft/auth/flows/RefreshTask.cpp
181+
minecraft/auth/flows/RefreshTask.cpp
182+
minecraft/auth/flows/ValidateTask.h
183+
minecraft/auth/flows/ValidateTask.cpp
137184
minecraft/onesix/OneSixUpdate.h
138185
minecraft/onesix/OneSixUpdate.cpp
139186
minecraft/onesix/OneSixInstance.h
@@ -201,25 +248,77 @@ set(LOGIC_SOURCES
201248
minecraft/ftb/FTBPlugin.h
202249
minecraft/ftb/FTBPlugin.cpp
203250

204-
# A Recursive file system watcher
205-
RecursiveFileSystemWatcher.h
206-
RecursiveFileSystemWatcher.cpp
251+
# Assets
252+
minecraft/AssetsUtils.h
253+
minecraft/AssetsUtils.cpp
207254

208-
# the screenshots feature
255+
# Forge and all things forge related
256+
minecraft/forge/ForgeVersion.h
257+
minecraft/forge/ForgeVersion.cpp
258+
minecraft/forge/ForgeVersionList.h
259+
minecraft/forge/ForgeVersionList.cpp
260+
minecraft/forge/ForgeXzDownload.h
261+
minecraft/forge/ForgeXzDownload.cpp
262+
minecraft/forge/LegacyForge.h
263+
minecraft/forge/LegacyForge.cpp
264+
minecraft/forge/ForgeInstaller.h
265+
minecraft/forge/ForgeInstaller.cpp
266+
267+
# Liteloader and related things
268+
minecraft/liteloader/LiteLoaderInstaller.h
269+
minecraft/liteloader/LiteLoaderInstaller.cpp
270+
minecraft/liteloader/LiteLoaderVersionList.h
271+
minecraft/liteloader/LiteLoaderVersionList.cpp
272+
)
273+
274+
add_unit_test(GradleSpecifier
275+
SOURCES minecraft/GradleSpecifier_test.cpp
276+
LIBS MultiMC_logic
277+
)
278+
279+
add_unit_test(MojangVersionFormat
280+
SOURCES minecraft/MojangVersionFormat_test.cpp
281+
LIBS MultiMC_logic
282+
DATA minecraft/testdata
283+
)
284+
285+
add_unit_test(Library
286+
SOURCES minecraft/Library_test.cpp
287+
LIBS MultiMC_logic
288+
)
289+
290+
# FIXME: shares data with FileSystem test
291+
add_unit_test(ModList
292+
SOURCES minecraft/ModList_test.cpp
293+
DATA testdata
294+
LIBS MultiMC_logic
295+
)
296+
297+
add_unit_test(ParseUtils
298+
SOURCES minecraft/ParseUtils_test.cpp
299+
LIBS MultiMC_logic
300+
)
301+
302+
# the screenshots feature
303+
set(SCREENSHOTS_SOURCES
209304
screenshots/Screenshot.h
210305
screenshots/ImgurUpload.h
211306
screenshots/ImgurUpload.cpp
212307
screenshots/ImgurAlbumCreation.h
213308
screenshots/ImgurAlbumCreation.cpp
309+
)
214310

311+
set(TASKS_SOURCES
215312
# Tasks
216313
tasks/Task.h
217314
tasks/Task.cpp
218315
tasks/ThreadTask.h
219316
tasks/ThreadTask.cpp
220317
tasks/SequentialTask.h
221318
tasks/SequentialTask.cpp
319+
)
222320

321+
set(SETTINGS_SOURCES
223322
# Settings
224323
settings/INIFile.cpp
225324
settings/INIFile.h
@@ -233,7 +332,14 @@ set(LOGIC_SOURCES
233332
settings/Setting.h
234333
settings/SettingsObject.cpp
235334
settings/SettingsObject.h
335+
)
336+
337+
add_unit_test(INIFile
338+
SOURCES settings/INIFile_test.cpp
339+
LIBS MultiMC_logic
340+
)
236341

342+
set(JAVA_SOURCES
237343
# Java related code
238344
java/launch/CheckJava.cpp
239345
java/launch/CheckJava.h
@@ -249,33 +355,20 @@ set(LOGIC_SOURCES
249355
java/JavaUtils.cpp
250356
java/JavaVersion.h
251357
java/JavaVersion.cpp
358+
)
252359

253-
# Assets
254-
minecraft/AssetsUtils.h
255-
minecraft/AssetsUtils.cpp
256-
257-
# Forge and all things forge related
258-
minecraft/forge/ForgeVersion.h
259-
minecraft/forge/ForgeVersion.cpp
260-
minecraft/forge/ForgeVersionList.h
261-
minecraft/forge/ForgeVersionList.cpp
262-
minecraft/forge/ForgeXzDownload.h
263-
minecraft/forge/ForgeXzDownload.cpp
264-
minecraft/forge/LegacyForge.h
265-
minecraft/forge/LegacyForge.cpp
266-
minecraft/forge/ForgeInstaller.h
267-
minecraft/forge/ForgeInstaller.cpp
268-
269-
# Liteloader and related things
270-
minecraft/liteloader/LiteLoaderInstaller.h
271-
minecraft/liteloader/LiteLoaderInstaller.cpp
272-
minecraft/liteloader/LiteLoaderVersionList.h
273-
minecraft/liteloader/LiteLoaderVersionList.cpp
360+
add_unit_test(JavaVersion
361+
SOURCES java/JavaVersion_test.cpp
362+
LIBS MultiMC_logic
363+
)
274364

365+
set(TRANSLATIONS_SOURCES
275366
# Translations
276367
trans/TranslationDownloader.h
277368
trans/TranslationDownloader.cpp
369+
)
278370

371+
set(TOOLS_SOURCES
279372
# Tools
280373
tools/BaseExternalTool.cpp
281374
tools/BaseExternalTool.h
@@ -287,7 +380,9 @@ set(LOGIC_SOURCES
287380
tools/JVisualVM.h
288381
tools/MCEditTool.cpp
289382
tools/MCEditTool.h
383+
)
290384

385+
set(WONKO_SOURCES
291386
# Wonko
292387
wonko/tasks/BaseWonkoEntityRemoteLoadTask.cpp
293388
wonko/tasks/BaseWonkoEntityRemoteLoadTask.h
@@ -310,11 +405,36 @@ set(LOGIC_SOURCES
310405
wonko/WonkoReference.cpp
311406
wonko/WonkoReference.h
312407
)
408+
409+
add_unit_test(WonkoIndex
410+
SOURCES wonko/WonkoIndex_test.cpp
411+
LIBS MultiMC_logic
412+
)
413+
313414
################################ COMPILE ################################
314415

315416
# we need zlib
316417
find_package(ZLIB REQUIRED)
317418

419+
set(LOGIC_SOURCES
420+
${CORE_SOURCES}
421+
${PATHMATCHER_SOURCES}
422+
${NET_SOURCES}
423+
${LAUNCH_SOURCES}
424+
${UPDATE_SOURCES}
425+
${NOTIFICATIONS_SOURCES}
426+
${NEWS_SOURCES}
427+
${STATUS_SOURCES}
428+
${MINECRAFT_SOURCES}
429+
${SCREENSHOTS_SOURCES}
430+
${TASKS_SOURCES}
431+
${SETTINGS_SOURCES}
432+
${JAVA_SOURCES}
433+
${TRANSLATIONS_SOURCES}
434+
${TOOLS_SOURCES}
435+
${WONKO_SOURCES}
436+
)
437+
318438
add_library(MultiMC_logic SHARED ${LOGIC_SOURCES})
319439
set_target_properties(MultiMC_logic PROPERTIES CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN 1)
320440

0 commit comments

Comments
 (0)