ENH: More ctest changes and move SetupTest to superclass

This commit is contained in:
Andy Cedilnik 2005-04-01 15:48:46 -05:00
parent 6cd36d16e5
commit 86cebea79a
10 changed files with 99 additions and 130 deletions

View File

@ -44,7 +44,7 @@ void cmAddTestCommand::FinalPass()
std::string fname; std::string fname;
fname = m_Makefile->GetStartOutputDirectory(); fname = m_Makefile->GetStartOutputDirectory();
fname += "/"; fname += "/";
if ( m_Makefile->IsOn("DART_ROOT") ) if ( m_Makefile->IsSet("DART_ROOT") )
{ {
fname += "DartTestfile.txt"; fname += "DartTestfile.txt";
} }

View File

@ -37,7 +37,7 @@ void cmEnableTestingCommand::CreateDartTestfileForMakefile(cmMakefile *mf)
std::string fname; std::string fname;
fname = mf->GetStartOutputDirectory(); fname = mf->GetStartOutputDirectory();
fname += "/"; fname += "/";
if ( m_Makefile->IsOn("DART_ROOT") ) if ( m_Makefile->IsSet("DART_ROOT") )
{ {
fname += "DartTestfile.txt"; fname += "DartTestfile.txt";
} }

View File

@ -989,3 +989,77 @@ cmGlobalGenerator::ConvertToRelativePath(const std::vector<std::string>& local,
return relative; return relative;
} }
inline std::string removeQuotes(const std::string& s)
{
if(s[0] == '\"' && s[s.size()-1] == '\"')
{
return s.substr(1, s.size()-2);
}
return s;
}
void cmGlobalGenerator::SetupTests()
{
std::string ctest =
m_LocalGenerators[0]->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND");
ctest = removeQuotes(ctest);
ctest = cmSystemTools::GetFilenamePath(ctest.c_str());
ctest += "/";
ctest += "ctest";
ctest += cmSystemTools::GetExecutableExtension();
if(!cmSystemTools::FileExists(ctest.c_str()))
{
ctest =
m_LocalGenerators[0]->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND");
ctest = cmSystemTools::GetFilenamePath(ctest.c_str());
ctest += "/Debug/";
ctest += "ctest";
ctest += cmSystemTools::GetExecutableExtension();
}
if(!cmSystemTools::FileExists(ctest.c_str()))
{
ctest =
m_LocalGenerators[0]->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND");
ctest = cmSystemTools::GetFilenamePath(ctest.c_str());
ctest += "/Release/";
ctest += "ctest";
ctest += cmSystemTools::GetExecutableExtension();
}
// if we found ctest
if (cmSystemTools::FileExists(ctest.c_str()))
{
// Create a full path filename for output Testfile
std::string fname;
fname = m_CMakeInstance->GetStartOutputDirectory();
fname += "/";
if ( m_LocalGenerators[0]->GetMakefile()->IsSet("DART_ROOT") )
{
fname += "DartTestfile.txt";
}
else
{
fname += "CTestTestfile.txt";
}
// If the file doesn't exist, then ENABLE_TESTING hasn't been run
if (cmSystemTools::FileExists(fname.c_str()))
{
const char* no_output = 0;
std::vector<std::string> no_depends;
std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
for(it = m_ProjectMap.begin(); it!= m_ProjectMap.end(); ++it)
{
std::vector<cmLocalGenerator*>& gen = it->second;
// add the ALL_BUILD to the first local generator of each project
if(gen.size())
{
gen[0]->GetMakefile()->
AddUtilityCommand("RUN_TESTS", false, no_output, no_depends,
ctest.c_str(), "-C", "$(IntDir)");
}
}
}
}
}

View File

@ -142,6 +142,7 @@ protected:
void FindMakeProgram(cmMakefile*); void FindMakeProgram(cmMakefile*);
void ConfigureRelativePaths(); void ConfigureRelativePaths();
void SetupTests();
bool m_ForceUnixPaths; bool m_ForceUnixPaths;
cmStdString m_FindMakeProgramFile; cmStdString m_FindMakeProgramFile;

View File

@ -371,75 +371,6 @@ void cmGlobalVisualStudio6Generator::OutputDSWFile()
} }
} }
inline std::string removeQuotes(const std::string& s)
{
if(s[0] == '\"' && s[s.size()-1] == '\"')
{
return s.substr(1, s.size()-2);
}
return s;
}
void cmGlobalVisualStudio6Generator::SetupTests()
{
std::string ctest =
m_LocalGenerators[0]->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND");
ctest = removeQuotes(ctest);
ctest = cmSystemTools::GetFilenamePath(ctest.c_str());
ctest += "/";
ctest += "ctest";
ctest += cmSystemTools::GetExecutableExtension();
if(!cmSystemTools::FileExists(ctest.c_str()))
{
ctest =
m_LocalGenerators[0]->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND");
ctest = cmSystemTools::GetFilenamePath(ctest.c_str());
ctest += "/Debug/";
ctest += "ctest";
ctest += cmSystemTools::GetExecutableExtension();
}
if(!cmSystemTools::FileExists(ctest.c_str()))
{
ctest =
m_LocalGenerators[0]->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND");
ctest = cmSystemTools::GetFilenamePath(ctest.c_str());
ctest += "/Release/";
ctest += "ctest";
ctest += cmSystemTools::GetExecutableExtension();
}
// if we found ctest
if (cmSystemTools::FileExists(ctest.c_str()))
{
// Create a full path filename for output Testfile
std::string fname;
fname = m_CMakeInstance->GetStartOutputDirectory();
fname += "/";
fname += "DartTestfile.txt";
// If the file doesn't exist, then ENABLE_TESTING hasn't been run
if (cmSystemTools::FileExists(fname.c_str()))
{
const char* no_output = 0;
std::vector<std::string> no_depends;
std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
for(it = m_ProjectMap.begin(); it!= m_ProjectMap.end(); ++it)
{
std::vector<cmLocalGenerator*>& gen = it->second;
// add the ALL_BUILD to the first local generator of each project
if(gen.size())
{
gen[0]->GetMakefile()->
AddUtilityCommand("RUN_TESTS", false, no_output, no_depends,
ctest.c_str(), "-C", "$(IntDir)");
}
}
}
}
}
// Write a dsp file into the DSW file, // Write a dsp file into the DSW file,
// Note, that dependencies from executables to // Note, that dependencies from executables to
// the libraries it uses are also done here // the libraries it uses are also done here

