diff options
author | Brad King <brad.king@kitware.com> | 2003-07-24 14:58:40 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2003-07-24 14:58:40 (GMT) |
commit | 08441daded83d314c95016b1a6f7bb047b85e0f2 (patch) | |
tree | 9ced40f442855405d882bc06c2a3c494475a314d /Source | |
parent | 1a0ca7264885f953a8adbe90ae5d6b9dfdf9142c (diff) | |
download | CMake-08441daded83d314c95016b1a6f7bb047b85e0f2.zip CMake-08441daded83d314c95016b1a6f7bb047b85e0f2.tar.gz CMake-08441daded83d314c95016b1a6f7bb047b85e0f2.tar.bz2 |
ENH: Added CommandLineTest to add coverage for command line arguments to cmake executables. This replaces the old DumpDocumentation test.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CMakeLists.txt | 6 | ||||
-rw-r--r-- | Source/cmDumpDocumentation.cxx | 42 |
2 files changed, 39 insertions, 9 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 38cafb6..552bbec 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -154,8 +154,10 @@ ADD_EXECUTABLE(cmaketest cmaketest.cxx) TARGET_LINK_LIBRARIES(cmaketest CMakeLib) IF(BUILD_TESTING) - ADD_TEST(DumpDocumentation ${EXECUTABLE_OUTPUT_PATH}/DumpDocumentation - --all-for-coverage) + ADD_TEST(CommandLineTest ${EXECUTABLE_OUTPUT_PATH}/cmaketest + ${CMake_SOURCE_DIR}/Tests/CommandLineTest + ${CMake_BINARY_DIR}/Tests/CommandLineTest + CommandLineTest) ADD_TEST(CustomCommand ${EXECUTABLE_OUTPUT_PATH}/cmaketest ${CMake_SOURCE_DIR}/Tests/CustomCommand diff --git a/Source/cmDumpDocumentation.cxx b/Source/cmDumpDocumentation.cxx index 0b474c4..0155ac2 100644 --- a/Source/cmDumpDocumentation.cxx +++ b/Source/cmDumpDocumentation.cxx @@ -41,7 +41,9 @@ static const cmDocumentationEntry cmDocumentationUsage[] = static const cmDocumentationEntry cmDocumentationDescription[] = { {0, - "CMake reads ... ", 0}, + "The \"DumpDocumentation\" executable is only available in the build " + "tree. It is used for testing, coverage, and documentation.", 0}, + CMAKE_STANDARD_INTRODUCTION, {0,0,0} }; @@ -73,7 +75,7 @@ int DumpHTML(const char* outname) return 0; } -int DumpForCoverage() +int DumpForCoverageToStream(std::ostream& out) { cmake cmi; cmDocumentation doc; @@ -87,13 +89,31 @@ int DumpForCoverage() doc.SetOptionsSection(cmDocumentationOptions); doc.SetCommandsSection(&commands[0]); doc.SetGeneratorsSection(&generators[0]); - doc.PrintDocumentation(cmDocumentation::Usage, std::cout); - doc.PrintDocumentation(cmDocumentation::Full, std::cout); - doc.PrintDocumentation(cmDocumentation::HTML, std::cout); - doc.PrintDocumentation(cmDocumentation::Man, std::cout); + doc.PrintDocumentation(cmDocumentation::Usage, out); + doc.PrintDocumentation(cmDocumentation::Full, out); + doc.PrintDocumentation(cmDocumentation::HTML, out); + doc.PrintDocumentation(cmDocumentation::Man, out); return 0; } +int DumpForCoverage(const char* outname) +{ + if(outname) + { + std::ofstream fout(outname); + if(!fout) + { + std::cerr << "failed to open output file: " << outname << "\n"; + return -1; + } + return DumpForCoverageToStream(fout); + } + else + { + return DumpForCoverageToStream(std::cout); + } +} + int main(int ac, char** av) { cmSystemTools::EnableMSVCDebugHook(); @@ -104,6 +124,14 @@ int main(int ac, char** av) if(strcmp(av[1], "--all-for-coverage") == 0) { coverage = true; + if(ac > 2) + { + outname = av[2]; + } + else + { + outname = 0; + } } else { @@ -113,7 +141,7 @@ int main(int ac, char** av) if(coverage) { - return DumpForCoverage(); + return DumpForCoverage(outname); } else { |