diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2001-08-23 21:40:07 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2001-08-23 21:40:07 (GMT) |
commit | a4f40c31f1e160ab34d90c1a5e9ed5ab6cc1de59 (patch) | |
tree | 554853021dba4b552bb22235b2f9a15a662fc989 | |
parent | 852be8a520a8a03268b499642c5257675b9ad7f2 (diff) | |
download | CMake-a4f40c31f1e160ab34d90c1a5e9ed5ab6cc1de59.zip CMake-a4f40c31f1e160ab34d90c1a5e9ed5ab6cc1de59.tar.gz CMake-a4f40c31f1e160ab34d90c1a5e9ed5ab6cc1de59.tar.bz2 |
ENH: add dump documentation test
-rw-r--r-- | Source/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Source/cmDumpDocumentation.cxx | 16 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 9 | ||||
-rw-r--r-- | Source/cmMakefile.h | 2 |
4 files changed, 18 insertions, 12 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 1eb94ff..84d5042 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -53,6 +53,7 @@ LINK_LIBRARIES(CMakeLib) LINK_DIRECTORIES(${CMake_BINARY_DIR}/Sources) ADD_EXECUTABLE(cmake cmakemain) +ADD_EXECUTABLE(DumpDocumentation cmDumpDocumentation) ADD_EXECUTABLE(ctest ctest.cxx cmSystemTools.cxx cmRegularExpression.cxx) @@ -66,6 +67,8 @@ IF(BUILD_TESTING) CONFIGURE_FILE( ${CMake_SOURCE_DIR}/Source/cmaketest.h.in ${CMake_BINARY_DIR}/Source/cmaketest.h ESCAPE_QUOTES) + ADD_TEST(DumpDocumentation ${CMake_BINARY_DIR}/Source/DumpDocumentation + ${CMake_BINARY_DIR}/CMakeDoc.html ) ADD_TEST(simple ${CMake_BINARY_DIR}/Source/cmaketest ${CMake_SOURCE_DIR}/Tests/Simple ${CMake_BINARY_DIR}/Tests/Simple simple ) diff --git a/Source/cmDumpDocumentation.cxx b/Source/cmDumpDocumentation.cxx index 51db267..77771dd 100644 --- a/Source/cmDumpDocumentation.cxx +++ b/Source/cmDumpDocumentation.cxx @@ -3,10 +3,20 @@ // #include "cmMakefile.h" -int main() +int main(int ac, char** av) { cmMakefile makefile; - makefile.DumpDocumentationToFile("cmake.txt"); - + const char* outname = "cmake.html"; + if(ac > 1) + { + outname = av[1]; + } + std::ofstream fout(outname); + if(!fout) + { + std::cerr << "failed to open output file: " << outname << "\n"; + return -1; + } + makefile.DumpDocumentationToFile(fout); return 0; } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 9dd92e8..ee27f58 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -797,16 +797,9 @@ const char* cmMakefile::GetDefinition(const char* name) return cmCacheManager::GetInstance()->GetCacheValue(name); } -int cmMakefile::DumpDocumentationToFile(const char *fileName) +int cmMakefile::DumpDocumentationToFile(std::ostream& f) { // Open the supplied filename - std::ofstream f; - f.open(fileName, std::ios::out); - - if ( f.fail() ) - { - return 0; - } // Loop over all registered commands and print out documentation const char *name; diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index c5363d6..5146f8f 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -487,7 +487,7 @@ public: * Dump documentation to a file. If 0 is returned, the * operation failed. */ - int DumpDocumentationToFile(const char *fileName); + int DumpDocumentationToFile(std::ostream&); /** * Expand all defined varibles in the string. |