mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-24 20:57:18 +01:00
Added a new skeleton unit test module with some notes.
This commit is contained in:
parent
77ca3e3290
commit
0cfa32c9aa
8
modules/unit_test/.gitignore
vendored
Normal file
8
modules/unit_test/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
.import
|
||||
*.d
|
||||
*.o
|
||||
*.meta
|
||||
*.obj
|
||||
*.pyc
|
||||
*.bc
|
||||
*.os
|
16
modules/unit_test/SCsub
Normal file
16
modules/unit_test/SCsub
Normal file
@ -0,0 +1,16 @@
|
||||
import os
|
||||
import version
|
||||
|
||||
Import('env')
|
||||
|
||||
module_env = env.Clone()
|
||||
|
||||
sources = [
|
||||
"register_types.cpp",
|
||||
"unit_test.cpp",
|
||||
"unit_test_db.cpp",
|
||||
"unit_test_runner.cpp",
|
||||
]
|
||||
|
||||
module_env.add_source_files(env.modules_sources, sources)
|
||||
|
19
modules/unit_test/config.py
Normal file
19
modules/unit_test/config.py
Normal file
@ -0,0 +1,19 @@
|
||||
|
||||
def can_build(env, platform):
|
||||
return True
|
||||
|
||||
|
||||
def configure(env):
|
||||
pass
|
||||
|
||||
|
||||
def get_doc_classes():
|
||||
return [
|
||||
"UnitTest",
|
||||
"UnitTestDB",
|
||||
"UnitTestRunner"
|
||||
]
|
||||
|
||||
def get_doc_path():
|
||||
return "doc_classes"
|
||||
|
31
modules/unit_test/register_types.cpp
Normal file
31
modules/unit_test/register_types.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
#include "register_types.h"
|
||||
|
||||
#include "core/config/engine.h"
|
||||
|
||||
#include "unit_test.h"
|
||||
#include "unit_test_db.h"
|
||||
#include "unit_test_runner.h"
|
||||
|
||||
static UnitTestDB *unit_test_manager = NULL;
|
||||
|
||||
void register_unit_test_types(ModuleRegistrationLevel p_level) {
|
||||
if (p_level == MODULE_REGISTRATION_LEVEL_SINGLETON) {
|
||||
unit_test_manager = memnew(UnitTestDB);
|
||||
ClassDB::register_class<UnitTestDB>();
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("UnitTestDB", UnitTestDB::get_singleton()));
|
||||
}
|
||||
|
||||
if (p_level == MODULE_REGISTRATION_LEVEL_SCENE) {
|
||||
ClassDB::register_class<UnitTest>();
|
||||
ClassDB::register_class<UnitTestRunner>();
|
||||
}
|
||||
}
|
||||
|
||||
void unregister_unit_test_types(ModuleRegistrationLevel p_level) {
|
||||
if (p_level == MODULE_REGISTRATION_LEVEL_SINGLETON) {
|
||||
if (unit_test_manager) {
|
||||
memdelete(unit_test_manager);
|
||||
}
|
||||
}
|
||||
}
|
9
modules/unit_test/register_types.h
Normal file
9
modules/unit_test/register_types.h
Normal file
@ -0,0 +1,9 @@
|
||||
#ifndef UNIT_TEST_REGISTER_TYPES_H
|
||||
#define UNIT_TEST_REGISTER_TYPES_H
|
||||
|
||||
#include "modules/register_module_types.h"
|
||||
|
||||
void register_unit_test_types(ModuleRegistrationLevel p_level);
|
||||
void unregister_unit_test_types(ModuleRegistrationLevel p_level);
|
||||
|
||||
#endif
|
10
modules/unit_test/unit_test.cpp
Normal file
10
modules/unit_test/unit_test.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
#include "unit_test.h"
|
||||
|
||||
UnitTest::UnitTest() {
|
||||
}
|
||||
|
||||
UnitTest::~UnitTest() {
|
||||
}
|
||||
|
||||
void UnitTest::_bind_methods() {
|
||||
}
|
37
modules/unit_test/unit_test.h
Normal file
37
modules/unit_test/unit_test.h
Normal file
@ -0,0 +1,37 @@
|
||||
#ifndef UNIT_TEST_H
|
||||
#define UNIT_TEST_H
|
||||
|
||||
#include "core/string/ustring.h"
|
||||
|
||||
#include "core/object/reference.h"
|
||||
|
||||
class QueryResult;
|
||||
|
||||
class UnitTest : public Reference {
|
||||
GDCLASS(UnitTest, Reference);
|
||||
|
||||
public:
|
||||
// ThreadPoolJob like api
|
||||
// asserts, prints, file check helpers, etc etc
|
||||
// bool process() -> return true when finished
|
||||
// bool _process()
|
||||
|
||||
// assert(a == "b", "Testing whenther a == b")
|
||||
// assert_equals(a, "b") ? -> could generate text automatically
|
||||
|
||||
// process type: process, physics process
|
||||
|
||||
//api to get results
|
||||
|
||||
//ajutomatically count tests, and some data (process time, physics and normal iteration nums)
|
||||
|
||||
//get_runner() -> returns runner
|
||||
|
||||
UnitTest();
|
||||
virtual ~UnitTest();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
};
|
||||
|
||||
#endif
|
20
modules/unit_test/unit_test_db.cpp
Normal file
20
modules/unit_test/unit_test_db.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
#include "unit_test_db.h"
|
||||
|
||||
UnitTestDB *UnitTestDB::_instance;
|
||||
|
||||
UnitTestDB *UnitTestDB::get_singleton() {
|
||||
return _instance;
|
||||
}
|
||||
|
||||
UnitTestDB::UnitTestDB() {
|
||||
_instance = this;
|
||||
}
|
||||
|
||||
UnitTestDB::~UnitTestDB() {
|
||||
_instance = NULL;
|
||||
}
|
||||
|
||||
void UnitTestDB::_bind_methods() {
|
||||
//ClassDB::bind_method(D_METHOD("", ""), &UnitTestDB::);
|
||||
}
|
32
modules/unit_test/unit_test_db.h
Normal file
32
modules/unit_test/unit_test_db.h
Normal file
@ -0,0 +1,32 @@
|
||||
#ifndef UNIT_TEST_MANAGER_H
|
||||
#define UNIT_TEST_MANAGER_H
|
||||
|
||||
#include "core/object/object.h"
|
||||
|
||||
class UnitTestDB : public Object {
|
||||
GDCLASS(UnitTestDB, Object);
|
||||
|
||||
public:
|
||||
//UnitTests api
|
||||
|
||||
//testing hint -> auto set (probably from main) if --test arg (should automatically set the scene root ast TestRunner eventually)
|
||||
//main -> --test_engine, or --load_engine_tests or --register_engine_tests ? -> register module tests
|
||||
//should probably have folders settings (also in project settings) -> only load them if necessary
|
||||
|
||||
//api for registering unit tests manually -> keep them separate
|
||||
|
||||
//api for getting all unit tests -> load everything from folders, append stuff manually registered -> return it
|
||||
|
||||
static UnitTestDB *get_singleton();
|
||||
|
||||
UnitTestDB();
|
||||
~UnitTestDB();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
static UnitTestDB *_instance;
|
||||
};
|
||||
|
||||
#endif
|
11
modules/unit_test/unit_test_runner.cpp
Normal file
11
modules/unit_test/unit_test_runner.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
#include "unit_test_runner.h"
|
||||
|
||||
UnitTestRunner::UnitTestRunner() {
|
||||
}
|
||||
|
||||
UnitTestRunner::~UnitTestRunner() {
|
||||
}
|
||||
|
||||
void UnitTestRunner::_bind_methods() {
|
||||
}
|
21
modules/unit_test/unit_test_runner.h
Normal file
21
modules/unit_test/unit_test_runner.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef UNIT_TEST_RUNNER_H
|
||||
#define UNIT_TEST_RUNNER_H
|
||||
|
||||
#include "scene/main/node.h"
|
||||
|
||||
class UnitTestRunner : public Node {
|
||||
GDCLASS(UnitTestRunner, Node);
|
||||
|
||||
public:
|
||||
// after enter tree gets all tests from db, call process on them when one returns true, go to the next one, exit after done
|
||||
|
||||
//should have api to easily get things that references can't get to easily but needed
|
||||
|
||||
UnitTestRunner();
|
||||
~UnitTestRunner();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user