summaryrefslogtreecommitdiffstats
path: root/Source/kwsys
diff options
context:
space:
mode:
authorSebastien Barre <sebastien.barre@kitware.com>2005-10-04 19:09:00 (GMT)
committerSebastien Barre <sebastien.barre@kitware.com>2005-10-04 19:09:00 (GMT)
commit13627538b9330e0a82f9c570fbdff52df1392c24 (patch)
tree85e5ed43c891300b434be93dca42dbc88b71605c /Source/kwsys
parent89569f07eda48a5896a153d5b9d123cc05776f3a (diff)
downloadCMake-13627538b9330e0a82f9c570fbdff52df1392c24.zip
CMake-13627538b9330e0a82f9c570fbdff52df1392c24.tar.gz
CMake-13627538b9330e0a82f9c570fbdff52df1392c24.tar.bz2
ENH: add kwsys test for DetectFileType
Diffstat (limited to 'Source/kwsys')
-rw-r--r--Source/kwsys/CMakeLists.txt8
-rw-r--r--Source/kwsys/testSystemTools.cxx30
-rw-r--r--Source/kwsys/testSystemTools.h.in20
3 files changed, 58 insertions, 0 deletions
diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt
index 2ff2740..d6bc472 100644
--- a/Source/kwsys/CMakeLists.txt
+++ b/Source/kwsys/CMakeLists.txt
@@ -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")
diff --git a/Source/kwsys/testSystemTools.cxx b/Source/kwsys/testSystemTools.cxx
index 484fdf4..7805c2a 100644
--- a/Source/kwsys/testSystemTools.cxx
+++ b/Source/kwsys/testSystemTools.cxx
@@ -27,6 +27,8 @@
# include "kwsys_ios_iostream.h.in"
#endif
+#include "testSystemTools.h"
+
//----------------------------------------------------------------------------
const char* toUnixPaths[][2] =
{
@@ -91,6 +93,32 @@ bool CheckEscapeChars(kwsys_stl::string input,
}
//----------------------------------------------------------------------------
+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*/)
{
bool res = true;
@@ -115,5 +143,7 @@ int main(/*int argc, char* argv*/)
*checkEscapeChars[cc][2], checkEscapeChars[cc][3]);
}
+ res &= CheckDetectFileType();
+
return res ? 0 : 1;
}
diff --git a/Source/kwsys/testSystemTools.h.in b/Source/kwsys/testSystemTools.h.in
new file mode 100644
index 0000000..a96f39e
--- /dev/null
+++ b/Source/kwsys/testSystemTools.h.in
@@ -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