浏览代码

tests: attempt to fix build without lua

Konstantin 2 年之前
父节点
当前提交
2a8f9629ae

+ 4 - 1
test/CMakeLists.txt

@@ -172,12 +172,15 @@ if(COPY)
 endif()
 endif()
 check_cxx_compiler_flag(-Wvirtual-move-assign MOVE_ASSIGN)
 check_cxx_compiler_flag(-Wvirtual-move-assign MOVE_ASSIGN)
 if(MOVE_ASSIGN)
 if(MOVE_ASSIGN)
-	add_compile_options(-Wno-virtual-move-assign) #GCC is too strict here
+	add_compile_options(-Wno-error=virtual-move-assign) #GCC is too strict here
 endif()
 endif()
 add_subdirectory_with_folder("3rdparty" googletest EXCLUDE_FROM_ALL)
 add_subdirectory_with_folder("3rdparty" googletest EXCLUDE_FROM_ALL)
 
 
 add_executable(vcmitest ${test_SRCS} ${test_HEADERS} ${mock_HEADERS})
 add_executable(vcmitest ${test_SRCS} ${test_HEADERS} ${mock_HEADERS})
 target_link_libraries(vcmitest PRIVATE gtest gmock vcmi ${SYSTEM_LIBS})
 target_link_libraries(vcmitest PRIVATE gtest gmock vcmi ${SYSTEM_LIBS})
+if(ENABLE_LUA)
+	target_link_libraries(vcmitest PRIVATE vcmiLua)
+endif()
 
 
 target_include_directories(vcmitest
 target_include_directories(vcmitest
 		PUBLIC	${CMAKE_CURRENT_SOURCE_DIR}
 		PUBLIC	${CMAKE_CURRENT_SOURCE_DIR}

+ 13 - 0
test/battle/CBattleInfoCallbackTest.cpp

@@ -19,7 +19,9 @@
 #include "mock/mock_BonusBearer.h"
 #include "mock/mock_BonusBearer.h"
 #include "mock/mock_battle_IBattleState.h"
 #include "mock/mock_battle_IBattleState.h"
 #include "mock/mock_battle_Unit.h"
 #include "mock/mock_battle_Unit.h"
+#if SCRIPTING_ENABLED
 #include "mock/mock_scripting_Pool.h"
 #include "mock/mock_scripting_Pool.h"
+#endif
 
 
 using namespace battle;
 using namespace battle;
 using namespace testing;
 using namespace testing;
@@ -122,11 +124,16 @@ public:
 	{
 	{
 	public:
 	public:
 
 
+#if SCRIPTING_ENABLED
 		scripting::Pool * pool;
 		scripting::Pool * pool;
 
 
 		TestSubject(scripting::Pool * p)
 		TestSubject(scripting::Pool * p)
 			: CBattleInfoCallback(),
 			: CBattleInfoCallback(),
 			pool(p)
 			pool(p)
+#else
+		TestSubject()
+			: CBattleInfoCallback()
+#endif
 		{
 		{
 		}
 		}
 
 
@@ -135,13 +142,17 @@ public:
 			CBattleInfoCallback::setBattle(battleInfo);
 			CBattleInfoCallback::setBattle(battleInfo);
 		}
 		}
 
 
+#if SCRIPTING_ENABLED
 		scripting::Pool * getContextPool() const override
 		scripting::Pool * getContextPool() const override
 		{
 		{
 			return pool;
 			return pool;
 		}
 		}
+#endif
 	};
 	};
 
 
+#if SCRIPTING_ENABLED
 	StrictMock<scripting::PoolMock> pool;
 	StrictMock<scripting::PoolMock> pool;
+#endif
 
 
 	TestSubject subject;
 	TestSubject subject;
 
 
@@ -149,8 +160,10 @@ public:
 	UnitsFake unitsFake;
 	UnitsFake unitsFake;
 
 
 	CBattleInfoCallbackTest()
 	CBattleInfoCallbackTest()
+#if SCRIPTING_ENABLED
 		: pool(),
 		: pool(),
 		subject(&pool)
 		subject(&pool)
+#endif
 	{
 	{
 
 
 	}
 	}

+ 7 - 4
test/mock/BattleFake.cpp

@@ -76,12 +76,14 @@ void UnitsFake::setDefaultBonusExpectations()
 
 
 BattleFake::~BattleFake() = default;
 BattleFake::~BattleFake() = default;
 
 
-BattleFake::BattleFake(std::shared_ptr<scripting::PoolMock> pool_)
-	: CBattleInfoCallback(),
-	BattleStateMock(),
+#if SCRIPTING_ENABLED
+BattleFake::BattleFake(std::shared_ptr<scripting::PoolMock> pool_):
 	pool(pool_)
 	pool(pool_)
 {
 {
 }
 }
