-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unit tests #362
base: master
Are you sure you want to change the base?
Unit tests #362
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,14 +3,48 @@ | |
#include "Testing/BsConsoleTestOutput.h" | ||
#include "Private/UnitTests/BsUtilityTestSuite.h" | ||
|
||
#include "BsApplication.h" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Generally I organize the non-plugin code in layers. 'Utility' layer is the lowest one, and it shouldn't be referencing anything from the higher layers (this includes Application or CoreApplication). Are these tests failing without the Application started up? Ideally we can run them without it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hm. well we could just change it to BsCoreApplication, which is the core layer, and therefore compatible with all other layers of testing for most part. I'll make the change and see if that works. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nope nvm, CoreApplication can't be initialized by itself for running the utility tests. stuff like gProfiler still gets called |
||
#include "BsEngineConfig.h" | ||
|
||
using namespace bs; | ||
|
||
|
||
START_UP_DESC testStartupDesc() | ||
{ | ||
START_UP_DESC desc; | ||
|
||
// Set up default plugins | ||
desc.renderAPI = BS_RENDER_API_MODULE; | ||
// desc.renderAPI = "NullRenderAPI" | ||
desc.renderer = BS_RENDERER_MODULE; | ||
// desc.renderer = "NullRenderer"; | ||
desc.audio = BS_AUDIO_MODULE; | ||
desc.physics = BS_PHYSICS_MODULE; | ||
|
||
desc.importers.push_back("bsfFreeImgImporter"); | ||
desc.importers.push_back("bsfFBXImporter"); | ||
desc.importers.push_back("bsfFontImporter"); | ||
desc.importers.push_back("bsfSL"); | ||
|
||
VideoMode mode; | ||
desc.primaryWindowDesc.videoMode = mode; | ||
desc.primaryWindowDesc.fullscreen = false; | ||
desc.primaryWindowDesc.title = "test"; | ||
return desc; | ||
} | ||
|
||
int main() | ||
{ | ||
|
||
auto desc = testStartupDesc(); | ||
bs::Application::startUp(desc); | ||
|
||
SPtr<TestSuite> tests = UtilityTestSuite::create<UtilityTestSuite>(); | ||
|
||
ConsoleTestOutput testOutput; | ||
tests->run(testOutput); | ||
|
||
bs::Application::shutDown(); | ||
|
||
return 0; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
//************************************ bs::framework - Copyright 2018 Marko Pintera **************************************// | ||
//*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********// | ||
#include "Testing/BsConsoleTestOutput.h" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd like to keep these non-unit tests elsewhere. Generally these things might require custom assets and might be bigger than one file as well, so it makes sense to me to dedicate a space for them. Even though this is a simple one I feel it fits into that category. Perhaps we can add a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This also applies to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. eh i prefer tests to be close to the code of interest. otherwise they can too quickly go out of date. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the issue with separate repos is that the most common example is a method signature changes, and then the author needs to remember to go to the separate repo, and update it there as well. Ideally the dev should just be compiling with build_tests=ON and so the tests are always compiling along with any signature changes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. anyone compiling the source code should be running the unit-tests on their platform as well to validate. And I don't find files ending with *_test.cpp to be confusing when intermixed with source code. Having FileSystem.cpp and FileSystem_test.cpp in the same folder is a lot more intuitive than in a separate repo. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense. Because you are starting up the application I assumed this was doing more than just a unit test. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah no, starting up the application was only necessary for starting some of the modules. some of the tests involved code that had to be initialized by the modules. At the very least Platform, MemStack, MessageHandler had to be startUp(). otherwise any tests using memstack will fail obviously. |
||
#include "BsRenderBeastTestSuite.h" | ||
|
||
#include "BsApplication.h" | ||
#include "BsEngineConfig.h" | ||
|
||
using namespace bs; | ||
|
||
|
||
START_UP_DESC testStartupDesc() | ||
{ | ||
START_UP_DESC desc; | ||
|
||
// Set up default plugins | ||
desc.renderAPI = BS_RENDER_API_MODULE; | ||
// desc.renderAPI = "NullRenderAPI" | ||
desc.renderer = BS_RENDERER_MODULE; | ||
// desc.renderer = "NullRenderer"; | ||
desc.audio = BS_AUDIO_MODULE; | ||
desc.physics = BS_PHYSICS_MODULE; | ||
|
||
desc.importers.push_back("bsfFreeImgImporter"); | ||
desc.importers.push_back("bsfFBXImporter"); | ||
desc.importers.push_back("bsfFontImporter"); | ||
desc.importers.push_back("bsfSL"); | ||
|
||
VideoMode mode; | ||
desc.primaryWindowDesc.videoMode = mode; | ||
desc.primaryWindowDesc.fullscreen = false; | ||
desc.primaryWindowDesc.title = "test"; | ||
return desc; | ||
} | ||
|
||
int main() | ||
{ | ||
|
||
auto desc = testStartupDesc(); | ||
bs::Application::startUp(desc); | ||
|
||
SPtr<TestSuite> tests = RenderBeastTestSuite::create<RenderBeastTestSuite>(); | ||
|
||
ConsoleTestOutput testOutput; | ||
tests->run(testOutput); | ||
|
||
bs::Application::shutDown(); | ||
|
||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//************************************ bs::framework - Copyright 2018 Marko Pintera **************************************// | ||
//*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********// | ||
#pragma once | ||
|
||
#include "Testing/BsTestSuite.h" | ||
|
||
namespace bs | ||
{ | ||
|
||
/** Runs unit tests for systems specific to the RenderBeast plugin. */ | ||
class RenderBeastTestSuite : public TestSuite | ||
{ | ||
public: | ||
RenderBeastTestSuite(); | ||
|
||
private: | ||
void testTextureRowAllocator(); | ||
}; | ||
|
||
} // namespace bs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the purpose of this macro vs. using
add_test
? Also, I'm seeing references toDebug
andRelease
- does it work on other configs?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i updated with commit for explanation. Esentially I was getting "found .so library" errors until I updated the tests. plus it's just useful to have add_test wrapper for future in case there's other common properties.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I honestly don't know if it works for other configs. But it at least works for my needs at the moment.