View File

@ -78,7 +78,6 @@ public:
std::vector<cmLocalGenerator*>& generators); std::vector<cmLocalGenerator*>& generators);
private: private:
void GenerateConfigurations(cmMakefile* mf); void GenerateConfigurations(cmMakefile* mf);
void SetupTests();
void WriteDSWFile(std::ostream& fout); void WriteDSWFile(std::ostream& fout);
void WriteDSWHeader(std::ostream& fout); void WriteDSWHeader(std::ostream& fout);
void WriteProject(std::ostream& fout, void WriteProject(std::ostream& fout,

View File

@ -128,63 +128,6 @@ cmLocalGenerator *cmGlobalVisualStudio7Generator::CreateLocalGenerator()
return lg; return lg;
} }
void cmGlobalVisualStudio7Generator::SetupTests()
{
std::string ctest =
m_LocalGenerators[0]->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND");
ctest = cmSystemTools::GetFilenamePath(ctest.c_str());
ctest += "/";
ctest += "ctest";
ctest += cmSystemTools::GetExecutableExtension();
if(!cmSystemTools::FileExists(ctest.c_str()))
{
ctest =
m_LocalGenerators[0]->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND");
ctest = cmSystemTools::GetFilenamePath(ctest.c_str());
ctest += "/Debug/";
ctest += "ctest";
ctest += cmSystemTools::GetExecutableExtension();
}
if(!cmSystemTools::FileExists(ctest.c_str()))
{
ctest =
m_LocalGenerators[0]->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND");
ctest = cmSystemTools::GetFilenamePath(ctest.c_str());
ctest += "/Release/";
ctest += "ctest";
ctest += cmSystemTools::GetExecutableExtension();
}
// if we found ctest
if (cmSystemTools::FileExists(ctest.c_str()))
{
// Create a full path filename for output Testfile
std::string fname;
fname = m_CMakeInstance->GetStartOutputDirectory();
fname += "/";
fname += "DartTestfile.txt";
// If the file doesn't exist, then ENABLE_TESTING hasn't been run
if (cmSystemTools::FileExists(fname.c_str()))
{
const char* no_output = 0;
std::vector<std::string> no_depends;
std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
for(it = m_ProjectMap.begin(); it!= m_ProjectMap.end(); ++it)
{
std::vector<cmLocalGenerator*>& gen = it->second;
// add the ALL_BUILD to the first local generator of each project
if(gen.size())
{
gen[0]->GetMakefile()->
AddUtilityCommand("RUN_TESTS", false, no_output, no_depends,
ctest.c_str(), "-C", "$(IntDir)");
}
}
}
}
}
void cmGlobalVisualStudio7Generator::GenerateConfigurations(cmMakefile* mf) void cmGlobalVisualStudio7Generator::GenerateConfigurations(cmMakefile* mf)
{ {
// process the configurations // process the configurations

View File

@ -97,7 +97,6 @@ protected:
virtual void WriteSLNFooter(std::ostream& fout); virtual void WriteSLNFooter(std::ostream& fout);
virtual void WriteSLNHeader(std::ostream& fout); virtual void WriteSLNHeader(std::ostream& fout);
void SetupTests();
void GenerateConfigurations(cmMakefile* mf); void GenerateConfigurations(cmMakefile* mf);
void WriteExternalProject(std::ostream& fout, void WriteExternalProject(std::ostream& fout,

View File

@ -1232,6 +1232,27 @@ bool cmMakefile::IsOn(const char* name) const
return cmSystemTools::IsOn(value); return cmSystemTools::IsOn(value);
} }
bool cmMakefile::IsSet(const char* name) const
{
const char* value = this->GetDefinition(name);
if ( !value )
{
return false;
}
if ( ! *value )
{
return false;
}
if ( cmSystemTools::IsNOTFOUND(value) )
{
return false;
}
return true;
}
const char* cmMakefile::GetRequiredDefinition(const char* name) const const char* cmMakefile::GetRequiredDefinition(const char* name) const
{ {
const char* ret = this->GetDefinition(name); const char* ret = this->GetDefinition(name);

View File

@ -496,6 +496,7 @@ public:
* returns false if no entry defined. * returns false if no entry defined.
*/ */
bool IsOn(const char* name) const; bool IsOn(const char* name) const;
bool IsSet(const char* name) const;
/** /**
* Get a list of preprocessor define flags. * Get a list of preprocessor define flags.