浏览代码

Add configure option and fix potential bug in other targets. Now the run command is actually run with directory, so eventually we should be able to run this from a subdirectory

Andy Cedilnik 23 年之前
父节点
当前提交
350eeeab4e
共有 2 个文件被更改,包括 52 次插入3 次删除
  1. 46 3
      Source/ctest.cxx
  2. 6 0
      Source/ctest.h

+ 46 - 3
Source/ctest.cxx

@@ -143,6 +143,10 @@ bool ctest::SetTest(const char* ttype)
     {
     {
     m_Tests[ctest::UPDATE_TEST] = 1;
     m_Tests[ctest::UPDATE_TEST] = 1;
     }
     }
+  else if ( cmSystemTools::LowerCase(ttype) == "configure" )
+    {
+    m_Tests[ctest::CONFIGURE_TEST] = 1;
+    }
   else if ( cmSystemTools::LowerCase(ttype) == "build" )
   else if ( cmSystemTools::LowerCase(ttype) == "build" )
     {
     {
     m_Tests[ctest::BUILD_TEST] = 1;
     m_Tests[ctest::BUILD_TEST] = 1;
@@ -281,7 +285,7 @@ void ctest::UpdateDirectory()
     }
     }
 
 
   std::string sourceDirectory = m_DartConfiguration["SourceDirectory"];
   std::string sourceDirectory = m_DartConfiguration["SourceDirectory"];
-  if ( cvsOptions.size() == 0 )
+  if ( sourceDirectory.size() == 0 )
     {
     {
     std::cerr << "Cannot find SourceDirectory  key in the DartConfiguration.tcl" << std::endl;
     std::cerr << "Cannot find SourceDirectory  key in the DartConfiguration.tcl" << std::endl;
     return;
     return;
@@ -293,7 +297,34 @@ void ctest::UpdateDirectory()
   int retVal;
   int retVal;
   bool res = cmSystemTools::RunCommand(command.c_str(), output, 
   bool res = cmSystemTools::RunCommand(command.c_str(), output, 
                                        retVal, sourceDirectory.c_str(),
                                        retVal, sourceDirectory.c_str(),
-                                       true);
+                                       m_Verbose);
+  if (! res || retVal )
+    {
+    std::cerr << "Error(s) when updating the project" << std::endl;
+    }
+}
+
+void ctest::ConfigureDirectory()
+{
+  std::string cCommand = m_DartConfiguration["ConfigureCommand"];
+  if ( cCommand.size() == 0 )
+    {
+    std::cerr << "Cannot find ConfigureCommand key in the DartConfiguration.tcl" << std::endl;
+    return;
+    }
+
+  std::string buildDirectory = m_DartConfiguration["BuildDirectory"];
+  if ( buildDirectory.size() == 0 )
+    {
+    std::cerr << "Cannot find BuildDirectory  key in the DartConfiguration.tcl" << std::endl;
+    return;
+    }
+
+  std::string output;
+  int retVal;
+  bool res = cmSystemTools::RunCommand(cCommand.c_str(), output, 
+                                       retVal, buildDirectory.c_str(),
+                                       m_Verbose);
   if (! res || retVal )
   if (! res || retVal )
     {
     {
     std::cerr << "Error(s) when updating the project" << std::endl;
     std::cerr << "Error(s) when updating the project" << std::endl;
@@ -308,10 +339,18 @@ void ctest::BuildDirectory()
     std::cerr << "Cannot find MakeCommand key in the DartConfiguration.tcl" << std::endl;
     std::cerr << "Cannot find MakeCommand key in the DartConfiguration.tcl" << std::endl;
     return;
     return;
     }
     }
+  std::string buildDirectory = m_DartConfiguration["BuildDirectory"];
+  if ( buildDirectory.size() == 0 )
+    {
+    std::cerr << "Cannot find BuildDirectory  key in the DartConfiguration.tcl" << std::endl;
+    return;
+    }
+
   std::string output;
   std::string output;
   int retVal;
   int retVal;
   bool res = cmSystemTools::RunCommand(makeCommand.c_str(), output, 
   bool res = cmSystemTools::RunCommand(makeCommand.c_str(), output, 
-                                       retVal, 0, true);
+                                       retVal, buildDirectory.c_str(), 
+                                       m_Verbose);
   if (! res || retVal )
   if (! res || retVal )
     {
     {
     std::cerr << "Error(s) when building project" << std::endl;
     std::cerr << "Error(s) when building project" << std::endl;
@@ -577,6 +616,10 @@ int ctest::ProcessTests()
     {
     {
     this->UpdateDirectory();
     this->UpdateDirectory();
     }
     }
+  if ( m_Tests[CONFIGURE_TEST] || m_Tests[ALL_TEST] )
+    {
+    this->ConfigureDirectory();
+    }
   if ( m_Tests[BUILD_TEST] || m_Tests[ALL_TEST] )
   if ( m_Tests[BUILD_TEST] || m_Tests[ALL_TEST] )
     {
     {
     this->BuildDirectory();
     this->BuildDirectory();

+ 6 - 0
Source/ctest.h

@@ -49,6 +49,11 @@ public:
    */
    */
   void UpdateDirectory();
   void UpdateDirectory();
 
 
+  /**
+   * Do configure the project
+   */
+  void ConfigureDirectory();
+
   /**
   /**
    * Run the test for a directory and any subdirectories
    * Run the test for a directory and any subdirectories
    */
    */
@@ -90,6 +95,7 @@ private:
   enum {
   enum {
     FIRST_TEST    = 0,
     FIRST_TEST    = 0,
     UPDATE_TEST,
     UPDATE_TEST,
+    CONFIGURE_TEST,
     BUILD_TEST,
     BUILD_TEST,
     TEST_TEST,
     TEST_TEST,
     COVERAGE_TEST,
     COVERAGE_TEST,