Adds support for debugger.
This commit is contained in:
@@ -2,14 +2,17 @@
|
||||
#define POKEMONSCRIPTTESTER_TESTRUNNER_HPP
|
||||
|
||||
#include <PkmnLib/ScriptResolving/AngelScript/AngelScriptMetadata.hpp>
|
||||
#include <PkmnLib/ScriptResolving/AngelScript/ContextPool.hpp>
|
||||
#include "../../extern/AngelscriptDebugger/src/AngelscriptDebugger.hpp"
|
||||
#include "../../extern/termcolor.hpp"
|
||||
#include "Test.hpp"
|
||||
|
||||
class TestRunner {
|
||||
AngelScriptResolver* _scriptResolver;
|
||||
ArbUt::Dictionary<std::string, std::unique_ptr<Test>> _tests;
|
||||
|
||||
public:
|
||||
TestRunner(AngelScriptResolver* scriptResolver) {
|
||||
TestRunner(AngelScriptResolver* scriptResolver) : _scriptResolver(scriptResolver) {
|
||||
const auto* module = scriptResolver->GetMainModule();
|
||||
auto builder = scriptResolver->GetBuilder();
|
||||
for (u32 i = 0; i < module->GetFunctionCount(); ++i) {
|
||||
@@ -30,8 +33,20 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
i32 RunAll(asIScriptEngine* engine) {
|
||||
auto ctx = engine->CreateContext();
|
||||
i32 RunAll(bool waitForDebugger) {
|
||||
auto ctx = _scriptResolver->GetContextPool()->RequestContext();
|
||||
ctx->SetUserData(_scriptResolver->GetUserdata());
|
||||
auto debugger = AngelscriptDebugger();
|
||||
debugger.Run(8684);
|
||||
debugger.RegisterContext(ctx);
|
||||
if (waitForDebugger) {
|
||||
std::cout << "Waiting for debugger" << std::endl;
|
||||
while (!debugger.HasDebuggerAttached()) {
|
||||
continue;
|
||||
}
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
for (auto& test : _tests) {
|
||||
test.second->Run(ctx);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user