+#else
+BattleFake::BattleFake() = default;
+#endif
 
 
 void BattleFake::setUp()
 void BattleFake::setUp()
 {
 {
@@ -95,11 +97,12 @@ void BattleFake::setupEmptyBattlefield()
 	EXPECT_CALL(*this, getBattlefieldType()).WillRepeatedly(Return(BattleField::fromString("grass_hills")));
 	EXPECT_CALL(*this, getBattlefieldType()).WillRepeatedly(Return(BattleField::fromString("grass_hills")));
 }
 }
 
 
-
+#if SCRIPTING_ENABLED
 scripting::Pool * BattleFake::getContextPool() const
 scripting::Pool * BattleFake::getContextPool() const
 {
 {
 	return pool.get();
 	return pool.get();
 }
 }
+#endif
 
 
 }
 }
 }
 }

+ 10 - 0
test/mock/BattleFake.h

@@ -15,7 +15,9 @@
 #include "mock_BonusBearer.h"
 #include "mock_BonusBearer.h"
 #include "mock_battle_IBattleState.h"
 #include "mock_battle_IBattleState.h"
 #include "mock_battle_Unit.h"
 #include "mock_battle_Unit.h"
+#if SCRIPTING_ENABLED
 #include "mock_scripting_Pool.h"
 #include "mock_scripting_Pool.h"
+#endif
 
 
 #include "../../lib/JsonNode.h"
 #include "../../lib/JsonNode.h"
 #include "../../lib/NetPacksBase.h"
 #include "../../lib/NetPacksBase.h"
