Commit 2f2596c2 authored by Andy Cedilnik's avatar Andy Cedilnik
Browse files

ENH: Add option to submit notes. Implements Bug #465 - Add notes support to CTest

parent 32accc16
......@@ -470,6 +470,10 @@ bool cmCTest::SetTest(const char* ttype)
{
m_Tests[cmCTest::MEMCHECK_TEST] = 1;
}
else if ( cmSystemTools::LowerCase(ttype) == "notes" )
{
m_Tests[cmCTest::NOTES_TEST] = 1;
}
else if ( cmSystemTools::LowerCase(ttype) == "submit" )
{
m_Tests[cmCTest::SUBMIT_TEST] = 1;
......@@ -924,7 +928,8 @@ int cmCTest::ConfigureDirectory()
std::ofstream os;
if ( !this->OpenOutputFile(m_CurrentTag, "Configure.xml", os) )
{
std::cerr << "Cannot open log file" << std::endl;
std::cerr << "Cannot open configure file" << std::endl;
return 1;
}
std::string start_time = ::CurrentTime();
......@@ -2194,6 +2199,10 @@ int cmCTest::SubmitResults()
{
files.push_back("Purify.xml");
}
if ( this->CTestFileExists("Notes.xml") )
{
files.push_back("Notes.xml");
}
cmCTestSubmit submit;
submit.SetVerbose(m_Verbose);
if ( m_DartConfiguration["DropMethod"] == "" ||
......@@ -3259,3 +3268,81 @@ bool cmCTest::ProcessMemCheckOutput(const std::string& str, std::string& log, in
return true;
}
int cmCTest::GenerateDartNotesOutput(std::ostream& os, const cmCTest::tm_VectorOfStrings& files)
{
cmCTest::tm_VectorOfStrings::const_iterator it;
for ( it = files.begin(); it != files.end(); it ++ )
{
if ( !cmSystemTools::FileExists(it->c_str()) )
{
std::cerr << "Error creating notes. File " << it->c_str() << " does not exists" << std::endl;
return 0;
}
}
os << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
<< "<?xml-stylesheet type=\"text/xsl\" href=\"Dart/Source/Server/XSL/Build.xsl <file:///Dart/Source/Server/XSL/Build.xsl> \"?>\n"
<< "<Site BuildName=\"" << m_DartConfiguration["BuildName"] << "\" BuildStamp=\""
<< m_CurrentTag << "-" << this->GetTestModelString() << "\" Name=\""
<< m_DartConfiguration["Site"] << "\">\n"
<< "<Notes>" << std::endl;
for ( it = files.begin(); it != files.end(); it ++ )
{
std::cout << "\tAdd file: " << it->c_str() << std::endl;
std::string note_time = ::CurrentTime();
os << "<Note>\n"
<< "<DateTime>" << note_time << "</DateTime>\n"
<< "<Text>" << std::endl;
std::ifstream ifs(it->c_str());
if ( ifs )
{
std::string line;
while ( cmSystemTools::GetLineFromStream(ifs, line) )
{
os << this->MakeXMLSafe(line) << std::endl;
}
ifs.close();
}
else
{
os << "Problem reading file: " << it->c_str() << std::endl;
std::cerr << "Problem reading file: " << it->c_str() << " while creating notes" << std::endl;
}
os << "</Text>\n"
<< "</Note>" << std::endl;
}
os << "</Notes>\n"
<< "</Site>" << std::endl;
return 1;
}
int cmCTest::GenerateNotesFile(const char* cfiles)
{
if ( !cfiles )
{
return 1;
}
std::vector<cmStdString> files;
std::cout << "Create notes file" << std::endl;
files = cmSystemTools::SplitString(cfiles, ';');
if ( files.size() == 0 )
{
return 1;
}
std::ofstream ofs;
if ( !this->OpenOutputFile(m_CurrentTag, "Notes.xml", ofs) )
{
std::cerr << "Cannot open notes file" << std::endl;
return 1;
}
this->GenerateDartNotesOutput(ofs, files);
return 0;
}
......@@ -137,6 +137,8 @@ public:
CONTINUOUS
};
int GenerateNotesFile(const char* files);
private:
enum {
FIRST_TEST = 0,
......@@ -148,8 +150,9 @@ private:
COVERAGE_TEST = 6,
MEMCHECK_TEST = 7,
SUBMIT_TEST = 8,
ALL_TEST = 9,
LAST_TEST = 10
NOTES_TEST = 9,
ALL_TEST = 10,
LAST_TEST = 11
};
enum { // Program statuses
......@@ -313,6 +316,9 @@ private:
//! End CTest XML output file
void EndXML(std::ostream& ostr);
//! Create not from files.
int GenerateDartNotesOutput(std::ostream& os, const tm_VectorOfStrings& files);
//! Parse Valgrind/Purify/Bounds Checker result out of the output string. After running,
// log holds the output and results hold the different memmory errors.
bool ProcessMemCheckOutput(const std::string& str, std::string& log, int* results);
......
......@@ -79,6 +79,8 @@ static const cmDocumentationEntry cmDocumentationOptions[] =
"ctest will do what is required to create and run a dashboard. This "
"option basically sets up a dashboard and then runs ctest -D with the "
"appropriate options."},
{"-A <Notes file>", "Add a notes file with submission",
"This option tells ctest to include a notes file when submitting dashboard. "},
{0,0,0}
};
......@@ -376,6 +378,16 @@ int main (int argc, char *argv[])
inst.m_ExcludeRegExp = args[i+1];
inst.m_UseExcludeRegExpFirst = inst.m_UseIncludeRegExp ? false : true;
}
if(arg.find("-A",0) == 0 && i < args.size() - 1)
{
inst.m_DartMode = true;
inst.SetTest("Notes");
inst.Initialize();
int ires = inst.GenerateNotesFile(args[i+1].c_str());
inst.Finalize();
return ires;
}
}
// call process directory
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment