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.
This commit is contained in:
Clinton Stimpson 2014-12-26 21:19:14 -07:00
parent 7ecbade887
commit 9a8ab86645
9 changed files with 49 additions and 46 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1 +0,0 @@
#define PROJECT_BINARY_DIR "@PROJECT_BINARY_DIR@"

View File

@ -1,6 +1,5 @@
#include "doc1.h"
#include "foo.h"
#include "config.h"
#include <stdio.h>
@ -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);

View File

@ -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
")

View File

@ -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)