From 9a8ab86645b0ea1fcbd1b069694d0cbb4fa2621a Mon Sep 17 00:00:00 2001 From: Clinton Stimpson Date: Fri, 26 Dec 2014 21:19:14 -0700 Subject: Encoding: Modify tests to work using non-ascii paths. For complex*, CustomCommand and OutDir tests, non-ascii paths are avoided in test code by using relative paths, and setting the working when running the test. This also avoids the need to internationalize the test code. For RunCMake.GeneratorExpression, use a UTF-8 encoding in file(STRINGS) to retrieve the compiled absolute path correctly. --- Tests/Complex/Executable/CMakeLists.txt | 14 +++++++++----- Tests/Complex/Executable/complex.cxx | 22 +++++++++++----------- Tests/ComplexOneConfig/Executable/CMakeLists.txt | 14 +++++++++----- Tests/ComplexOneConfig/Executable/complex.cxx | 22 +++++++++++----------- Tests/CustomCommand/CMakeLists.txt | 7 ------- Tests/CustomCommand/config.h.in | 1 - Tests/CustomCommand/foo.in | 3 +-- Tests/OutDir/OutDir.cmake | 10 +++++++--- .../ValidTarget-TARGET_PDB_FILE-check.cmake | 2 +- 9 files changed, 49 insertions(+), 46 deletions(-) delete mode 100644 Tests/CustomCommand/config.h.in diff --git a/Tests/Complex/Executable/CMakeLists.txt b/Tests/Complex/Executable/CMakeLists.txt index bf23d4a..508221c 100644 --- a/Tests/Complex/Executable/CMakeLists.txt +++ b/Tests/Complex/Executable/CMakeLists.txt @@ -89,18 +89,22 @@ remove_definitions(-DCOMPLEX_DEFINED) # Test pre-build/pre-link/post-build rules for an executable. add_custom_command(TARGET complex PRE_BUILD COMMAND ${CREATE_FILE_EXE} - ARGS "${Complex_BINARY_DIR}/Executable/prebuild.txt") + ARGS "Executable/prebuild.txt" + WORKING_DIRECTORY "${Complex_BINARY_DIR}") add_custom_command(TARGET complex PRE_LINK COMMAND ${CREATE_FILE_EXE} - ARGS "${Complex_BINARY_DIR}/Executable/prelink.txt") + ARGS "Executable/prelink.txt" + WORKING_DIRECTORY "${Complex_BINARY_DIR}") add_custom_command(TARGET complex POST_BUILD COMMAND ${CREATE_FILE_EXE} - ARGS "${Complex_BINARY_DIR}/Executable/postbuild.txt") + ARGS "Executable/postbuild.txt" + WORKING_DIRECTORY "${Complex_BINARY_DIR}") add_custom_command(TARGET complex POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy - "${Complex_BINARY_DIR}/Executable/postbuild.txt" - "${Complex_BINARY_DIR}/Executable/postbuild2.txt") + "Executable/postbuild.txt" + "Executable/postbuild2.txt" + WORKING_DIRECTORY "${Complex_BINARY_DIR}") set_source_files_properties(complex COMPILE_FLAGS diff --git a/Tests/Complex/Executable/complex.cxx b/Tests/Complex/Executable/complex.cxx index 31442ba..ec222a5 100644 --- a/Tests/Complex/Executable/complex.cxx +++ b/Tests/Complex/Executable/complex.cxx @@ -716,14 +716,14 @@ int main() // the file was removed the last time 'complex' was run, and it is // only created during a build. - TestAndRemoveFile(BINARY_DIR "/Library/prebuild.txt"); - TestAndRemoveFile(BINARY_DIR "/Library/prelink.txt"); - TestAndRemoveFile(BINARY_DIR "/Library/postbuild.txt"); - TestAndRemoveFile(BINARY_DIR "/Library/postbuild2.txt"); - TestAndRemoveFile(BINARY_DIR "/Executable/prebuild.txt"); - TestAndRemoveFile(BINARY_DIR "/Executable/prelink.txt"); - TestAndRemoveFile(BINARY_DIR "/Executable/postbuild.txt"); - TestAndRemoveFile(BINARY_DIR "/Executable/postbuild2.txt"); + TestAndRemoveFile("Library/prebuild.txt"); + TestAndRemoveFile("Library/prelink.txt"); + TestAndRemoveFile("Library/postbuild.txt"); + TestAndRemoveFile("Library/postbuild2.txt"); + TestAndRemoveFile("Executable/prebuild.txt"); + TestAndRemoveFile("Executable/prelink.txt"); + TestAndRemoveFile("Executable/postbuild.txt"); + TestAndRemoveFile("Executable/postbuild2.txt"); // ---------------------------------------------------------------------- // A custom target has been created (see Library/). @@ -733,12 +733,12 @@ int main() // the file was removed the last time 'complex' was run, and it is // only created during a build. - TestAndRemoveFile(BINARY_DIR "/Library/custom_target1.txt"); + TestAndRemoveFile("Library/custom_target1.txt"); // ---------------------------------------------------------------------- // A directory has been created. - TestDir(BINARY_DIR "/make_dir"); + TestDir("make_dir"); // ---------------------------------------------------------------------- // Test OUTPUT_REQUIRED_FILES @@ -749,7 +749,7 @@ int main() // the file was removed the last time 'complex' was run, and it is // only created during a build. - TestAndRemoveFile(BINARY_DIR "/Executable/Temp/complex-required.txt"); + TestAndRemoveFile("Executable/Temp/complex-required.txt"); // ---------------------------------------------------------------------- // Test FIND_LIBRARY diff --git a/Tests/ComplexOneConfig/Executable/CMakeLists.txt b/Tests/ComplexOneConfig/Executable/CMakeLists.txt index 01f1005..e910f20 100644 --- a/Tests/ComplexOneConfig/Executable/CMakeLists.txt +++ b/Tests/ComplexOneConfig/Executable/CMakeLists.txt @@ -89,18 +89,22 @@ remove_definitions(-DCOMPLEX_DEFINED) # Test pre-build/pre-link/post-build rules for an executable. add_custom_command(TARGET complex PRE_BUILD COMMAND ${CREATE_FILE_EXE} - ARGS "${Complex_BINARY_DIR}/Executable/prebuild.txt") + ARGS "Executable/prebuild.txt" + WORKING_DIRECTORY "${Complex_BINARY_DIR}") add_custom_command(TARGET complex PRE_BUILD COMMAND ${CREATE_FILE_EXE} - ARGS "${Complex_BINARY_DIR}/Executable/prelink.txt") + ARGS "Executable/prelink.txt" + WORKING_DIRECTORY "${Complex_BINARY_DIR}") add_custom_command(TARGET complex POST_BUILD COMMAND ${CREATE_FILE_EXE} - ARGS "${Complex_BINARY_DIR}/Executable/postbuild.txt") + ARGS "Executable/postbuild.txt" + WORKING_DIRECTORY "${Complex_BINARY_DIR}") add_custom_command(TARGET complex POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy - "${Complex_BINARY_DIR}/Executable/postbuild.txt" - "${Complex_BINARY_DIR}/Executable/postbuild2.txt") + "Executable/postbuild.txt" + "Executable/postbuild2.txt" + WORKING_DIRECTORY "${Complex_BINARY_DIR}") set_source_files_properties(complex COMPILE_FLAGS diff --git a/Tests/ComplexOneConfig/Executable/complex.cxx b/Tests/ComplexOneConfig/Executable/complex.cxx index 31442ba..ec222a5 100644 --- a/Tests/ComplexOneConfig/Executable/complex.cxx +++ b/Tests/ComplexOneConfig/Executable/complex.cxx @@ -716,14 +716,14 @@ int main() // the file was removed the last time 'complex' was run, and it is // only created during a build. - TestAndRemoveFile(BINARY_DIR "/Library/prebuild.txt"); - TestAndRemoveFile(BINARY_DIR "/Library/prelink.txt"); - TestAndRemoveFile(BINARY_DIR "/Library/postbuild.txt"); - TestAndRemoveFile(BINARY_DIR "/Library/postbuild2.txt"); - TestAndRemoveFile(BINARY_DIR "/Executable/prebuild.txt"); - TestAndRemoveFile(BINARY_DIR "/Executable/prelink.txt"); - TestAndRemoveFile(BINARY_DIR "/Executable/postbuild.txt"); - TestAndRemoveFile(BINARY_DIR "/Executable/postbuild2.txt"); + TestAndRemoveFile("Library/prebuild.txt"); + TestAndRemoveFile("Library/prelink.txt"); + TestAndRemoveFile("Library/postbuild.txt"); + TestAndRemoveFile("Library/postbuild2.txt"); + TestAndRemoveFile("Executable/prebuild.txt"); + TestAndRemoveFile("Executable/prelink.txt"); + TestAndRemoveFile("Executable/postbuild.txt"); + TestAndRemoveFile("Executable/postbuild2.txt"); // ---------------------------------------------------------------------- // A custom target has been created (see Library/). @@ -733,12 +733,12 @@ int main() // the file was removed the last time 'complex' was run, and it is // only created during a build. - TestAndRemoveFile(BINARY_DIR "/Library/custom_target1.txt"); + TestAndRemoveFile("Library/custom_target1.txt"); // ---------------------------------------------------------------------- // A directory has been created. - TestDir(BINARY_DIR "/make_dir"); + TestDir("make_dir"); // ---------------------------------------------------------------------- // Test OUTPUT_REQUIRED_FILES @@ -749,7 +749,7 @@ int main() // the file was removed the last time 'complex' was run, and it is // only created during a build. - TestAndRemoveFile(BINARY_DIR "/Executable/Temp/complex-required.txt"); + TestAndRemoveFile("Executable/Temp/complex-required.txt"); // ---------------------------------------------------------------------- // Test FIND_LIBRARY diff --git a/Tests/CustomCommand/CMakeLists.txt b/Tests/CustomCommand/CMakeLists.txt index 915da0a..57ffeec 100644 --- a/Tests/CustomCommand/CMakeLists.txt +++ b/Tests/CustomCommand/CMakeLists.txt @@ -164,13 +164,6 @@ add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/not_included.h ${PROJECT_BINARY_DIR}/not_included.h ) -# Tell the executable where to find not_included.h. -configure_file( - ${PROJECT_SOURCE_DIR}/config.h.in - ${PROJECT_BINARY_DIR}/config.h - @ONLY - ) - # add the executable add_executable(CustomCommand ${PROJECT_BINARY_DIR}/foo.h diff --git a/Tests/CustomCommand/config.h.in b/Tests/CustomCommand/config.h.in deleted file mode 100644 index 86c97bd..0000000 --- a/Tests/CustomCommand/config.h.in +++ /dev/null @@ -1 +0,0 @@ -#define PROJECT_BINARY_DIR "@PROJECT_BINARY_DIR@" diff --git a/Tests/CustomCommand/foo.in b/Tests/CustomCommand/foo.in index 0c5021c..e43aed1 100644 --- a/Tests/CustomCommand/foo.in +++ b/Tests/CustomCommand/foo.in @@ -1,6 +1,5 @@ #include "doc1.h" #include "foo.h" -#include "config.h" #include @@ -11,7 +10,7 @@ int main () { if (generated()*wrapped()*doc() == 3*5*7) { - FILE* fin = fopen(PROJECT_BINARY_DIR "/not_included.h", "r"); + FILE* fin = fopen("not_included.h", "r"); if(fin) { fclose(fin); diff --git a/Tests/OutDir/OutDir.cmake b/Tests/OutDir/OutDir.cmake index e1e6b7f..a1f13e7 100644 --- a/Tests/OutDir/OutDir.cmake +++ b/Tests/OutDir/OutDir.cmake @@ -16,13 +16,17 @@ find_program(CONLY_EXE PATHS ${top}/runtime NO_DEFAULT_PATH) +file(RELATIVE_PATH TESTC1_LIB_FILE "${top}" "${TESTC1_LIB}") +file(RELATIVE_PATH TESTC2_LIB_FILE "${top}" "${TESTC2_LIB}") +file(RELATIVE_PATH CONLY_EXE_FILE "${top}" "${CONLY_EXE}") + file(WRITE ${top}/OutDir.h "/* Generated by ${CMAKE_CURRENT_LIST_FILE} */ #ifndef OutDir_h #define OutDir_h -#define TESTC1_LIB \"${TESTC1_LIB}\" -#define TESTC2_LIB \"${TESTC2_LIB}\" -#define CONLY_EXE \"${CONLY_EXE}\" +#define TESTC1_LIB \"${TESTC1_LIB_FILE}\" +#define TESTC2_LIB \"${TESTC2_LIB_FILE}\" +#define CONLY_EXE \"${CONLY_EXE_FILE}\" #endif ") diff --git a/Tests/RunCMake/GeneratorExpression/ValidTarget-TARGET_PDB_FILE-check.cmake b/Tests/RunCMake/GeneratorExpression/ValidTarget-TARGET_PDB_FILE-check.cmake index 748d14f..2a588bc 100644 --- a/Tests/RunCMake/GeneratorExpression/ValidTarget-TARGET_PDB_FILE-check.cmake +++ b/Tests/RunCMake/GeneratorExpression/ValidTarget-TARGET_PDB_FILE-check.cmake @@ -1,4 +1,4 @@ -file(STRINGS ${RunCMake_TEST_BINARY_DIR}/test.txt TEST_TXT) +file(STRINGS ${RunCMake_TEST_BINARY_DIR}/test.txt TEST_TXT ENCODING UTF-8) list(GET TEST_TXT 0 PDB_PATH) list(GET TEST_TXT 1 PDB_NAME) -- cgit v0.12