diff options
author | Justin Goshi <jgoshi@microsoft.com> | 2018-10-18 18:34:37 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-01-10 12:37:32 (GMT) |
commit | fc41a95f0803abb2b5daa4f0eb21cf38c625bd26 (patch) | |
tree | bcb027bb2f3a2bfe453b78b7a82a2c2c420fc833 /Source/cmCTest.cxx | |
parent | 7b81d8c21e0a0d8756f0afdc0530c2d06ee3bcd4 (diff) | |
download | CMake-fc41a95f0803abb2b5daa4f0eb21cf38c625bd26.zip CMake-fc41a95f0803abb2b5daa4f0eb21cf38c625bd26.tar.gz CMake-fc41a95f0803abb2b5daa4f0eb21cf38c625bd26.tar.bz2 |
CTest: Add --show-only[=format] option to print test info
format can be 'human' to print the current text format or 'json-v1' to
print the test object model in json format and is useful for IDEs who
want to gather information about the tests. Defaults to 'human' format.
Diffstat (limited to 'Source/cmCTest.cxx')
-rw-r--r-- | Source/cmCTest.cxx | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 7c19864..225c99f 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -278,6 +278,8 @@ cmCTest::cmCTest() this->ExtraVerbose = false; this->ProduceXML = false; this->ShowOnly = false; + this->OutputAsJson = false; + this->OutputAsJsonVersion = 1; this->RunConfigurationScript = false; this->UseHTTP10 = false; this->PrintLabels = false; @@ -1930,6 +1932,20 @@ bool cmCTest::HandleCommandLineArguments(size_t& i, if (this->CheckArgument(arg, "-N", "--show-only")) { this->ShowOnly = true; } + if (cmSystemTools::StringStartsWith(arg.c_str(), "--show-only=")) { + this->ShowOnly = true; + + // Check if a specific format is requested. Defaults to human readable + // text. + std::string argWithFormat = "--show-only="; + std::string format = arg.substr(argWithFormat.length()); + if (format == "json-v1") { + // Force quiet mode so the only output is the json object model. + this->Quiet = true; + this->OutputAsJson = true; + this->OutputAsJsonVersion = 1; + } + } if (this->CheckArgument(arg, "-O", "--output-log") && i < args.size() - 1) { i++; @@ -2630,6 +2646,16 @@ bool cmCTest::GetShowOnly() return this->ShowOnly; } +bool cmCTest::GetOutputAsJson() +{ + return this->OutputAsJson; +} + +int cmCTest::GetOutputAsJsonVersion() +{ + return this->OutputAsJsonVersion; +} + int cmCTest::GetMaxTestNameWidth() const { return this->MaxTestNameWidth; |