Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
42080a3c95
|
|||
|
7342cf8a56
|
|||
|
fbbfbfd3b3
|
|||
|
3b2e4f20ac
|
|||
|
35527f68bd
|
|||
|
3507ea4f6a
|
|||
|
7c2096853b
|
|||
|
af81c92165
|
|||
|
7043b12f34
|
17
.drone.yml
17
.drone.yml
@@ -13,16 +13,21 @@ steps:
|
||||
CC: /usr/bin/clang
|
||||
CXX: /usr/bin/clang++
|
||||
commands:
|
||||
- cmake -DCMAKE_BUILD_TYPE=Release . -B build-release
|
||||
- cmake -GNinja -DCMAKE_BUILD_TYPE=Release . -B build-release
|
||||
- cmake --build build-release --target all -- -j 4
|
||||
- name: build-release-windows
|
||||
image: deukhoofd/windowsbuilder
|
||||
environment:
|
||||
CHOST: x86_64-w64-mingw32
|
||||
AR: x86_64-w64-mingw32-ar
|
||||
AS: x86_64-w64-mingw32-as
|
||||
RANLIB: x86_64-w64-mingw32-ranlib
|
||||
CC: x86_64-w64-mingw32-gcc
|
||||
CXX: x86_64-w64-mingw32-g++
|
||||
STRIP: x86_64-w64-mingw32-strip
|
||||
RC: x86_64-w64-mingw32-windres
|
||||
commands:
|
||||
- update-alternatives --set i686-w64-mingw32-gcc /usr/bin/i686-w64-mingw32-gcc-posix
|
||||
- update-alternatives --set i686-w64-mingw32-g++ /usr/bin/i686-w64-mingw32-g++-posix
|
||||
- update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix
|
||||
- update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix
|
||||
- cmake -DCMAKE_BUILD_TYPE=Release . -B build-release-windows -DWINDOWS=ON -D CMAKE_C_COMPILER=/usr/bin/x86_64-w64-mingw32-gcc -D CMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++
|
||||
- cmake -GNinja -DCMAKE_BUILD_TYPE=Release . -B build-release-windows -DWINDOWS=ON -D CMAKE_C_COMPILER=/usr/bin/x86_64-w64-mingw32-gcc -D CMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++
|
||||
- cmake --build build-release-windows --target all -- -j 4
|
||||
- name: gitea_release
|
||||
image: plugins/gitea-release
|
||||
|
||||
@@ -19,9 +19,8 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
endif ()
|
||||
|
||||
|
||||
file(GLOB_RECURSE SRC_FILES src/*.cpp src/*.hpp)
|
||||
file(GLOB_RECURSE SRC_FILES src/*.cpp src/*.hpp extern/AngelscriptDebugger/src/*.cpp)
|
||||
add_executable(PokemonScriptTester ${SRC_FILES})
|
||||
target_precompile_headers(PokemonScriptTester PUBLIC src/Precompiled.hxx)
|
||||
add_definitions(-DLEVEL_U8)
|
||||
|
||||
SET(_LINKS -static pkmnLib)
|
||||
|
||||
@@ -40,10 +40,13 @@ function(include_pkmnlib)
|
||||
execute_process(COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/include)
|
||||
execute_process(COMMAND ln -s ${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/src/pkmnlib/src
|
||||
${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/include/PkmnLib)
|
||||
execute_process(COMMAND ln -s ${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/src/pkmnlib/extern
|
||||
${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/include/extern)
|
||||
execute_process(COMMAND cp -r ${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/src/pkmnlib/extern
|
||||
${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/include/PkmnLib/extern)
|
||||
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/include
|
||||
${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/src/pkmnlib/extern/AngelscriptDebuggerServer/extern/asio-1.18.2/include
|
||||
${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/bin/CreatureLib/include
|
||||
${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/bin/Angelscript/src/AngelscriptProj/angelscript/include
|
||||
${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/bin/CreatureLib/bin/Arbutils/include)
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
#ifndef POKEMONSCRIPTTESTER_PRECOMPILED_HXX
|
||||
#define POKEMONSCRIPTTESTER_PRECOMPILED_HXX
|
||||
|
||||
#include <PkmnLib/Precompiled.hxx>
|
||||
|
||||
#endif // POKEMONSCRIPTTESTER_PRECOMPILED_HXX
|
||||
@@ -12,7 +12,7 @@
|
||||
class BattleFunctions {
|
||||
static CreatureLib::Battling::CreatureParty* CreateSimpleParty(CScriptArray* species, u8 level) {
|
||||
auto* ctx = asGetActiveContext();
|
||||
TestEnvironment* env = static_cast<TestEnvironment*>(ctx->GetUserData());
|
||||
TestEnvironment* env = static_cast<TestEnvironment*>(ctx->GetUserData(684));
|
||||
|
||||
auto lib = Globals::Library.GetValue();
|
||||
auto p1 = new PkmnLib::Battling::PokemonParty(species->GetSize());
|
||||
@@ -31,10 +31,25 @@ class BattleFunctions {
|
||||
return p1;
|
||||
}
|
||||
|
||||
static CreatureLib::Battling::CreatureParty* CreateParty(CScriptArray* mons) {
|
||||
auto* ctx = asGetActiveContext();
|
||||
TestEnvironment* env = static_cast<TestEnvironment*>(ctx->GetUserData(684));
|
||||
|
||||
auto p1 = new PkmnLib::Battling::PokemonParty(mons->GetSize());
|
||||
for (u32 i = 0; i < mons->GetSize(); ++i) {
|
||||
auto s = *reinterpret_cast<PkmnLib::Battling::Pokemon**>(mons->At(i));
|
||||
p1->SwapInto(i, s);
|
||||
// Party becomes owner of mon, so take it from GC.
|
||||
env->TakeOwnershipOfGarbage(s);
|
||||
}
|
||||
env->AddGarbage(p1);
|
||||
return p1;
|
||||
}
|
||||
|
||||
static PkmnLib::Battling::Battle* CreateSimpleBattle(u32 seed, const ArbUt::StringView& species1,
|
||||
const ArbUt::StringView& species2, u8 level) {
|
||||
auto* ctx = asGetActiveContext();
|
||||
TestEnvironment* env = static_cast<TestEnvironment*>(ctx->GetUserData());
|
||||
TestEnvironment* env = static_cast<TestEnvironment*>(ctx->GetUserData(684));
|
||||
auto lib = Globals::Library.GetValue();
|
||||
|
||||
auto mon1 = PkmnLib::Battling::CreatePokemon(lib, species1, level)
|
||||
@@ -79,7 +94,7 @@ class BattleFunctions {
|
||||
static PkmnLib::Battling::Battle* CreateSimpleBattleFromParties(u32 seed, PkmnLib::Battling::PokemonParty* p1,
|
||||
PkmnLib::Battling::PokemonParty* p2) {
|
||||
auto* ctx = asGetActiveContext();
|
||||
TestEnvironment* env = static_cast<TestEnvironment*>(ctx->GetUserData());
|
||||
TestEnvironment* env = static_cast<TestEnvironment*>(ctx->GetUserData(684));
|
||||
auto lib = Globals::Library.GetValue();
|
||||
|
||||
auto battle = new PkmnLib::Battling::Battle(
|
||||
@@ -109,7 +124,7 @@ class BattleFunctions {
|
||||
return false;
|
||||
}
|
||||
auto* ctx = asGetActiveContext();
|
||||
TestEnvironment* env = static_cast<TestEnvironment*>(ctx->GetUserData());
|
||||
TestEnvironment* env = static_cast<TestEnvironment*>(ctx->GetUserData(684));
|
||||
|
||||
auto learnedMove =
|
||||
new PkmnLib::Battling::LearnedMove(move.value(), CreatureLib::Battling::AttackLearnMethod::Unknown);
|
||||
@@ -152,6 +167,8 @@ public:
|
||||
Ensure(
|
||||
engine->RegisterGlobalFunction("Party@ CreateSimpleParty(const array<constString>&in species, uint8 level)",
|
||||
asFUNCTION(CreateSimpleParty), asCALL_CDECL) >= 0);
|
||||
Ensure(engine->RegisterGlobalFunction("Party@ CreateParty(const array<Pokemon@>&in mons)",
|
||||
asFUNCTION(CreateParty), asCALL_CDECL) >= 0);
|
||||
Ensure(engine->RegisterGlobalFunction("Battle@ CreateSimpleBattle(uint seed, const constString&in species1, "
|
||||
"const constString&in species2, uint8 level)",
|
||||
asFUNCTION(CreateSimpleBattle), asCALL_CDECL) >= 0);
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
|
||||
class MiscMockFunctions {
|
||||
static CScriptHandle CreateMoveScript(const ArbUt::StringView& name) {
|
||||
auto script = Globals::Library.GetValue()->GetScriptResolver()->LoadScript(ScriptCategory::Attack, name);
|
||||
auto script = Globals::Library.GetValue()->GetScriptResolver()->LoadScript(nullptr, ScriptCategory::Attack, name);
|
||||
if (script != nullptr) {
|
||||
auto* ctx = asGetActiveContext();
|
||||
TestEnvironment* env = static_cast<TestEnvironment*>(ctx->GetUserData());
|
||||
TestEnvironment* env = static_cast<TestEnvironment*>(ctx->GetUserData(684));
|
||||
env->AddGarbage(script);
|
||||
}
|
||||
auto p = dynamic_cast<AngelScriptScript*>(script);
|
||||
@@ -21,11 +21,11 @@ class MiscMockFunctions {
|
||||
PkmnLib::Battling::Pokemon* user,
|
||||
PkmnLib::Battling::Pokemon* target) {
|
||||
auto* ctx = asGetActiveContext();
|
||||
TestEnvironment* env = static_cast<TestEnvironment*>(ctx->GetUserData());
|
||||
TestEnvironment* env = static_cast<TestEnvironment*>(ctx->GetUserData(684));
|
||||
|
||||
auto move = Globals::Library.GetValue()->GetMoveLibrary()->TryGet(moveName);
|
||||
if (!move.has_value()) {
|
||||
return {};
|
||||
THROW("Unknown move: " << moveName);
|
||||
}
|
||||
auto learnedMove =
|
||||
new PkmnLib::Battling::LearnedMove(move.value(), CreatureLib::Battling::AttackLearnMethod::Unknown);
|
||||
@@ -41,7 +41,7 @@ class MiscMockFunctions {
|
||||
PkmnLib::Battling::Pokemon* user,
|
||||
u8 targetSide, u8 target) {
|
||||
auto* ctx = asGetActiveContext();
|
||||
TestEnvironment* env = static_cast<TestEnvironment*>(ctx->GetUserData());
|
||||
TestEnvironment* env = static_cast<TestEnvironment*>(ctx->GetUserData(684));
|
||||
|
||||
auto move = Globals::Library.GetValue()->GetMoveLibrary()->TryGet(moveName);
|
||||
if (!move.has_value()) {
|
||||
|
||||
83
src/Tester/AngelScript/PokemonBuilder.hpp
Normal file
83
src/Tester/AngelScript/PokemonBuilder.hpp
Normal file
@@ -0,0 +1,83 @@
|
||||
#ifndef POKEMONSCRIPTTESTER_POKEMONBUILDER_HPP
|
||||
#define POKEMONSCRIPTTESTER_POKEMONBUILDER_HPP
|
||||
#include <PkmnLib/Battling/Pokemon/CreatePokemon.hpp>
|
||||
#include <angelscript.h>
|
||||
|
||||
class PokemonBuilderRegistration {
|
||||
public:
|
||||
static PkmnLib::Battling::CreatePokemon* CreatePokemonBuilder(const ArbUt::StringView& species, uint8_t level) {
|
||||
auto* ctx = asGetActiveContext();
|
||||
TestEnvironment* env = static_cast<TestEnvironment*>(ctx->GetUserData(684));
|
||||
auto lib = Globals::Library.GetValue();
|
||||
|
||||
auto builder = new PkmnLib::Battling::CreatePokemon(lib, species, level);
|
||||
env->AddGarbage(builder);
|
||||
return builder;
|
||||
}
|
||||
|
||||
static PkmnLib::Battling::CreatePokemon& WithGenderWrapper(PkmnLib::Battling::CreatePokemon* builder, i32 gender) {
|
||||
return builder->WithGender((CreatureLib::Library::Gender)gender);
|
||||
}
|
||||
|
||||
static PkmnLib::Battling::Pokemon* BuildWrapper(PkmnLib::Battling::CreatePokemon* builder, u32 seed) {
|
||||
auto rand = ArbUt::Random(seed);
|
||||
auto p = builder->Build(rand);
|
||||
auto* ctx = asGetActiveContext();
|
||||
TestEnvironment* env = static_cast<TestEnvironment*>(ctx->GetUserData(684));
|
||||
env->AddGarbage(p);
|
||||
return p;
|
||||
}
|
||||
|
||||
static void Register(AngelScriptResolver* resolver) {
|
||||
auto engine = resolver->GetEngine();
|
||||
Ensure(engine->RegisterObjectType("PokemonBuilder", 0, asOBJ_REF | asOBJ_NOCOUNT) >= 0);
|
||||
Ensure(engine->RegisterGlobalFunction(
|
||||
"PokemonBuilder@ CreatePokemonBuilder(const constString&in species, uint8 level)",
|
||||
asFUNCTION(CreatePokemonBuilder), asCALL_CDECL) >= 0);
|
||||
|
||||
Ensure(engine->RegisterObjectMethod("PokemonBuilder", "PokemonBuilder@ WithForme(const constString&in forme)",
|
||||
asMETHODPR(PkmnLib::Battling::CreatePokemon, WithForme,
|
||||
(const ArbUt::StringView&), PkmnLib::Battling::CreatePokemon&),
|
||||
asCALL_THISCALL));
|
||||
Ensure(engine->RegisterObjectMethod("PokemonBuilder", "PokemonBuilder@ WithGender(Gender gender)",
|
||||
asFUNCTION(WithGenderWrapper), asCALL_CDECL_OBJFIRST));
|
||||
Ensure(engine->RegisterObjectMethod(
|
||||
"PokemonBuilder", "PokemonBuilder@ IsShiny(bool value)",
|
||||
asMETHODPR(PkmnLib::Battling::CreatePokemon, IsShiny, (bool), PkmnLib::Battling::CreatePokemon&),
|
||||
asCALL_THISCALL));
|
||||
Ensure(engine->RegisterObjectMethod("PokemonBuilder", "PokemonBuilder@ WithHeldItem(const constString&in item)",
|
||||
asMETHODPR(PkmnLib::Battling::CreatePokemon, WithHeldItem,
|
||||
(const ArbUt::StringView&), PkmnLib::Battling::CreatePokemon&),
|
||||
asCALL_THISCALL));
|
||||
Ensure(engine->RegisterObjectMethod(
|
||||
"PokemonBuilder", "PokemonBuilder@ LearnMove(const constString&in move, MoveLearnMethod method)",
|
||||
asMETHODPR(PkmnLib::Battling::CreatePokemon, LearnMove,
|
||||
(const ArbUt::StringView&, CreatureLib::Battling::AttackLearnMethod),
|
||||
PkmnLib::Battling::CreatePokemon&),
|
||||
asCALL_THISCALL));
|
||||
Ensure(engine->RegisterObjectMethod(
|
||||
"PokemonBuilder",
|
||||
"PokemonBuilder@ WithIndividualValues(uint8 hp,uint8 att,uint8 def,uint8 spa,uint8 spd,uint8 speed)",
|
||||
asMETHODPR(PkmnLib::Battling::CreatePokemon, WithIndividualValues, (u8, u8, u8, u8, u8, u8),
|
||||
PkmnLib::Battling::CreatePokemon&),
|
||||
asCALL_THISCALL));
|
||||
Ensure(engine->RegisterObjectMethod(
|
||||
"PokemonBuilder",
|
||||
"PokemonBuilder@ WithEffortValues(uint8 hp,uint8 att,uint8 def,uint8 spa,uint8 spd,uint8 speed)",
|
||||
asMETHODPR(PkmnLib::Battling::CreatePokemon, WithEffortValues, (u8, u8, u8, u8, u8, u8),
|
||||
PkmnLib::Battling::CreatePokemon&),
|
||||
asCALL_THISCALL));
|
||||
Ensure(engine->RegisterObjectMethod("PokemonBuilder", "PokemonBuilder@ WithNature(const constString&in nature)",
|
||||
asMETHODPR(PkmnLib::Battling::CreatePokemon, WithNature,
|
||||
(const ArbUt::StringView&), PkmnLib::Battling::CreatePokemon&),
|
||||
asCALL_THISCALL));
|
||||
Ensure(engine->RegisterObjectMethod("PokemonBuilder", "PokemonBuilder@ WithNickname(const string&in name)",
|
||||
asMETHODPR(PkmnLib::Battling::CreatePokemon, WithNickname,
|
||||
(const std::string&), PkmnLib::Battling::CreatePokemon&),
|
||||
asCALL_THISCALL));
|
||||
Ensure(engine->RegisterObjectMethod("PokemonBuilder", "Pokemon@ Build(uint seed = 0)", asFUNCTION(BuildWrapper),
|
||||
asCALL_CDECL_OBJFIRST));
|
||||
}
|
||||
};
|
||||
|
||||
#endif // POKEMONSCRIPTTESTER_POKEMONBUILDER_HPP
|
||||
@@ -23,7 +23,7 @@ private:
|
||||
|
||||
static bool Require(bool value) {
|
||||
auto* ctx = asGetActiveContext();
|
||||
TestEnvironment* env = static_cast<TestEnvironment*>(ctx->GetUserData());
|
||||
TestEnvironment* env = static_cast<TestEnvironment*>(ctx->GetUserData(684));
|
||||
env->TotalRequirements += 1;
|
||||
if (!value) {
|
||||
env->FailedRequirements += 1;
|
||||
@@ -43,7 +43,7 @@ private:
|
||||
|
||||
static bool RequireEqualsI32(i32 expected, i32 actual) {
|
||||
auto* ctx = asGetActiveContext();
|
||||
TestEnvironment* env = static_cast<TestEnvironment*>(ctx->GetUserData());
|
||||
TestEnvironment* env = static_cast<TestEnvironment*>(ctx->GetUserData(684));
|
||||
env->TotalRequirements += 1;
|
||||
if (expected != actual) {
|
||||
env->FailedRequirements += 1;
|
||||
@@ -56,7 +56,7 @@ private:
|
||||
|
||||
static bool RequireEqualsString(const std::string& expected, const std::string& actual) {
|
||||
auto* ctx = asGetActiveContext();
|
||||
TestEnvironment* env = static_cast<TestEnvironment*>(ctx->GetUserData());
|
||||
TestEnvironment* env = static_cast<TestEnvironment*>(ctx->GetUserData(684));
|
||||
if (expected != actual) {
|
||||
env->FailedRequirements += 1;
|
||||
auto data = GetRequirementData(ctx);
|
||||
|
||||
@@ -13,17 +13,31 @@ public:
|
||||
void Run(asIScriptContext* ctx) {
|
||||
ctx->PushState();
|
||||
ctx->Prepare(_function);
|
||||
ctx->SetUserData(_env.get());
|
||||
ctx->SetUserData(_env.get(), 684);
|
||||
auto e = ctx->Execute();
|
||||
if (e == asEXECUTION_SUSPENDED) {
|
||||
auto s = ctx->GetState();
|
||||
while (s != asEXECUTION_FINISHED && s != asEXECUTION_EXCEPTION && s != asEXECUTION_ABORTED &&
|
||||
s != asEXECUTION_ERROR) {
|
||||
s = ctx->GetState();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
_env->CollectGarbage();
|
||||
if (e == asEXECUTION_EXCEPTION) {
|
||||
_errorMessage = ctx->GetExceptionString();
|
||||
std::stringstream error;
|
||||
const char* exceptionSection = "";
|
||||
int exceptionColumn = 0;
|
||||
auto exceptionLine = ctx->GetExceptionLineNumber(&exceptionColumn, &exceptionSection);
|
||||
error << "[" << exceptionSection << ":" << exceptionLine << "," << exceptionColumn << "] "
|
||||
<< ctx->GetExceptionString();
|
||||
_errorMessage = error.str();
|
||||
_result = TestResult::Failed;
|
||||
ctx->PopState();
|
||||
return;
|
||||
}
|
||||
ctx->PopState();
|
||||
Ensure(e == asEXECUTION_FINISHED);
|
||||
_result = TestResult::Success;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,13 @@ struct TestEnvironment {
|
||||
size_t FailedRequirements = 0;
|
||||
|
||||
template <typename T> void AddGarbage(T* data) { _garbage.Append(GarbageObject(data)); }
|
||||
template <typename T> void TakeOwnershipOfGarbage(T* data) {
|
||||
for (auto& g : _garbage) {
|
||||
if (g.Ptr == data) {
|
||||
g.Ptr = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CollectGarbage() {
|
||||
for (auto& o : _garbage) {
|
||||
|
||||
@@ -2,14 +2,18 @@
|
||||
#define POKEMONSCRIPTTESTER_TESTRUNNER_HPP
|
||||
|
||||
#include <PkmnLib/ScriptResolving/AngelScript/AngelScriptMetadata.hpp>
|
||||
#include <PkmnLib/ScriptResolving/AngelScript/ContextPool.hpp>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
#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 +34,21 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
i32 RunAll(asIScriptEngine* engine) {
|
||||
auto ctx = engine->CreateContext();
|
||||
i32 RunAll(bool waitForDebugger) {
|
||||
auto ctx = _scriptResolver->GetContextPool()->RequestContext();
|
||||
ctx->SetUserData(_scriptResolver->GetUserdata());
|
||||
_scriptResolver->SetDebugger(new AngelscriptDebugger());
|
||||
auto& debugger = *_scriptResolver->GetDebugger().GetValue();
|
||||
debugger.Run(8684);
|
||||
debugger.RegisterContext(ctx);
|
||||
if (waitForDebugger) {
|
||||
std::cout << "Waiting for debugger" << std::endl;
|
||||
while (!debugger.HasDebuggerAttached()) {
|
||||
continue;
|
||||
}
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
}
|
||||
|
||||
for (auto& test : _tests) {
|
||||
test.second->Run(ctx);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "Globals.hpp"
|
||||
#include "Tester/AngelScript/BattleFunctions.hpp"
|
||||
#include "Tester/AngelScript/MiscMockFunctions.hpp"
|
||||
#include "Tester/AngelScript/PokemonBuilder.hpp"
|
||||
#include "Tester/AngelScript/TestFunctions.hpp"
|
||||
#include "Tester/TestRunner.hpp"
|
||||
#include "git.h"
|
||||
@@ -23,6 +24,8 @@ int main(int argc, char** argv) {
|
||||
{"workdir"});
|
||||
args::Flag logTimeFlag(parser, "time-log", "Whether to show time logging.", {'t', "time-log"});
|
||||
args::Flag forceColorFlag(parser, "force-color", "Whether to force color text output.", {'c', "force-color"});
|
||||
args::Flag waitForDebuggerFlag(parser, "wait-for-debugger", "Whether to wait until a debugger is connected or not.",
|
||||
{'w', "wait-for-debugger"});
|
||||
try {
|
||||
parser.ParseCLI(argc, argv);
|
||||
} catch (args::Help&) {
|
||||
@@ -55,6 +58,7 @@ int main(int argc, char** argv) {
|
||||
TestFunctions::Register(scriptResolver);
|
||||
BattleFunctions::Register(scriptResolver);
|
||||
MiscMockFunctions::Register(scriptResolver);
|
||||
PokemonBuilderRegistration::Register(scriptResolver);
|
||||
};
|
||||
|
||||
Globals::Library = BuildLibrary::Build("", initialize);
|
||||
@@ -71,9 +75,8 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
auto* scriptResolver = dynamic_cast<AngelScriptResolver*>(Globals::Library.GetValue()->GetScriptResolver().get());
|
||||
auto testRunner = TestRunner(scriptResolver);
|
||||
auto* engine = scriptResolver->GetBuilder().GetEngine();
|
||||
std::chrono::steady_clock::time_point beginTests = std::chrono::steady_clock::now();
|
||||
auto v = testRunner.RunAll(engine);
|
||||
auto v = testRunner.RunAll(waitForDebuggerFlag.Get());
|
||||
std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now();
|
||||
std::cout << std::endl
|
||||
<< "Total Run time: " << std::chrono::duration_cast<std::chrono::milliseconds>(end - begin).count()
|
||||
|
||||
Reference in New Issue
Block a user