Exemple #1
0
int DesignerWarningFunc(const char * message)
{
	if (g_pGameCVars->designer_warning_enabled && (!gEnv->IsDedicated()))
	{
		GameWarning("!DESIGNER WARNING\n%s", message);
	}

	// kept because autotests gather all designer warnings out of logs with this form
	CryLogAlways("---DESIGNER_WARNING: %s", message);
	CryLogAlways("----------------------------------------");

#if ENABLE_FEATURE_TESTER
	// If feature testing is in progress, write each designer warning out as a failed feature test

	CFeatureTester * featureTester = CFeatureTester::GetInstance();
	if (featureTester)
	{
		CAutoTester * autoTestResultWriter = featureTester->GetAutoTesterIfActive();
		if (autoTestResultWriter)
		{
			CryFixedStringT<32> warningName;
			warningName.Format("DesignerWarning%04u", s_numDesignerWarningsHit);
			autoTestResultWriter->AddSimpleTestCase("DesignerWarnings", warningName.c_str(), 0.1f, message);
		}
	}
#endif

	s_numDesignerWarningsHit++;
	return 0;
}
Exemple #2
0
// Console commands
void CFeatureTestMgr::CmdMapRunAll(IConsoleCmdArgs *pArgs)
{
#if ENABLE_FEATURE_TESTER
	CFeatureTester* pFTester = CFeatureTester::GetInstance();

	bool reloadLevel = false;
	bool quickload = false;

	int argCount = pArgs->GetArgCount();
	for (int argIndex = 0; argIndex < argCount; ++argIndex)
	{
		const char* arg = pArgs->GetArg(argIndex);
		if (!stricmp("reloadlevel", arg))
		{
			reloadLevel = true;
		}
		if (!stricmp("quickload", arg))
		{
			quickload = true;
		}
	}

	if (pFTester)
		pFTester->GetMapFeatureTestMgr().ScheduleRunAll(reloadLevel, quickload, 0.0f);
#else
	CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_ERROR, "Feature testing not enabled in this build.");
#endif
}
/// Utility function for returning a test result to the manager and updating any associated entity passed trigger
void CFlowNode_FeatureTest::SetResult(bool result, const char *reason)
{
#if ENABLE_FEATURE_TESTER
	CFeatureTester *pFeatureTester = CFeatureTester::GetInstance();

	if(pFeatureTester)
	{
		CFeatureTestMgr &ftMgr = pFeatureTester->GetMapFeatureTestMgr();

		// If this is the result for a sequence test
		if(m_entitySeqIndex >= 0 && m_entitySeqIndex < SEQ_ENTITY_COUNT)
		{
			IEntity *pEnt = NULL;
			GetEntityAtIndex(m_entitySeqIndex, pEnt);

			if(pEnt)
			{
				ActivateOutput(&m_actInfo, SEQ_ENTITY_FIRST_OUTPUT_PORT + m_entitySeqIndex, result);

				// If test has actually run
				if(TestHasRun())
				{
					// Inform manager of results
					string testSeqName(Name());
					testSeqName.append("[");
					testSeqName.append(pEnt->GetEntityTextDescription());
					testSeqName.append("]");

					const string desc(GetPortString(&m_actInfo, eInputPorts_Description));

					//Need to ensure non-owned tests pass null pointer
					const char *owners = m_owners.empty() ? NULL : m_owners.c_str();

					ftMgr.OnTestResults(testSeqName.c_str(), desc.c_str(), (result) ? NULL : reason, m_timeRunning, owners);
				}
			}
		}
		else	// Single test (not sequence)
		{
			// If test has actually run
			if(TestHasRun())
			{
				// Inform manager of results
				string testSeqName(Name());
				const string desc(GetPortString(&m_actInfo, eInputPorts_Description));

				//Need to ensure non-owned tests pass null pointer
				const char *owners = m_owners.empty() ? NULL : m_owners.c_str();

				ftMgr.OnTestResults(testSeqName.c_str(), desc.c_str(), (result) ? NULL : reason, m_timeRunning, owners);
			}
		}
	}

#endif
	// NOTE: AllPassed should be triggered by the caller if no more tests are left to run
}
Exemple #4
0
	CFeatureTestMgr* GetFeatureTestMgr() const
	{
#if ENABLE_FEATURE_TESTER
		CFeatureTester* pFTester = CFeatureTester::GetInstance();

		if (pFTester)
		{
			return &pFTester->GetMapFeatureTestMgr();
		}
#endif
		return NULL;
	}
