[PATCH v1 07/13] Remove outputDirectory global variable
Ryan Long
ryan.long at oarcorp.com
Sun Aug 1 23:23:41 UTC 2021
- Replaced outputDirectory in app_common with a local variable in
covoar()
- Created the outputDirectory_m member variable
- Added parameters to Reports* constructors to initialize
outputDirectory_m and non member functions
---
tester/covoar/ReportsBase.cc | 41 ++++++++++++++++++++++++++---------------
tester/covoar/ReportsBase.h | 19 +++++++++++++++----
tester/covoar/ReportsHtml.cc | 18 +++++++++++++++---
tester/covoar/ReportsHtml.h | 3 ++-
tester/covoar/ReportsText.cc | 11 +++++++++--
tester/covoar/ReportsText.h | 3 ++-
tester/covoar/app_common.cc | 1 -
tester/covoar/app_common.h | 1 -
tester/covoar/covoar.cc | 4 +++-
9 files changed, 72 insertions(+), 29 deletions(-)
diff --git a/tester/covoar/ReportsBase.cc b/tester/covoar/ReportsBase.cc
index b2da71a..266a6ea 100644
--- a/tester/covoar/ReportsBase.cc
+++ b/tester/covoar/ReportsBase.cc
@@ -27,12 +27,14 @@ ReportsBase::ReportsBase(
time_t timestamp,
const std::string& symbolSetName,
Coverage::Explanations& allExplanations,
- const std::string& projectName
+ const std::string& projectName,
+ const std::string& outputDirectory
): reportExtension_m( "" ),
symbolSetName_m( symbolSetName ),
timestamp_m( timestamp ),
allExplanations_m( allExplanations ),
- projectName_m( projectName )
+ projectName_m( projectName ),
+ outputDirectory_m( outputDirectory )
{
}
@@ -43,7 +45,8 @@ ReportsBase::~ReportsBase()
void ReportsBase::OpenFile(
const std::string& fileName,
const std::string& symbolSetName,
- std::ofstream& aFile
+ std::ofstream& aFile,
+ const std::string& outputDirectory
)
{
int sc;
@@ -89,7 +92,7 @@ void ReportsBase::OpenAnnotatedFile(
std::ofstream& aFile
)
{
- OpenFile(fileName, symbolSetName_m, aFile);
+ OpenFile( fileName, symbolSetName_m, aFile, outputDirectory_m );
}
void ReportsBase::OpenBranchFile(
@@ -98,7 +101,7 @@ void ReportsBase::OpenBranchFile(
std::ofstream& aFile
)
{
- OpenFile(fileName, symbolSetName_m, aFile);
+ OpenFile( fileName, symbolSetName_m, aFile, outputDirectory_m );
}
void ReportsBase::OpenCoverageFile(
@@ -106,7 +109,7 @@ void ReportsBase::OpenCoverageFile(
std::ofstream& aFile
)
{
- OpenFile(fileName, symbolSetName_m, aFile);
+ OpenFile( fileName, symbolSetName_m, aFile, outputDirectory_m );
}
void ReportsBase::OpenNoRangeFile(
@@ -114,7 +117,7 @@ void ReportsBase::OpenNoRangeFile(
std::ofstream& aFile
)
{
- OpenFile(fileName, symbolSetName_m, aFile);
+ OpenFile( fileName, symbolSetName_m, aFile, outputDirectory_m );
}
@@ -123,7 +126,7 @@ void ReportsBase::OpenSizeFile(
std::ofstream& aFile
)
{
- OpenFile(fileName, symbolSetName_m, aFile);
+ OpenFile( fileName, symbolSetName_m, aFile, outputDirectory_m );
}
void ReportsBase::OpenSymbolSummaryFile(
@@ -131,7 +134,7 @@ void ReportsBase::OpenSymbolSummaryFile(
std::ofstream& aFile
)
{
- OpenFile(fileName, symbolSetName_m, aFile);
+ OpenFile( fileName, symbolSetName_m, aFile, outputDirectory_m );
}
void ReportsBase::CloseFile( std::ofstream& aFile )
@@ -466,7 +469,8 @@ void ReportsBase::WriteSymbolSummaryReport( const std::string& fileName )
void ReportsBase::WriteSummaryReport(
const std::string& fileName,
- const std::string& symbolSetName
+ const std::string& symbolSetName,
+ const std::string& outputDirectory
)
{
// Calculate coverage statistics and output results.
@@ -480,7 +484,7 @@ void ReportsBase::WriteSummaryReport(
std::ofstream report;
// Open the report file.
- OpenFile( fileName, symbolSetName, report );
+ OpenFile( fileName, symbolSetName, report, outputDirectory );
if ( !report.is_open() ) {
return;
}
@@ -568,7 +572,8 @@ void GenerateReports(
const std::string& symbolSetName,
Coverage::Explanations& allExplanations,
bool verbose,
- const std::string& projectName
+ const std::string& projectName,
+ const std::string& outputDirectory
)
{
typedef std::list<ReportsBase *> reportList_t;
@@ -585,14 +590,16 @@ void GenerateReports(
timestamp,
symbolSetName,
allExplanations,
- projectName
+ projectName,
+ outputDirectory
);
reportList.push_back( reports );
reports = new ReportsHtml(
timestamp,
symbolSetName,
allExplanations,
- projectName
+ projectName,
+ outputDirectory
);
reportList.push_back( reports );
@@ -641,7 +648,11 @@ void GenerateReports(
delete reports;
}
- ReportsBase::WriteSummaryReport( "summary.txt", symbolSetName );
+ ReportsBase::WriteSummaryReport(
+ "summary.txt",
+ symbolSetName,
+ outputDirectory
+ );
}
}
diff --git a/tester/covoar/ReportsBase.h b/tester/covoar/ReportsBase.h
index 38b7c29..a0c6a32 100644
--- a/tester/covoar/ReportsBase.h
+++ b/tester/covoar/ReportsBase.h
@@ -31,7 +31,8 @@ class ReportsBase {
time_t timestamp,
const std::string& symbolSetName,
Coverage::Explanations& allExplanations,
- const std::string& projectName
+ const std::string& projectName,
+ const std::string& outputDirectory
);
virtual ~ReportsBase();
@@ -87,7 +88,8 @@ class ReportsBase {
*/
static void WriteSummaryReport(
const std::string& fileName,
- const std::string& symbolSetName
+ const std::string& symbolSetName,
+ const std::string& outputDirectory
);
/*!
@@ -136,17 +138,24 @@ class ReportsBase {
std::string projectName_m;
/*!
+ * This variable stores the output directory.
+ */
+ std::string outputDirectory_m = "";
+
+ /*!
* This method Opens a report file and verifies that it opened
* correctly. Upon failure NULL is returned.
*
* @param[in] fileName identifies the report file name
* @param[in] symbolSetName identifies the name of the report's symbol set
* @param[in] aFile identifies the file to open
+ * @param[in] outputDirectory identifies the directory for the output
*/
static void OpenFile(
const std::string& fileName,
const std::string& symbolSetName,
- std::ofstream& aFile
+ std::ofstream& aFile,
+ const std::string& outputDirectory
);
/*!
@@ -408,12 +417,14 @@ class ReportsBase {
* @param[in] allExplanations is the explanations to report on.
* @param[in] verbose specifies whether to be verbose with output
* @param[in] projectName specifies the name of the project
+ * @param[in] outputDirectory specifies the directory for the output
*/
void GenerateReports(
const std::string& symbolSetName,
Coverage::Explanations& allExplanations,
bool verbose,
- const std::string& projectName
+ const std::string& projectName,
+ const std::string& outputDirectory
);
}
diff --git a/tester/covoar/ReportsHtml.cc b/tester/covoar/ReportsHtml.cc
index 4f384d5..89067f7 100644
--- a/tester/covoar/ReportsHtml.cc
+++ b/tester/covoar/ReportsHtml.cc
@@ -41,8 +41,15 @@ namespace Coverage {
time_t timestamp,
const std::string& symbolSetName,
Coverage::Explanations& allExplanations,
- const std::string& projectName
- ): ReportsBase( timestamp, symbolSetName, allExplanations, projectName )
+ const std::string& projectName,
+ const std::string& outputDirectory
+ ): ReportsBase(
+ timestamp,
+ symbolSetName,
+ allExplanations,
+ projectName,
+ outputDirectory
+ )
{
reportExtension_m = ".html";
lastState_m = A_SOURCE;
@@ -105,7 +112,12 @@ namespace Coverage {
)
{
// Open the file
- ReportsBase::OpenFile( fileName, symbolSetName_m, aFile );
+ ReportsBase::OpenFile(
+ fileName,
+ symbolSetName_m,
+ aFile,
+ outputDirectory_m
+ );
// Put Header information on the file
aFile << "<html>" << std::endl
diff --git a/tester/covoar/ReportsHtml.h b/tester/covoar/ReportsHtml.h
index 46698f0..53e1897 100644
--- a/tester/covoar/ReportsHtml.h
+++ b/tester/covoar/ReportsHtml.h
@@ -29,7 +29,8 @@ class ReportsHtml: public ReportsBase {
time_t timestamp,
const std::string& symbolSetName,
Coverage::Explanations& allExplanations,
- const std::string& projectName
+ const std::string& projectName,
+ const std::string& outputDirectory
);
~ReportsHtml();
diff --git a/tester/covoar/ReportsText.cc b/tester/covoar/ReportsText.cc
index 7318de3..535bf76 100644
--- a/tester/covoar/ReportsText.cc
+++ b/tester/covoar/ReportsText.cc
@@ -20,8 +20,15 @@ ReportsText::ReportsText(
time_t timestamp,
const std::string& symbolSetName,
Coverage::Explanations& allExplanations,
- const std::string& projectName
-): ReportsBase( timestamp, symbolSetName, allExplanations, projectName )
+ const std::string& projectName,
+ const std::string& outputDirectory
+): ReportsBase(
+ timestamp,
+ symbolSetName,
+ allExplanations,
+ projectName,
+ outputDirectory
+ )
{
reportExtension_m = ".txt";
}
diff --git a/tester/covoar/ReportsText.h b/tester/covoar/ReportsText.h
index c44591d..b3ffd83 100644
--- a/tester/covoar/ReportsText.h
+++ b/tester/covoar/ReportsText.h
@@ -25,7 +25,8 @@ class ReportsText: public ReportsBase {
time_t timestamp,
const std::string& symbolSetName,
Coverage::Explanations& allExplanations,
- const std::string& projectName
+ const std::string& projectName,
+ const std::string& outputDirectory
);
virtual ~ReportsText();
diff --git a/tester/covoar/app_common.cc b/tester/covoar/app_common.cc
index cedffdd..6f88f4b 100644
--- a/tester/covoar/app_common.cc
+++ b/tester/covoar/app_common.cc
@@ -57,7 +57,6 @@
* Global variables for the program
*/
Coverage::DesiredSymbols* SymbolsToAnalyze = NULL;
-const char* outputDirectory = ".";
bool BranchInfoAvailable = false;
Target::TargetBase* TargetInfo = NULL;
char inputBuffer[MAX_LINE_LENGTH];
diff --git a/tester/covoar/app_common.h b/tester/covoar/app_common.h
index 533a926..473d259 100644
--- a/tester/covoar/app_common.h
+++ b/tester/covoar/app_common.h
@@ -13,7 +13,6 @@
#include "TargetBase.h"
extern Coverage::DesiredSymbols* SymbolsToAnalyze;
-extern const char* outputDirectory;
extern bool BranchInfoAvailable;
extern Target::TargetBase* TargetInfo;
diff --git a/tester/covoar/covoar.cc b/tester/covoar/covoar.cc
index 5f8de5b..2d161aa 100644
--- a/tester/covoar/covoar.cc
+++ b/tester/covoar/covoar.cc
@@ -179,6 +179,7 @@ int covoar(
bool verbose = false;
std::string dynamicLibrary;
std::string projectName;
+ std::string outputDirectory = ".";
//
// Process command line options.
@@ -479,7 +480,8 @@ int covoar(
setName,
allExplanations,
verbose,
- projectName
+ projectName,
+ outputDirectory
);
}
--
1.8.3.1
More information about the devel
mailing list