@@ -61,16 +63,24 @@ public:
 
 
 class BattleFake : public CBattleInfoCallback, public BattleStateMock
 class BattleFake : public CBattleInfoCallback, public BattleStateMock
 {
 {
+#if SCRIPTING_ENABLED
 	std::shared_ptr<scripting::PoolMock> pool;
 	std::shared_ptr<scripting::PoolMock> pool;
+#endif
 public:
 public:
+#if SCRIPTING_ENABLED
 	BattleFake(std::shared_ptr<scripting::PoolMock> pool_);
 	BattleFake(std::shared_ptr<scripting::PoolMock> pool_);
+#else
+	BattleFake();
+#endif
 	virtual ~BattleFake();
 	virtual ~BattleFake();
 
 
 	void setUp();
 	void setUp();
 
 
 	void setupEmptyBattlefield();
 	void setupEmptyBattlefield();
 
 
+#if SCRIPTING_ENABLED
 	scripting::Pool * getContextPool() const override;
 	scripting::Pool * getContextPool() const override;
+#endif
 
 
 	template <typename T>
 	template <typename T>
 	void accept(T * pack)
 	void accept(T * pack)

+ 2 - 0
test/mock/mock_IBattleInfoCallback.h

@@ -16,7 +16,9 @@
 class IBattleInfoCallbackMock : public IBattleInfoCallback
 class IBattleInfoCallbackMock : public IBattleInfoCallback
 {
 {
 public:
 public:
+#if SCRIPTING_ENABLED
 	MOCK_CONST_METHOD0(getContextPool, scripting::Pool *());
 	MOCK_CONST_METHOD0(getContextPool, scripting::Pool *());
+#endif
 	MOCK_CONST_METHOD0(battleTerrainType, TerrainId());
 	MOCK_CONST_METHOD0(battleTerrainType, TerrainId());
 	MOCK_CONST_METHOD0(battleGetBattlefieldType, BattleField());
 	MOCK_CONST_METHOD0(battleGetBattlefieldType, BattleField());
 
 

+ 3 - 0
test/mock/mock_IGameCallback.h

@@ -91,7 +91,10 @@ public:
 	///useful callback methods
 	///useful callback methods
 	void sendAndApply(CPackForClient * pack) override;
 	void sendAndApply(CPackForClient * pack) override;
 
 
+#if SCRIPTING_ENABLED
 	MOCK_CONST_METHOD0(getGlobalContextPool, scripting::Pool *());
 	MOCK_CONST_METHOD0(getGlobalContextPool, scripting::Pool *());
+#endif
+
 private:
 private:
 	UpperCallback * upperCallback;
 	UpperCallback * upperCallback;
 };
 };

+ 2 - 0
test/mock/mock_Services.h

@@ -21,7 +21,9 @@ public:
 	MOCK_CONST_METHOD0(factions, const FactionService *());
 	MOCK_CONST_METHOD0(factions, const FactionService *());
 	MOCK_CONST_METHOD0(heroClasses, const HeroClassService *());
 	MOCK_CONST_METHOD0(heroClasses, const HeroClassService *());
 	MOCK_CONST_METHOD0(heroTypes, const HeroTypeService *());
 	MOCK_CONST_METHOD0(heroTypes, const HeroTypeService *());
+#if SCRIPTING_ENABLED
 	MOCK_CONST_METHOD0(scripts, const scripting::Service *());
 	MOCK_CONST_METHOD0(scripts, const scripting::Service *());
+#endif
 	MOCK_CONST_METHOD0(spells, const spells::Service *());
 	MOCK_CONST_METHOD0(spells, const spells::Service *());
 	MOCK_CONST_METHOD0(skills, const SkillService * ());
 	MOCK_CONST_METHOD0(skills, const SkillService * ());
 	MOCK_CONST_METHOD0(battlefields, const BattleFieldService *());
 	MOCK_CONST_METHOD0(battlefields, const BattleFieldService *());

+ 2 - 0
test/mock/mock_spells_Mechanics.h

@@ -70,7 +70,9 @@ public:
 	MOCK_CONST_METHOD2(ownerMatches, bool(const battle::Unit *, const boost::logic::tribool));
 	MOCK_CONST_METHOD2(ownerMatches, bool(const battle::Unit *, const boost::logic::tribool));
 
 
 	MOCK_CONST_METHOD0(creatures, const CreatureService *());
 	MOCK_CONST_METHOD0(creatures, const CreatureService *());
+#if SCRIPTING_ENABLED
 	MOCK_CONST_METHOD0(scripts, const scripting::Service *());
 	MOCK_CONST_METHOD0(scripts, const scripting::Service *());
+#endif
 	MOCK_CONST_METHOD0(spells, const Service *());
 	MOCK_CONST_METHOD0(spells, const Service *());
 
 
 	MOCK_CONST_METHOD0(game, const IGameInfoCallback * ());
 	MOCK_CONST_METHOD0(game, const IGameInfoCallback * ());

+ 2 - 0
test/scripting/ScriptFixture.h

@@ -24,7 +24,9 @@
 #include "../mock/mock_IBattleInfoCallback.h"
 #include "../mock/mock_IBattleInfoCallback.h"
 #include "../mock/mock_IGameInfoCallback.h"
 #include "../mock/mock_IGameInfoCallback.h"
 #include "../mock/mock_battle_IBattleState.h"
 #include "../mock/mock_battle_IBattleState.h"
+#if SCRIPTING_ENABLED
 #include "../mock/mock_scripting_Pool.h"
 #include "../mock/mock_scripting_Pool.h"
+#endif
 #include "../mock/mock_Environment.h"
 #include "../mock/mock_Environment.h"
 #include "../mock/mock_Services.h"
 #include "../mock/mock_Services.h"
 #include "../mock/mock_vstd_CLoggerBase.h"
 #include "../mock/mock_vstd_CLoggerBase.h"

+ 4 - 1
test/spells/effects/EffectFixture.cpp

@@ -72,9 +72,12 @@ void EffectFixture::setupEffect(Registry * registry, const JsonNode & effectConf
 
 
 void EffectFixture::setUp()
 void EffectFixture::setUp()
 {
 {
+#if SCRIPTING_ENABLED
 	pool = std::make_shared<PoolMock>();
 	pool = std::make_shared<PoolMock>();
-
 	battleFake = std::make_shared<battle::BattleFake>(pool);
 	battleFake = std::make_shared<battle::BattleFake>(pool);
+#else
+	battleFake = std::make_shared<battle::BattleFake>();
+#endif
 	battleFake->setUp();
 	battleFake->setUp();
 
 
 	EXPECT_CALL(mechanicsMock, game()).WillRepeatedly(Return(&gameMock));
 	EXPECT_CALL(mechanicsMock, game()).WillRepeatedly(Return(&gameMock));

+ 6 - 0
test/spells/effects/EffectFixture.h

@@ -26,7 +26,9 @@
 #include "../../mock/mock_battle_IBattleState.h"
 #include "../../mock/mock_battle_IBattleState.h"
 #include "../../mock/mock_battle_Unit.h"
 #include "../../mock/mock_battle_Unit.h"
 #include "../../mock/mock_vstd_RNG.h"
 #include "../../mock/mock_vstd_RNG.h"
+#if SCRIPTING_ENABLED
 #include "../../mock/mock_scripting_Pool.h"
 #include "../../mock/mock_scripting_Pool.h"
+#endif
 #include "../../mock/BattleFake.h"
 #include "../../mock/BattleFake.h"
 #include "../../mock/mock_ServerCallback.h"
 #include "../../mock/mock_ServerCallback.h"
 
 
@@ -48,7 +50,9 @@ namespace test
 using namespace ::testing;
 using namespace ::testing;
 using namespace ::spells;
 using namespace ::spells;
 using namespace ::spells::effects;
 using namespace ::spells::effects;
+#if SCRIPTING_ENABLED
 using namespace ::scripting;
 using namespace ::scripting;
+#endif
 
 
 class EffectFixture
 class EffectFixture
 {
 {
@@ -65,7 +69,9 @@ public:
 
 
 	battle::UnitsFake unitsFake;
 	battle::UnitsFake unitsFake;
 
 
+#if SCRIPTING_ENABLED
 	std::shared_ptr<PoolMock> pool;
 	std::shared_ptr<PoolMock> pool;
+#endif
 	std::shared_ptr<battle::BattleFake> battleFake;
 	std::shared_ptr<battle::BattleFake> battleFake;
 
 
 	StrictMock<ServerCallbackMock> serverMock;
 	StrictMock<ServerCallbackMock> serverMock;