瀏覽代碼

ENH: add max width option to ctest ouptut

Bill Hoffman 17 年之前
父節點
當前提交
43fe0d3978
共有 4 個文件被更改,包括 26 次插入4 次删除
  1. 3 2
      Source/CTest/cmCTestTestHandler.cxx
  2. 12 0
      Source/cmCTest.cxx
  3. 7 1
      Source/cmCTest.h
  4. 4 1
      Source/ctest.cxx

+ 3 - 2
Source/CTest/cmCTestTestHandler.cxx

@@ -644,8 +644,9 @@ void cmCTestTestHandler::ProcessOneTest(cmCTestTestProperties *it,
     cmCTestLog(this->CTest, HANDLER_OUTPUT, "Testing");
     }
   cmCTestLog(this->CTest, HANDLER_OUTPUT, " ");
-  std::string outname = testname;
-  outname.resize(30, ' ');
+  const int maxTestNameWidth = this->CTest->GetMaxTestNameWidth();
+  std::string outname = testname + " ";
+  outname.resize(maxTestNameWidth, '.');
   *this->LogFile << cnt << "/" << tmsize << " Testing: " << testname
                  << std::endl;
   

+ 12 - 0
Source/cmCTest.cxx

@@ -249,6 +249,7 @@ cmCTest::cmCTest()
   this->ShowOnly               = false;
   this->RunConfigurationScript = false;
   this->TestModel              = cmCTest::EXPERIMENTAL;
+  this->MaxTestNameWidth       = 30;
   this->InteractiveDebugMode   = true;
   this->TimeOut                = 0;
   this->CompressXMLFiles       = false;
@@ -1721,6 +1722,11 @@ void cmCTest::HandleCommandLineArguments(size_t &i,
     {
     this->ForceNewCTestProcess = true;
     }
+  if(this->CheckArgument(arg, "-W", "--max-width") && i < args.size() - 1)
+    {
+    i++;
+    this->MaxTestNameWidth = atoi(args[i].c_str());
+    }
   if(this->CheckArgument(arg, "--interactive-debug-mode") &&
      i < args.size() - 1 )
     {
@@ -2309,6 +2315,12 @@ bool cmCTest::GetShowOnly()
   return this->ShowOnly;
 }
 
+//----------------------------------------------------------------------
+int cmCTest::GetMaxTestNameWidth() const
+{
+  return this->MaxTestNameWidth;
+}
+
 //----------------------------------------------------------------------
 void cmCTest::SetProduceXML(bool v)
 {

+ 7 - 1
Source/cmCTest.h

@@ -168,7 +168,11 @@ public:
   ///! Should we only show what we would do?
   bool GetShowOnly();
 
-   /**
+
+  ///! The max output width
+  int GetMaxTestNameWidth() const;
+
+  /**
    * Run a single executable command and put the stdout and stderr
    * in output.
    *
@@ -373,6 +377,8 @@ private:
 
   double                  TimeOut;
 
+  int                     MaxTestNameWidth;
+
   std::string             ParallelCacheFile;
   int                     ParallelLevel;
   int                     ParallelSubprocessId;

+ 4 - 1
Source/ctest.cxx

@@ -128,8 +128,11 @@ static const char * cmDocumentationOptions[][3] =
   {"-U, --union", "Take the Union of -I and -R",
    "When both -R and -I are specified by default the intersection of "
    "tests are run. By specifying -U the union of tests is run instead."},
+  {"--max-width <width>", "Set the max width for a test name to output",
+   "Set the maximum width for each test name to show in the output.  This "
+   "allows the user to widen the output to avoid cliping the test name which "
+   "can be very annoying."},
   {"--interactive-debug-mode [0|1]", "Set the interactive mode to 0 or 1.",
-
    "This option causes ctest to run tests in either an interactive mode or "
    "a non-interactive mode. On Windows this means that in non-interactive "
    "mode, all system debug pop up windows are blocked. In dashboard mode "