浏览代码

ENH: make sure tests that are not run fail, and make sure that it does not try to run directories with the same name as tests

Bill Hoffman 22 年之前
父节点
当前提交
4d082d4215
共有 1 个文件被更改,包括 19 次插入7 次删除
  1. 19 7
      Source/cmCTest.cxx

+ 19 - 7
Source/cmCTest.cxx

@@ -4104,7 +4104,8 @@ int cmCTest::RunCMakeAndTest(std::string* outstring)
   // See if the executable exists as written.
   // See if the executable exists as written.
   std::vector<std::string> failed;
   std::vector<std::string> failed;
   std::string fullPath;
   std::string fullPath;
-  if(cmSystemTools::FileExists(m_TestCommand.c_str()))
+  if(cmSystemTools::FileExists(m_TestCommand.c_str())
+    && !cmSystemTools::FileIsDirectory(m_TestCommand.c_str()))
     {
     {
     fullPath = cmSystemTools::CollapseFullPath(m_TestCommand.c_str());
     fullPath = cmSystemTools::CollapseFullPath(m_TestCommand.c_str());
     }
     }
@@ -4113,7 +4114,8 @@ int cmCTest::RunCMakeAndTest(std::string* outstring)
     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())
+       && !cmSystemTools::FileIsDirectory(tryPath.c_str()))
       {
       {
       fullPath = cmSystemTools::CollapseFullPath(tryPath.c_str());
       fullPath = cmSystemTools::CollapseFullPath(tryPath.c_str());
       }
       }
@@ -4123,7 +4125,8 @@ int cmCTest::RunCMakeAndTest(std::string* outstring)
       // try the Debug extension
       // try the Debug extension
       tryPath = m_ConfigType + "/";
       tryPath = m_ConfigType + "/";
       tryPath += cmSystemTools::GetFilenameName(m_TestCommand);
       tryPath += cmSystemTools::GetFilenameName(m_TestCommand);
-      if(cmSystemTools::FileExists(tryPath.c_str()))
+      if(cmSystemTools::FileExists(tryPath.c_str())
+         && !cmSystemTools::FileIsDirectory(tryPath.c_str()))
         {
         {
         fullPath = cmSystemTools::CollapseFullPath(tryPath.c_str());
         fullPath = cmSystemTools::CollapseFullPath(tryPath.c_str());
         }
         }
@@ -4131,7 +4134,8 @@ int cmCTest::RunCMakeAndTest(std::string* outstring)
         {
         {
         failed.push_back(tryPath);
         failed.push_back(tryPath);
         tryPath += cmSystemTools::GetExecutableExtension();
         tryPath += cmSystemTools::GetExecutableExtension();
-        if(cmSystemTools::FileExists(tryPath.c_str()))
+        if(cmSystemTools::FileExists(tryPath.c_str())
+           && !cmSystemTools::FileIsDirectory(tryPath.c_str()))
           {
           {
           fullPath = cmSystemTools::CollapseFullPath(tryPath.c_str());
           fullPath = cmSystemTools::CollapseFullPath(tryPath.c_str());
           }
           }
@@ -4142,7 +4146,8 @@ int cmCTest::RunCMakeAndTest(std::string* outstring)
           tryPath += "/";
           tryPath += "/";
           tryPath += m_TestCommand;
           tryPath += m_TestCommand;
           tryPath += cmSystemTools::GetExecutableExtension();
           tryPath += cmSystemTools::GetExecutableExtension();
-          if(cmSystemTools::FileExists(tryPath.c_str()))
+          if(cmSystemTools::FileExists(tryPath.c_str())
+             && !cmSystemTools::FileIsDirectory(tryPath.c_str()))
             {
             {
             fullPath = cmSystemTools::CollapseFullPath(tryPath.c_str());
             fullPath = cmSystemTools::CollapseFullPath(tryPath.c_str());
             }
             }
@@ -4154,7 +4159,8 @@ int cmCTest::RunCMakeAndTest(std::string* outstring)
             tryPath += m_ConfigType + "/";
             tryPath += m_ConfigType + "/";
             tryPath += m_TestCommand;
             tryPath += m_TestCommand;
             tryPath += cmSystemTools::GetExecutableExtension();
             tryPath += cmSystemTools::GetExecutableExtension();
-            if(cmSystemTools::FileExists(tryPath.c_str()))
+            if(cmSystemTools::FileExists(tryPath.c_str())
+               && !cmSystemTools::FileIsDirectory(tryPath.c_str()))
               {
               {
               fullPath = cmSystemTools::CollapseFullPath(tryPath.c_str());
               fullPath = cmSystemTools::CollapseFullPath(tryPath.c_str());
               }
               }
@@ -4210,7 +4216,13 @@ int cmCTest::RunCMakeAndTest(std::string* outstring)
     out << m_TestCommandArgs[k] << " ";
     out << m_TestCommandArgs[k] << " ";
     }
     }
   out << "\n";
   out << "\n";
-  this->RunTest(testCommand, &outs, &retval);
+  int runTestRes = this->RunTest(testCommand, &outs, &retval);
+  if(runTestRes != cmsysProcess_State_Exited || retval != 0)
+    {
+    out << "Test failed to run.\n";
+    retval = 1;
+    }
+   
   out << outs << "\n";
   out << outs << "\n";
   if(outstring)
   if(outstring)
     {
     {