CFlowNode_FeatureTest::~CFlowNode_FeatureTest()
{
#if ENABLE_FEATURE_TESTER
	// Unregister from FeatureTester
	CFeatureTester *pFeatureTester = CFeatureTester::GetInstance();

	if(pFeatureTester)
	{
		pFeatureTester->GetMapFeatureTestMgr().UnregisterFeatureTest(this);
	}

#endif
}
/// Used to return results and schedule next run in sequence
void CFlowNode_FeatureTest::OnTestResult(bool result, const char *reason)
{
#if ENABLE_FEATURE_TESTER
	CFeatureTester *pFeatureTester = CFeatureTester::GetInstance();

	if(pFeatureTester)
	{
		CODECHECKPOINT(FeatureTest_OnTestResult_Start);
		CFeatureTestMgr &ftMgr = pFeatureTester->GetMapFeatureTestMgr();

		if(m_running)
		{
			if(!result)
				++m_failureCount;

			// Sets the result for any associated entity passed triggers and informs manager of result
			SetResult(result, reason);

			// Ensure all tests are reset and this is no longer marked as running
			Cleanup();

			// If testing a sequence, this will run the next test and mark this as running again
			StartNextTestRun();

			// If no more sequential entities?
			if(!m_running)
			{
				CODECHECKPOINT(FeatureTest_OnTestResult_TestFinished);
				// Indicate test case complete
				ActivateOutput(&m_actInfo, eOutputPorts_AllPassed, m_failureCount == 0);

				ftMgr.OnTestFinished(this);
			}
		}
		else
		{
			CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_WARNING, "FeatureTest %s received Succeeded signal when test was inactive (ignoring).", Name());
		}
	}

#endif
}
CFlowNode_FeatureTest::CFlowNode_FeatureTest(SActivationInfo *activationInformation)
	:	m_actInfo(),
		m_entitySeqIndex(-1),
		m_failureCount(),
		m_timeRunning(0.0f),
		m_hasBeenStarted(false),
		m_ready(),
		m_running(),
		m_labelProfileData(false)
{
#if ENABLE_FEATURE_TESTER
	// Register with FeatureTester
	CFeatureTester *pFeatureTester = CFeatureTester::GetInstance();

	if(pFeatureTester)
	{
		pFeatureTester->GetMapFeatureTestMgr().RegisterFeatureTest(this);
	}

#endif
}
Exemple #8
0
void CFeatureTestMgr::CmdMapForceRun(IConsoleCmdArgs *pArgs)
{
#if ENABLE_FEATURE_TESTER
	CFeatureTester* pFTester = CFeatureTester::GetInstance();

	if (pFTester)
	{
		CFeatureTestMgr& ftMgr = pFTester->GetMapFeatureTestMgr();

		if (pArgs->GetArgCount() == 2)
		{
			const char* ftName = pArgs->GetArg(1);
			ftMgr.ForceRun(ftName);
		}
		else
		{
			CryLogAlways("Usage: %s <testname>", pArgs->GetArg(0));
		}
	}
#else
	CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_ERROR, "Feature testing not enabled in this build.");
#endif
}
void CFlowNode_FeatureTest::ProcessEvent(EFlowEvent event, SActivationInfo *pActInfo)
{
#if ENABLE_FEATURE_TESTER
	CFeatureTester *pFeatureTester = CFeatureTester::GetInstance();

	if(pFeatureTester)
	{
		CFeatureTestMgr &ftMgr = pFeatureTester->GetMapFeatureTestMgr();

		switch(event)
		{
		case eFE_Initialize:
		{
			m_actInfo = *pActInfo;

			// Use this event to reset state in CMapFeatureTestMgr if tests were in progress,
			// allowing it to cope with game/editor transitions cleanly
			if(m_running)
				ftMgr.Reset();

			// Called on level load/reset
			m_ready = false;
			m_running = false;
			m_failureCount = 0;
			m_timeRunning = 0.0f;
			m_hasBeenStarted = false;

			// Deactivate & hide any associated entities - doesn't work... Need to explore other techniques
			// For now just use HiddenInGame for tests
			//DeactivateAllEntities();

			// Set default result outputs to false with reason "Not run"
			for(m_entitySeqIndex = 0; m_entitySeqIndex < SEQ_ENTITY_COUNT; ++m_entitySeqIndex)
				SetResult(false, "Not run");

			m_entitySeqIndex = -1;

			ActivateOutput(pActInfo, eOutputPorts_AllPassed, false);
		}
		break;

		case eFE_Activate:
		{
			if(IsPortActive(pActInfo, eInputPorts_Ready))
			{
				bool readyInput = GetPortBool(pActInfo, eInputPorts_Ready);
				m_labelProfileData = GetPortBool(pActInfo, eInputPorts_LabelProfileData);
				m_owners = GetPortString(pActInfo, eInputPorts_Owners);

				if(readyInput != m_ready)
				{
					m_ready = readyInput;
					CryLogAlways("Test %s now: %s", Name(), m_ready ? "Ready to run" : "Not ready to run");
				}
			}
			else if(IsPortActive(pActInfo, eInputPorts_Succeeded))
			{
				OnTestResult(true, "FG Succeeded Triggered");
			}
			else if(IsPortActive(pActInfo, eInputPorts_Failed))
			{
				OnTestResult(false, "FG Failed Triggered");
			}
		}
		break;
		}
	}

#endif
}