ENH: add kwsys test for DetectFileType
This commit is contained in:
parent
89569f07ed
commit
13627538b9
@ -635,6 +635,14 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
|
|||||||
ENDIF(EXECUTABLE_OUTPUT_PATH)
|
ENDIF(EXECUTABLE_OUTPUT_PATH)
|
||||||
|
|
||||||
IF(BUILD_TESTING)
|
IF(BUILD_TESTING)
|
||||||
|
|
||||||
|
GET_TARGET_PROPERTY(TEST_SYSTEMTOOLS_EXE testSystemTools LOCATION)
|
||||||
|
SET(TEST_SYSTEMTOOLS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/testSystemTools.cxx")
|
||||||
|
CONFIGURE_FILE(
|
||||||
|
${PROJECT_SOURCE_DIR}/testSystemTools.h.in
|
||||||
|
${PROJECT_BINARY_DIR}/testSystemTools.h)
|
||||||
|
INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR})
|
||||||
|
|
||||||
IF(CTEST_TEST_KWSYS)
|
IF(CTEST_TEST_KWSYS)
|
||||||
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/ExtraTest.cmake.in"
|
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/ExtraTest.cmake.in"
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/ExtraTest.cmake")
|
"${CMAKE_CURRENT_BINARY_DIR}/ExtraTest.cmake")
|
||||||
|
@ -27,6 +27,8 @@
|
|||||||
# include "kwsys_ios_iostream.h.in"
|
# include "kwsys_ios_iostream.h.in"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "testSystemTools.h"
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
const char* toUnixPaths[][2] =
|
const char* toUnixPaths[][2] =
|
||||||
{
|
{
|
||||||
@ -90,6 +92,32 @@ bool CheckEscapeChars(kwsys_stl::string input,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool CheckDetectFileType()
|
||||||
|
{
|
||||||
|
bool res = true;
|
||||||
|
|
||||||
|
if (kwsys::SystemTools::DetectFileType(TEST_SYSTEMTOOLS_EXE) !=
|
||||||
|
kwsys::SystemTools::FileTypeBinary)
|
||||||
|
{
|
||||||
|
kwsys_ios::cerr
|
||||||
|
<< "Problem with DetectFileType - failed to detect type of: "
|
||||||
|
<< TEST_SYSTEMTOOLS_EXE << kwsys_ios::endl;
|
||||||
|
res = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (kwsys::SystemTools::DetectFileType(TEST_SYSTEMTOOLS_SRC) !=
|
||||||
|
kwsys::SystemTools::FileTypeText)
|
||||||
|
{
|
||||||
|
kwsys_ios::cerr
|
||||||
|
<< "Problem with DetectFileType - failed to detect type of: "
|
||||||
|
<< TEST_SYSTEMTOOLS_SRC << kwsys_ios::endl;
|
||||||
|
res = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
int main(/*int argc, char* argv*/)
|
int main(/*int argc, char* argv*/)
|
||||||
{
|
{
|
||||||
@ -115,5 +143,7 @@ int main(/*int argc, char* argv*/)
|
|||||||
*checkEscapeChars[cc][2], checkEscapeChars[cc][3]);
|
*checkEscapeChars[cc][2], checkEscapeChars[cc][3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
res &= CheckDetectFileType();
|
||||||
|
|
||||||
return res ? 0 : 1;
|
return res ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
20
Source/kwsys/testSystemTools.h.in
Normal file
20
Source/kwsys/testSystemTools.h.in
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
=========================================================================*/
|
||||||
|
#ifndef @KWSYS_NAMESPACE@_testSystemtools_h
|
||||||
|
#define @KWSYS_NAMESPACE@_testSystemtools_h
|
||||||
|
|
||||||
|
#define TEST_SYSTEMTOOLS_EXE "@TEST_SYSTEMTOOLS_EXE@"
|
||||||
|
#define TEST_SYSTEMTOOLS_SRC "@TEST_SYSTEMTOOLS_SRC@"
|
||||||
|
|
||||||
|
#endif
|
Loading…
x
Reference in New Issue
Block a user