⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 buildruntextlistener.cpp

📁 自动化编译工具代码
💻 CPP
字号:
// BuildRunTextListener.cpp: implementation of the CBuildRunTextListener class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "BuildRunTextListener.h"

#include "resultxsd.h"
#include "Common.h"

#include <iostream>
using namespace std;

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CBuildRunTextListener::CBuildRunTextListener()
{

}

CBuildRunTextListener::~CBuildRunTextListener()
{

}


void CBuildRunTextListener::ReportExecStepMsg(ExecStepMsg msg)
{
	const CString strMsg = GetMsgText(msg);

	cout << (LPCTSTR)strMsg << endl;
}


/*    
--------------------------SUCCESSED----------------------------------
VSSPath			= $/Test/TestProjectVC2005
ProjectName		= TestProjectVC2005
---------------------------------------------------------------------
--------------------------FAILED-------------------------------------
VSSPath			= $/Test/TestProjectVC6
ProjectName		= TestProjectVC6
TestCount		= 10
FailTest		= 1
ProjectTempDir	= D:\TestDB\Project\133236781
TestResultFile	= D:\TestDB\Project\133236781\TestReport\tests.xml
---------------------------------------------------------------------
                                                                  */
//--------------------------------------------------------------------------
//								Default
//--------------------------------------------------------------------------
// 分析测试结果报告
BOOL CBuildRunTextListener::ReportExecResult(const CString &strTestResultFile,
											 CTestProjectType project)
{
	CString strReportMsg;

	CString strVSSPath			= project.GetVSSPath();
	CString strProjectName		= project.GetProjectName();

	CresultxsdDoc	doc;
	CTestRunType	root	= doc.Load(strTestResultFile);
	CStatisticsType statis	= root.GetStatistics();
	if (statis.GetFailures() > 0)	// 错误
	{
		CFailedTestsType failtests = root.GetFailedTests();

		int		nTests				= statis.GetTests();
		int		nFailures			= statis.GetFailures();
		CString strProjectTempDir	= CCommon::GetDirFrontDirPath(CCommon::GetFilePath(strTestResultFile));
		strReportMsg.Format(
			"\r\n---------------------------Fails---------------------------"
			"\r\nVSSPath        = %s"
			"\r\nProjectName    = %s"
			"\r\nProjectTempDir = %s"
			"\r\nTestResultFile = %s"
			"\r\n"
			"\r\n------------------ %d test(s), %d fails(s) ------------------"
			"\r\n"
				,strVSSPath
				,strProjectName
				,strProjectTempDir
				,strTestResultFile
				,nTests
				,nFailures
				);
	}
	/* 这中间还有"异常" */
	else						// 成功
	{
		strReportMsg.Format(
			"--------------------------Successed--------------------------"
			"\r\nVSSPath         = %s"
			"\r\nProjectName     = %s"
			"\r\n"
				,strVSSPath
				,strProjectName);
	}

	cout << (LPCTSTR)strReportMsg << endl;

	return statis.GetFailures() == 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -