ENH: Do kwsys testing as part of cmake testing, command line arguments are not experimental and add simple test for systemtools
This commit is contained in:
parent
3778d89cb9
commit
4a390c174c
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue