summaryrefslogtreecommitdiffstats
path: root/Source/kwsys
diff options
context:
space:
mode:
authorAndy Cedilnik <andy.cedilnik@kitware.com>2005-04-13 17:57:24 (GMT)
committerAndy Cedilnik <andy.cedilnik@kitware.com>2005-04-13 17:57:24 (GMT)
commit4a390c174cb4e96963b0f1392828f1f1da70c61f (patch)
tree43f038f99605da1ef3221b61cee70d0f6dec35db /Source/kwsys
parent3778d89cb907b9283c86a0e74be8dd4b9118ba5e (diff)
downloadCMake-4a390c174cb4e96963b0f1392828f1f1da70c61f.zip
CMake-4a390c174cb4e96963b0f1392828f1f1da70c61f.tar.gz
CMake-4a390c174cb4e96963b0f1392828f1f1da70c61f.tar.bz2
ENH: Do kwsys testing as part of cmake testing, command line arguments are not experimental and add simple test for systemtools
Diffstat (limited to 'Source/kwsys')
-rw-r--r--Source/kwsys/CMakeLists.txt63
-rw-r--r--Source/kwsys/Configure.hxx.in1
-rw-r--r--Source/kwsys/Process.h.in4
-rw-r--r--Source/kwsys/ProcessUNIX.c1
-rw-r--r--Source/kwsys/ProcessWin32.c1
-rw-r--r--Source/kwsys/test1.cxx7
-rw-r--r--Source/kwsys/testCommandLineArguments.cxx5
-rw-r--r--Source/kwsys/testIOS.cxx7
-rw-r--r--Source/kwsys/testProcess.c3
-rw-r--r--Source/kwsys/testSystemTools.cxx64
-rw-r--r--Source/kwsys/testhash.cxx8
11 files changed, 117 insertions, 47 deletions
diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt
index 6d14b80..7787933 100644
--- a/Source/kwsys/CMakeLists.txt
+++ b/Source/kwsys/CMakeLists.txt
@@ -70,6 +70,9 @@
IF(NOT KWSYS_NAMESPACE)
SET(KWSYS_NAMESPACE "kwsys")
SET(KWSYS_STANDALONE 1)
+ENDIF(NOT KWSYS_NAMESPACE)
+
+IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
SET(KWSYS_ENABLE_C 1)
# Enable all components.
@@ -79,7 +82,7 @@ IF(NOT KWSYS_NAMESPACE)
SET(KWSYS_USE_RegularExpression 1)
SET(KWSYS_USE_SystemTools 1)
SET(KWSYS_USE_CommandLineArguments 1)
-ENDIF(NOT KWSYS_NAMESPACE)
+ENDIF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
#-----------------------------------------------------------------------------
# The project name is that of the specified namespace.
@@ -87,7 +90,7 @@ PROJECT(${KWSYS_NAMESPACE})
# Enable testing if building standalone.
IF(KWSYS_STANDALONE)
- INCLUDE(${CMAKE_ROOT}/Modules/Dart.cmake)
+ INCLUDE(Dart)
MARK_AS_ADVANCED(BUILD_TESTING DART_ROOT TCL_TCLSH)
IF(BUILD_TESTING)
ENABLE_TESTING()
@@ -300,16 +303,6 @@ FOREACH(c Directory RegularExpression SystemTools CommandLineArguments)
ENDIF(KWSYS_USE_${c})
ENDFOREACH(c)
-IF(KWSYS_USE_CommandLineArguments)
- IF(NOT ParaView_SOURCE_DIR)
- IF(NOT CMake_SOURCE_DIR)
- IF(NOT KWSYS_STANDALONE)
- MESSAGE("Command Line Arguments is experimental code for now")
- ENDIF(NOT KWSYS_STANDALONE)
- ENDIF(NOT CMake_SOURCE_DIR)
- ENDIF(NOT ParaView_SOURCE_DIR)
-ENDIF(KWSYS_USE_CommandLineArguments)
-
# Add selected C components.
FOREACH(c Process Base64)
IF(KWSYS_USE_${c})
@@ -463,17 +456,25 @@ ENDIF(KWSYS_USE_Process)
#-----------------------------------------------------------------------------
# Setup testing if not being built as part of another project.
-IF(KWSYS_STANDALONE)
- ADD_EXECUTABLE(testIOS testIOS.cxx)
- ADD_EXECUTABLE(testhash testhash.cxx)
- ADD_EXECUTABLE(testProcess testProcess.c)
- ADD_EXECUTABLE(test1 test1.cxx)
- ADD_EXECUTABLE(testCommandLineArguments testCommandLineArguments.cxx)
- TARGET_LINK_LIBRARIES(testIOS ${KWSYS_NAMESPACE})
- TARGET_LINK_LIBRARIES(testhash ${KWSYS_NAMESPACE})
- TARGET_LINK_LIBRARIES(testProcess ${KWSYS_NAMESPACE}_c)
- TARGET_LINK_LIBRARIES(test1 ${KWSYS_NAMESPACE})
- TARGET_LINK_LIBRARIES(testCommandLineArguments ${KWSYS_NAMESPACE})
+IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
+ # C++ tests
+ FOREACH(test
+ testSystemTools
+ testIOS
+ testhash
+ test1
+ testCommandLineArguments
+ )
+ ADD_EXECUTABLE(${test} ${test}.cxx)
+ TARGET_LINK_LIBRARIES(${test} ${KWSYS_NAMESPACE})
+ ENDFOREACH(test)
+ # C tests
+ FOREACH(test
+ testProcess
+ )
+ ADD_EXECUTABLE(${test} ${test}.c)
+ TARGET_LINK_LIBRARIES(${test} ${KWSYS_NAMESPACE}_c)
+ ENDFOREACH(test)
SET(EXEC_DIR "${CMAKE_CURRENT_BINARY_DIR}")
IF(EXECUTABLE_OUTPUT_PATH)
@@ -481,11 +482,13 @@ IF(KWSYS_STANDALONE)
ENDIF(EXECUTABLE_OUTPUT_PATH)
IF(BUILD_TESTING)
- ADD_TEST(testProcess-1 ${EXEC_DIR}/testProcess 1)
- ADD_TEST(testProcess-2 ${EXEC_DIR}/testProcess 2)
- ADD_TEST(testProcess-3 ${EXEC_DIR}/testProcess 3)
- ADD_TEST(testProcess-4 ${EXEC_DIR}/testProcess 4)
- ADD_TEST(testProcess-5 ${EXEC_DIR}/testProcess 5)
- ADD_TEST(testProcess-6 ${EXEC_DIR}/testProcess 6)
+ ADD_TEST(kwsys-testSystemTools ${EXEC_DIR}/testSystemTools)
+ ADD_TEST(kwsys-testProcess-1 ${EXEC_DIR}/testProcess 1)
+ ADD_TEST(kwsys-testProcess-2 ${EXEC_DIR}/testProcess 2)
+ ADD_TEST(kwsys-testProcess-3 ${EXEC_DIR}/testProcess 3)
+ ADD_TEST(kwsys-testProcess-4 ${EXEC_DIR}/testProcess 4)
+ ADD_TEST(kwsys-testProcess-5 ${EXEC_DIR}/testProcess 5)
+ ADD_TEST(kwsys-testProcess-6 ${EXEC_DIR}/testProcess 6)
+ ADD_TEST(kwsys-hash ${EXEC_DIR}/testhash)
ENDIF(BUILD_TESTING)
-ENDIF(KWSYS_STANDALONE)
+ENDIF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
diff --git a/Source/kwsys/Configure.hxx.in b/Source/kwsys/Configure.hxx.in
index 3cf75da..13d3a97 100644
--- a/Source/kwsys/Configure.hxx.in
+++ b/Source/kwsys/Configure.hxx.in
@@ -105,6 +105,7 @@
# if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
# define kwsys_stl @KWSYS_NAMESPACE@_stl
# define kwsys_ios @KWSYS_NAMESPACE@_ios
+# define kwsys @KWSYS_NAMESPACE@
# endif
# define KWSYS_NAME_IS_KWSYS @KWSYS_NAMESPACE@_NAME_IS_KWSYS
# define KWSYS_STL_HAVE_STD @KWSYS_NAMESPACE@_STL_HAVE_STD
diff --git a/Source/kwsys/Process.h.in b/Source/kwsys/Process.h.in
index 380d1b4..bd61086 100644
--- a/Source/kwsys/Process.h.in
+++ b/Source/kwsys/Process.h.in
@@ -322,9 +322,9 @@ kwsysEXPORT void kwsysProcess_Kill(kwsysProcess* cp);
} /* extern "C" */
#endif
-/* If we are building a kwsysProcess .c file, let it use these macros.
+/* If we are building a kwsys .c or .cxx file, let it use these macros.
Otherwise, undefine them to keep the namespace clean. */
-#if !defined(KWSYS_IN_PROCESS_C)
+#if !defined(KWSYS_NAMESPACE)
# undef kwsys_ns
# undef kwsysEXPORT
# undef kwsysProcess
diff --git a/Source/kwsys/ProcessUNIX.c b/Source/kwsys/ProcessUNIX.c
index 6900906..c36a137 100644
--- a/Source/kwsys/ProcessUNIX.c
+++ b/Source/kwsys/ProcessUNIX.c
@@ -11,7 +11,6 @@
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
-#define KWSYS_IN_PROCESS_C
#include "kwsysPrivate.h"
#include KWSYS_HEADER(Process.h)
diff --git a/Source/kwsys/ProcessWin32.c b/Source/kwsys/ProcessWin32.c
index 538f4b4..7175d1b 100644
--- a/Source/kwsys/ProcessWin32.c
+++ b/Source/kwsys/ProcessWin32.c
@@ -11,7 +11,6 @@
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
-#define KWSYS_IN_PROCESS_C
#include "kwsysPrivate.h"
#include KWSYS_HEADER(Process.h)
diff --git a/Source/kwsys/test1.cxx b/Source/kwsys/test1.cxx
index 840253f..19f5c9b 100644
--- a/Source/kwsys/test1.cxx
+++ b/Source/kwsys/test1.cxx
@@ -11,9 +11,10 @@
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
-#include <kwsys/Directory.hxx>
-#include <kwsys/Process.h>
-#include <kwsys/ios/iostream>
+#include "kwsysPrivate.h"
+#include KWSYS_HEADER(Directory.hxx)
+#include KWSYS_HEADER(Process.h)
+#include KWSYS_HEADER(ios/iostream)
int main()
{
diff --git a/Source/kwsys/testCommandLineArguments.cxx b/Source/kwsys/testCommandLineArguments.cxx
index 99b45c0..5ae0131 100644
--- a/Source/kwsys/testCommandLineArguments.cxx
+++ b/Source/kwsys/testCommandLineArguments.cxx
@@ -11,9 +11,10 @@
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
-#include <kwsys/CommandLineArguments.hxx>
+#include "kwsysPrivate.h"
-#include <kwsys/ios/iostream>
+#include KWSYS_HEADER(CommandLineArguments.hxx)
+#include KWSYS_HEADER(ios/iostream)
void* random_ptr = (void*)0x123;
diff --git a/Source/kwsys/testIOS.cxx b/Source/kwsys/testIOS.cxx
index f1441f6..a6f33d8 100644
--- a/Source/kwsys/testIOS.cxx
+++ b/Source/kwsys/testIOS.cxx
@@ -1,6 +1,7 @@
-#include <kwsys/stl/vector>
-#include <kwsys/ios/sstream>
-#include <kwsys/ios/iostream>
+#include "kwsysPrivate.h"
+#include KWSYS_HEADER(stl/vector)
+#include KWSYS_HEADER(ios/sstream)
+#include KWSYS_HEADER(ios/iostream)
int main()
{
diff --git a/Source/kwsys/testProcess.c b/Source/kwsys/testProcess.c
index fb0916f..b34c49c 100644
--- a/Source/kwsys/testProcess.c
+++ b/Source/kwsys/testProcess.c
@@ -11,7 +11,8 @@
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
-#include <kwsys/Process.h>
+#include "kwsysPrivate.h"
+#include KWSYS_HEADER(Process.h)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/Source/kwsys/testSystemTools.cxx b/Source/kwsys/testSystemTools.cxx
new file mode 100644
index 0000000..28de9a9
--- /dev/null
+++ b/Source/kwsys/testSystemTools.cxx
@@ -0,0 +1,64 @@
+/*=========================================================================
+
+ Program: KWSys - Kitware System Library
+ Module: $RCSfile$
+
+ Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved.
+ See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+#include "kwsysPrivate.h"
+#include KWSYS_HEADER(SystemTools.hxx)
+#include KWSYS_HEADER(ios/iostream)
+
+const char* toUnixPaths[][2] =
+{
+ { "/usr/local/bin/passwd", "/usr/local/bin/passwd" },
+ { "/usr/lo cal/bin/pa sswd", "/usr/lo cal/bin/pa sswd" },
+ { "/usr/lo\\ cal/bin/pa\\ sswd", "/usr/lo\\ cal/bin/pa\\ sswd" },
+ { "c:/usr/local/bin/passwd", "c:/usr/local/bin/passwd" },
+ { "c:/usr/lo cal/bin/pa sswd", "c:/usr/lo cal/bin/pa sswd" },
+ { "c:/usr/lo\\ cal/bin/pa\\ sswd", "c:/usr/lo\\ cal/bin/pa\\ sswd" },
+ { "\\usr\\local\\bin\\passwd", "/usr/local/bin/passwd" },
+ { "\\usr\\lo cal\\bin\\pa sswd", "/usr/lo cal/bin/pa sswd" },
+ { "\\usr\\lo\\ cal\\bin\\pa\\ sswd", "/usr/lo\\ cal/bin/pa\\ sswd" },
+ { "c:\\usr\\local\\bin\\passwd", "c:/usr/local/bin/passwd" },
+ { "c:\\usr\\lo cal\\bin\\pa sswd", "c:/usr/lo cal/bin/pa sswd" },
+ { "c:\\usr\\lo\\ cal\\bin\\pa\\ sswd", "c:/usr/lo\\ cal/bin/pa\\ sswd" },
+ { "\\\\usr\\local\\bin\\passwd", "//usr/local/bin/passwd" },
+ { "\\\\usr\\lo cal\\bin\\pa sswd", "//usr/lo cal/bin/pa sswd" },
+ { "\\\\usr\\lo\\ cal\\bin\\pa\\ sswd", "//usr/lo\\ cal/bin/pa\\ sswd" },
+ {0, 0}
+};
+
+bool CheckConvertToUnixSlashes(kwsys_stl::string input, kwsys_stl::string output)
+{
+ kwsys_stl::string result = input;
+ kwsys::SystemTools::ConvertToUnixSlashes(result);
+ if ( result != output )
+ {
+ kwsys_ios::cerr << "Problem with ConvertToUnixSlashes - input: " << input.c_str() << " output: " << result.c_str() << " expected: " << output.c_str() << kwsys_ios::endl;
+ return false;
+ }
+ return true;
+}
+
+int main(/*int argc, char* argv*/)
+{
+ int cc;
+ for ( cc = 0; toUnixPaths[cc][0]; cc ++ )
+ {
+ CheckConvertToUnixSlashes(toUnixPaths[cc][0], toUnixPaths[cc][1]);
+ }
+ {
+ // Special check for ~
+ kwsys_stl::string output = kwsys::SystemTools::GetEnv("HOME");
+ output += "/foo bar/lala";
+ CheckConvertToUnixSlashes("~/foo bar/lala", output);
+ }
+ return 0;
+}
diff --git a/Source/kwsys/testhash.cxx b/Source/kwsys/testhash.cxx
index 0ca54e6..8360a18 100644
--- a/Source/kwsys/testhash.cxx
+++ b/Source/kwsys/testhash.cxx
@@ -1,7 +1,7 @@
-#include <kwsys/hash_map.hxx>
-#include <kwsys/hash_set.hxx>
-
-#include <kwsys/ios/iostream>
+#include "kwsysPrivate.h"
+#include KWSYS_HEADER(hash_map.hxx)
+#include KWSYS_HEADER(hash_set.hxx)
+#include KWSYS_HEADER(ios/iostream)
#if defined(_MSC_VER)
# pragma warning (disable:4786)