ENH: Only look for executable until found

This commit is contained in:
Andy Cedilnik 2004-01-12 13:30:57 -05:00
parent 002679fdba
commit b4bf41434c
2 changed files with 58 additions and 57 deletions

View File

@ -4095,61 +4095,61 @@ int cmCTest::RunCMakeAndTest(std::string* outstring)
else else
{ {
failed.push_back(m_TestCommand); failed.push_back(m_TestCommand);
} std::string tryPath = m_TestCommand;
std::string tryPath = m_TestCommand; tryPath += cmSystemTools::GetExecutableExtension();
tryPath += cmSystemTools::GetExecutableExtension(); if(cmSystemTools::FileExists(tryPath.c_str()))
if(cmSystemTools::FileExists(tryPath.c_str())) {
{ fullPath = cmSystemTools::CollapseFullPath(tryPath.c_str());
fullPath = cmSystemTools::CollapseFullPath(tryPath.c_str()); }
} else
else {
{ failed.push_back(tryPath);
failed.push_back(tryPath); // try the Debug extension
} tryPath = m_ConfigType + "/";
// try the Debug extension tryPath += cmSystemTools::GetFilenameName(m_TestCommand);
tryPath = m_ConfigType + "/"; if(cmSystemTools::FileExists(tryPath.c_str()))
tryPath += cmSystemTools::GetFilenameName(m_TestCommand); {
if(cmSystemTools::FileExists(tryPath.c_str())) fullPath = cmSystemTools::CollapseFullPath(tryPath.c_str());
{ }
fullPath = cmSystemTools::CollapseFullPath(tryPath.c_str()); else
} {
else failed.push_back(tryPath);
{ tryPath += cmSystemTools::GetExecutableExtension();
failed.push_back(tryPath); if(cmSystemTools::FileExists(tryPath.c_str()))
} {
tryPath += cmSystemTools::GetExecutableExtension(); fullPath = cmSystemTools::CollapseFullPath(tryPath.c_str());
if(cmSystemTools::FileExists(tryPath.c_str())) }
{ else
fullPath = cmSystemTools::CollapseFullPath(tryPath.c_str()); {
} failed.push_back(tryPath);
else tryPath = m_ExecutableDirectory;
{ tryPath += "/";
failed.push_back(tryPath); tryPath += m_TestCommand;
} tryPath += cmSystemTools::GetExecutableExtension();
tryPath = m_ExecutableDirectory; if(cmSystemTools::FileExists(tryPath.c_str()))
tryPath += "/"; {
tryPath += m_TestCommand; fullPath = cmSystemTools::CollapseFullPath(tryPath.c_str());
tryPath += cmSystemTools::GetExecutableExtension(); }
if(cmSystemTools::FileExists(tryPath.c_str())) else
{ {
fullPath = cmSystemTools::CollapseFullPath(tryPath.c_str()); failed.push_back(tryPath);
} tryPath = m_ExecutableDirectory;
else tryPath += "/";
{ tryPath += m_ConfigType + "/";
failed.push_back(tryPath); tryPath += m_TestCommand;
} tryPath += cmSystemTools::GetExecutableExtension();
tryPath = m_ExecutableDirectory; if(cmSystemTools::FileExists(tryPath.c_str()))
tryPath += "/"; {
tryPath += m_ConfigType + "/"; fullPath = cmSystemTools::CollapseFullPath(tryPath.c_str());
tryPath += m_TestCommand; }
tryPath += cmSystemTools::GetExecutableExtension(); else
if(cmSystemTools::FileExists(tryPath.c_str())) {
{ failed.push_back(tryPath);
fullPath = cmSystemTools::CollapseFullPath(tryPath.c_str()); }
} }
else }
{ }
failed.push_back(tryPath); }
} }
if(!cmSystemTools::FileExists(fullPath.c_str())) if(!cmSystemTools::FileExists(fullPath.c_str()))
{ {

View File

@ -626,8 +626,9 @@ bool SystemTools::SameFile(const char* file1, const char* file2)
// return true if the file exists // return true if the file exists
bool SystemTools::FileExists(const char* filename) bool SystemTools::FileExists(const char* filename)
{ {
struct stat fs; // struct stat fs;
if (stat(filename, &fs) != 0) // if (stat(filename, &fs) != 0)
if ( access(filename, F_OK) != 0 )
{ {
return false; return false;
} }