WIP #846 Initial idea for unit tests for ModLibrary
hi, @lethal-guitar hope you're doing well!
I've noticed you closed this issue: #846. Why? I just came up with, I think, a cool idea to solve it!
I'm not there yet, but inching closer. Need to get some sleep soon (real late here) but if you approve of this idea, I'll absolutely go the extra mile!
Main points:
Add a fileshystem "stub" (handle?) for the filesystem functions used in ModLibrary::rescan
ideas: make a struct with function pointers, why?
- simpler than virtual (yes, it is)
- allows us to easily use std::filesystem::functions, no need for wrappers
- we don't use gmock anyways, so mocking isn't as easy
- simpler than virtual (yes, I really don't like 'em, that's why it's twice)
very veeeery much WIP, didn't test much apart from building the code and the unit test, didn't even have time to step through the debugger, it's really late, this commit message will change :)
- [ Y] I've compiled the code locally on my machine, and it builds without errors
- [ N] I've launched the game on my machine after making my changes, and I can successfully start a new game from the main menu (it's late don't have much time right now but wanted to just put this idea into writing)
@lethal-guitar what do you think? worth pursuing?
here's some logs from the current unit test (it's very basic of course):
andrew@pop-os:~/Projects/RigelEngine$ ./build/gcc-11-Debug/test/tests
2024-01-27 23:27:28.900 ( 0.000s) [ 8FE553C0] mod_library.cpp:127 INFO| { rescan
2024-01-27 23:27:28.900 ( 0.000s) [ 8FE553C0] mod_library.cpp:131 INFO| . Listing mod directories
2024-01-27 23:27:28.900 ( 0.000s) [ 8FE553C0] mod_library.cpp:157 INFO| . Found 0 mods
2024-01-27 23:27:28.900 ( 0.000s) [ 8FE553C0] mod_library.cpp:162 INFO| . No previous mod library, creating default selection
2024-01-27 23:27:28.900 ( 0.000s) [ 8FE553C0] mod_library.cpp:127 INFO| } 0.000 s: rescan
===============================================================================
test cases: 1 | 1 passed
assertions: - none -
Hi @bencsikandrei, good to see you back and thanks for the PR! I closed the issue but it's still relevant, you're very welcome to work on it if you're interested. Basically, I recently did a bit of cleanup and closed a whole bunch of issues that I don't realistically see myself getting around to anytime soon - I don't really have much time for the project at the moment. But reviewing and discussing should be doable.
I'll have a closer look at the proposal when I have time, and let you know what I think!