Commit 97817ce7 authored by Chuck Atkins's avatar Chuck Atkins
Browse files

SystemTools: Refactor test file and directory locations

The full path for files used by SystemTools tests were preconfigured
in a generated header file by CMake variables.  This begins to get
unwieldy and clutters the CMake files once more variables and files
get added.  In preperation for more file and directory tests being
added, the preconfigured variables are now just the source and binary
directories for which all tests can base themselves off of.

Change-Id: Iae9e11592a3c040ce2e9cc90dbd1ccedfc3129ea
parent e4bba930
......@@ -1171,10 +1171,9 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
ADD_EXECUTABLE(${KWSYS_NAMESPACE}TestsCxx ${KWSYS_CXX_TEST_SRCS})
SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestsCxx PROPERTY LABELS ${KWSYS_LABELS_EXE})
TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE}TestsCxx ${KWSYS_NAMESPACE})
SET(TEST_SYSTEMTOOLS_BIN_FILE
"${CMAKE_CURRENT_SOURCE_DIR}/testSystemTools.bin")
SET(TEST_SYSTEMTOOLS_SRC_FILE
"${CMAKE_CURRENT_SOURCE_DIR}/testSystemTools.cxx")
SET(TEST_SYSTEMTOOLS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
SET(TEST_SYSTEMTOOLS_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
CONFIGURE_FILE(
${PROJECT_SOURCE_DIR}/testSystemTools.h.in
${PROJECT_BINARY_DIR}/testSystemTools.h)
......
......@@ -108,7 +108,7 @@ int testDynamicLoader(int argc, char *argv[])
// Make sure that inexistent lib is giving correct result
res += TestDynamicLoader("azerty_", "foo_bar",0,0,0);
// Make sure that random binary file cannot be assimilated as dylib
res += TestDynamicLoader(TEST_SYSTEMTOOLS_BIN_FILE, "wp",0,0,0);
res += TestDynamicLoader(TEST_SYSTEMTOOLS_SOURCE_DIR "/testSystemTools.bin", "wp",0,0,0);
#endif
#ifdef __linux__
......
......@@ -98,31 +98,35 @@ static bool CheckEscapeChars(kwsys_stl::string input,
static bool CheckFileOperations()
{
bool res = true;
const kwsys_stl::string testBinFile(TEST_SYSTEMTOOLS_SOURCE_DIR
"/testSystemTools.bin");
const kwsys_stl::string testTxtFile(TEST_SYSTEMTOOLS_SOURCE_DIR
"/testSystemTools.cxx");
if (kwsys::SystemTools::DetectFileType(TEST_SYSTEMTOOLS_BIN_FILE) !=
if (kwsys::SystemTools::DetectFileType(testBinFile.c_str()) !=
kwsys::SystemTools::FileTypeBinary)
{
kwsys_ios::cerr
<< "Problem with DetectFileType - failed to detect type of: "
<< TEST_SYSTEMTOOLS_BIN_FILE << kwsys_ios::endl;
<< testBinFile << kwsys_ios::endl;
res = false;
}
if (kwsys::SystemTools::DetectFileType(TEST_SYSTEMTOOLS_SRC_FILE) !=
if (kwsys::SystemTools::DetectFileType(testTxtFile.c_str()) !=
kwsys::SystemTools::FileTypeText)
{
kwsys_ios::cerr
<< "Problem with DetectFileType - failed to detect type of: "
<< TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
<< testTxtFile << kwsys_ios::endl;
res = false;
}
if (kwsys::SystemTools::FileLength(TEST_SYSTEMTOOLS_BIN_FILE) != 766)
if (kwsys::SystemTools::FileLength(testBinFile.c_str()) != 766)
{
kwsys_ios::cerr
<< "Problem with FileLength - incorrect length for: "
<< TEST_SYSTEMTOOLS_BIN_FILE << kwsys_ios::endl;
res = false;
<< testBinFile << kwsys_ios::endl;
res = false;
}
return res;
......@@ -138,7 +142,7 @@ static bool CheckStringOperations()
{
kwsys_ios::cerr
<< "Problem with CapitalizedWords "
<< TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
<< '"' << test << '"' << kwsys_ios::endl;
res = false;
}
......@@ -148,7 +152,7 @@ static bool CheckStringOperations()
{
kwsys_ios::cerr
<< "Problem with UnCapitalizedWords "
<< TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
<< '"' << test << '"' << kwsys_ios::endl;
res = false;
}
......@@ -158,7 +162,7 @@ static bool CheckStringOperations()
{
kwsys_ios::cerr
<< "Problem with AddSpaceBetweenCapitalizedWords "
<< TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
<< '"' << test << '"' << kwsys_ios::endl;
res = false;
}
......@@ -168,7 +172,7 @@ static bool CheckStringOperations()
{
kwsys_ios::cerr
<< "Problem with AppendStrings "
<< TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
<< "\"Mary Had A\" \" Little Lamb.\"" << kwsys_ios::endl;
res = false;
}
delete [] cres;
......@@ -179,7 +183,7 @@ static bool CheckStringOperations()
{
kwsys_ios::cerr
<< "Problem with AppendStrings "
<< TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
<< "\"Mary Had\" \" A \" \"Little Lamb.\"" << kwsys_ios::endl;
res = false;
}
delete [] cres;
......@@ -188,7 +192,7 @@ static bool CheckStringOperations()
{
kwsys_ios::cerr
<< "Problem with CountChar "
<< TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
<< "\"Mary Had A Little Lamb.\"" << kwsys_ios::endl;
res = false;
}
......@@ -198,7 +202,7 @@ static bool CheckStringOperations()
{
kwsys_ios::cerr
<< "Problem with RemoveChars "
<< TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
<< "\"Mary Had A Little Lamb.\"" << kwsys_ios::endl;
res = false;
}
delete [] cres;
......@@ -209,7 +213,7 @@ static bool CheckStringOperations()
{
kwsys_ios::cerr
<< "Problem with RemoveCharsButUpperHex "
<< TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
<< "\"Mary Had A Little Lamb.\"" << kwsys_ios::endl;
res = false;
}
delete [] cres;
......@@ -221,7 +225,7 @@ static bool CheckStringOperations()
{
kwsys_ios::cerr
<< "Problem with ReplaceChars "
<< TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
<< "\"Mary Had A Little Lamb.\"" << kwsys_ios::endl;
res = false;
}
delete [] cres2;
......@@ -231,7 +235,7 @@ static bool CheckStringOperations()
{
kwsys_ios::cerr
<< "Problem with StringStartsWith "
<< TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
<< "\"Mary Had A Little Lamb.\"" << kwsys_ios::endl;
res = false;
}
......@@ -240,7 +244,7 @@ static bool CheckStringOperations()
{
kwsys_ios::cerr
<< "Problem with StringEndsWith "
<< TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
<< "\"Mary Had A Little Lamb.\"" << kwsys_ios::endl;
res = false;
}
......@@ -249,7 +253,7 @@ static bool CheckStringOperations()
{
kwsys_ios::cerr
<< "Problem with DuplicateString "
<< TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
<< "\"Mary Had A Little Lamb.\"" << kwsys_ios::endl;
res = false;
}
delete [] cres;
......@@ -260,7 +264,7 @@ static bool CheckStringOperations()
{
kwsys_ios::cerr
<< "Problem with CropString "
<< TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
<< "\"Mary Had A Little Lamb.\"" << kwsys_ios::endl;
res = false;
}
......@@ -271,8 +275,8 @@ static bool CheckStringOperations()
{
kwsys_ios::cerr
<< "Problem with Split "
<< TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
res = false;
<< "\"Mary Had A Little Lamb.\"" << kwsys_ios::endl;
res = false;
}
if (kwsys::SystemTools::ConvertToWindowsOutputPath
......@@ -281,6 +285,7 @@ static bool CheckStringOperations()
{
kwsys_ios::cerr
<< "Problem with ConvertToWindowsOutputPath "
<< "\"L://Local Mojo/Hex Power Pack/Iffy Voodoo\""
<< kwsys_ios::endl;
res = false;
}
......@@ -291,6 +296,7 @@ static bool CheckStringOperations()
{
kwsys_ios::cerr
<< "Problem with ConvertToWindowsOutputPath "
<< "\"//grayson/Local Mojo/Hex Power Pack/Iffy Voodoo\""
<< kwsys_ios::endl;
res = false;
}
......@@ -301,6 +307,7 @@ static bool CheckStringOperations()
{
kwsys_ios::cerr
<< "Problem with ConvertToUnixOutputPath "
<< "\"//Local Mojo/Hex Power Pack/Iffy Voodoo\""
<< kwsys_ios::endl;
res = false;
}
......@@ -308,14 +315,17 @@ static bool CheckStringOperations()
int targc;
char **targv;
kwsys::SystemTools::ConvertWindowsCommandLineToUnixArguments
("\"Local Mojo\\Voodoo.asp\" -CastHex \"D:\\My Secret Mojo\\Voodoo.mp3\"", &targc, &targv);
("\"Local Mojo\\Voodoo.asp\" -CastHex \"D:\\My Secret Mojo\\Voodoo.mp3\"",
&targc, &targv);
if (targc != 4 || strcmp(targv[1],"Local Mojo\\Voodoo.asp") ||
strcmp(targv[2],"-CastHex") ||
strcmp(targv[3],"D:\\My Secret Mojo\\Voodoo.mp3"))
{
kwsys_ios::cerr
<< "Problem with ConvertWindowsCommandLineToUnixArguments"
<< TEST_SYSTEMTOOLS_SRC_FILE << kwsys_ios::endl;
<< "\'\"Local Mojo\\Voodoo.asp\" "
<< "-CastHex \"D:\\My Secret Mojo\\Voodoo.mp3\"\'"
<< kwsys_ios::endl;
res = false;
}
for (;targc >=0; --targc)
......
......@@ -14,7 +14,7 @@
#define EXECUTABLE_OUTPUT_PATH "@CMAKE_CURRENT_BINARY_DIR@"
#define TEST_SYSTEMTOOLS_BIN_FILE "@TEST_SYSTEMTOOLS_BIN_FILE@"
#define TEST_SYSTEMTOOLS_SRC_FILE "@TEST_SYSTEMTOOLS_SRC_FILE@"
#define TEST_SYSTEMTOOLS_SOURCE_DIR "@TEST_SYSTEMTOOLS_SOURCE_DIR@"
#define TEST_SYSTEMTOOLS_BINARY_DIR "@TEST_SYSTEMTOOLS_BINARY_DIR@"
#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