summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2003-07-24 14:58:40 (GMT)
committerBrad King <brad.king@kitware.com>2003-07-24 14:58:40 (GMT)
commit08441daded83d314c95016b1a6f7bb047b85e0f2 (patch)
tree9ced40f442855405d882bc06c2a3c494475a314d
parent1a0ca7264885f953a8adbe90ae5d6b9dfdf9142c (diff)
downloadCMake-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.
-rw-r--r--Source/CMakeLists.txt6
-rw-r--r--Source/cmDumpDocumentation.cxx42
-rw-r--r--Tests/CommandLineTest/CMakeLists.txt22
-rw-r--r--Tests/CommandLineTest/CommandLineTest.cxx4
-rw-r--r--Tests/StringFileTest/CMakeLists.txt10
5 files changed, 65 insertions, 19 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
{
diff --git a/Tests/CommandLineTest/CMakeLists.txt b/Tests/CommandLineTest/CMakeLists.txt
new file mode 100644
index 0000000..ebea593
--- /dev/null
+++ b/Tests/CommandLineTest/CMakeLists.txt
@@ -0,0 +1,22 @@
+PROJECT(CommandLineTest)
+
+GET_FILENAME_COMPONENT(CMAKE_BIN_DIR ${CMAKE_COMMAND} PATH)
+FIND_PROGRAM(DUMP_DOC_EXE NAMES DumpDocumentation PATHS ${CMAKE_BIN_DIR})
+
+EXEC_PROGRAM(${CMAKE_COMMAND} ARGS "-E chdir ${CMAKE_CURRENT_SOURCE_DIR} \"${CMAKE_COMMAND} -E echo \\\"Hello World\\\"\"")
+EXEC_PROGRAM(${CMAKE_COMMAND} ARGS "-E time \"${CMAKE_COMMAND} -N -L ${CommandLineTest_SOURCE_DIR}\"")
+EXEC_PROGRAM(${CMAKE_COMMAND} ARGS "-E time \"${CMAKE_COMMAND} -N -LA ${CommandLineTest_SOURCE_DIR}\"")
+EXEC_PROGRAM(${CMAKE_COMMAND} ARGS "-E time \"${CMAKE_COMMAND} -N -LH ${CommandLineTest_SOURCE_DIR}\"")
+EXEC_PROGRAM(${CMAKE_COMMAND} ARGS "-E time \"${CMAKE_COMMAND} -N -LAH ${CommandLineTest_SOURCE_DIR}\"")
+EXEC_PROGRAM(${CMAKE_COMMAND} ARGS "--help")
+EXEC_PROGRAM(${CMAKE_COMMAND} ARGS "--help-full \"${CMAKE_CURRENT_BINARY_DIR}/cmake.txt\"")
+EXEC_PROGRAM(${CMAKE_COMMAND} ARGS "--help-man \"${CMAKE_CURRENT_BINARY_DIR}/cmake.man\"")
+EXEC_PROGRAM(${CMAKE_COMMAND} ARGS "--help-html \"${CMAKE_CURRENT_BINARY_DIR}/cmake.html\"")
+
+IF(DUMP_DOC_EXE)
+ EXEC_PROGRAM(${DUMP_DOC_EXE} ARGS "--all-for-coverage \"${CMAKE_CURRENT_BINARY_DIR}/all_for_coverage.txt\"")
+ELSE(DUMP_DOC_EXE)
+ MESSAGE(SEND_ERROR "Cannot find DumpDocumentation executable.")
+ENDIF(DUMP_DOC_EXE)
+
+ADD_EXECUTABLE(CommandLineTest CommandLineTest.cxx)
diff --git a/Tests/CommandLineTest/CommandLineTest.cxx b/Tests/CommandLineTest/CommandLineTest.cxx
new file mode 100644
index 0000000..f8b643a
--- /dev/null
+++ b/Tests/CommandLineTest/CommandLineTest.cxx
@@ -0,0 +1,4 @@
+int main()
+{
+ return 0;
+}
diff --git a/Tests/StringFileTest/CMakeLists.txt b/Tests/StringFileTest/CMakeLists.txt
index ff17be6..b0030fe 100644
--- a/Tests/StringFileTest/CMakeLists.txt
+++ b/Tests/StringFileTest/CMakeLists.txt
@@ -55,16 +55,6 @@ FOREACH(var
FILE(APPEND "${file}" "#define ${var} \"${${var}}\"\n")
ENDFOREACH(var)
-EXEC_PROGRAM(${CMAKE_COMMAND} ARGS "-E chdir ${CMAKE_CURRENT_SOURCE_DIR} \"${CMAKE_COMMAND} -E echo \\\"Hello World\\\"\"")
-EXEC_PROGRAM(${CMAKE_COMMAND} ARGS "-E time \"${CMAKE_COMMAND} -N -L ${StringFileTest_SOURCE_DIR}\"")
-EXEC_PROGRAM(${CMAKE_COMMAND} ARGS "-E time \"${CMAKE_COMMAND} -N -LA ${StringFileTest_SOURCE_DIR}\"")
-EXEC_PROGRAM(${CMAKE_COMMAND} ARGS "-E time \"${CMAKE_COMMAND} -N -LH ${StringFileTest_SOURCE_DIR}\"")
-EXEC_PROGRAM(${CMAKE_COMMAND} ARGS "-E time \"${CMAKE_COMMAND} -N -LAH ${StringFileTest_SOURCE_DIR}\"")
-EXEC_PROGRAM(${CMAKE_COMMAND} ARGS "--help")
-EXEC_PROGRAM(${CMAKE_COMMAND} ARGS "--help-full \"${CMAKE_CURRENT_BINARY_DIR}/cmake.txt\"")
-EXEC_PROGRAM(${CMAKE_COMMAND} ARGS "--help-man \"${CMAKE_CURRENT_BINARY_DIR}/cmake.man\"")
-EXEC_PROGRAM(${CMAKE_COMMAND} ARGS "--help-html \"${CMAKE_CURRENT_BINARY_DIR}/cmake.html\"")
-
# Write include file to a file
STRING(REGEX REPLACE "includefile" "${file}" outfile "${infile}")
FILE(WRITE "${CMAKE_CURRENT_BINARY_DIR}/OutputFile.h" "${outfile}")