Commit c97d98bd authored by Sebastien Barre's avatar Sebastien Barre
Browse files

ENH: add kwsys test for DetectFileType

parent f7e092fa
......@@ -635,6 +635,14 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
ENDIF(EXECUTABLE_OUTPUT_PATH)
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)
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/ExtraTest.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/ExtraTest.cmake")
......
......@@ -27,6 +27,8 @@
# include "kwsys_ios_iostream.h.in"
#endif
#include "testSystemTools.h"
//----------------------------------------------------------------------------
const char* toUnixPaths[][2] =
{
......@@ -90,6 +92,32 @@ bool CheckEscapeChars(kwsys_stl::string input,
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*/)
{
......@@ -115,5 +143,7 @@ int main(/*int argc, char* argv*/)
*checkEscapeChars[cc][2], checkEscapeChars[cc][3]);
}
res &= CheckDetectFileType();
return res ? 0 : 1;
}
/*=========================================================================
Program: KWSys - Kitware System Library
Module: testSystemTools.h.in
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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment