summaryrefslogtreecommitdiffstats
path: root/Tests/CustomCommand
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2008-04-29 19:34:49 (GMT)
committerBrad King <brad.king@kitware.com>2008-04-29 19:34:49 (GMT)
commitc7d84b21c636a559b1f1a87735ce12d21f4a9dcd (patch)
treef63d1ac44651bfeb21a82c614d7c6c8155cbffbd /Tests/CustomCommand
parent3344ce9197926f262fa4eed30f085d72b08af744 (diff)
downloadCMake-c7d84b21c636a559b1f1a87735ce12d21f4a9dcd.zip
CMake-c7d84b21c636a559b1f1a87735ce12d21f4a9dcd.tar.gz
CMake-c7d84b21c636a559b1f1a87735ce12d21f4a9dcd.tar.bz2
BUG: Do not escape shell operators when generating command lines.
- See bug#6868. - Update CustomCommand test to check.
Diffstat (limited to 'Tests/CustomCommand')
-rw-r--r--Tests/CustomCommand/CMakeLists.txt16
-rw-r--r--Tests/CustomCommand/GeneratorInExtraDir/CMakeLists.txt2
-rw-r--r--Tests/CustomCommand/gen_redirect_in.c5
-rw-r--r--Tests/CustomCommand/generator.cxx6
-rw-r--r--Tests/CustomCommand/tcat.cxx11
5 files changed, 37 insertions, 3 deletions
diff --git a/Tests/CustomCommand/CMakeLists.txt b/Tests/CustomCommand/CMakeLists.txt
index 29c06cd..4660e5d 100644
--- a/Tests/CustomCommand/CMakeLists.txt
+++ b/Tests/CustomCommand/CMakeLists.txt
@@ -150,6 +150,7 @@ ADD_EXECUTABLE(CustomCommand
${PROJECT_BINARY_DIR}/wrapped_help.c
${PROJECT_BINARY_DIR}/generated.c
${PROJECT_BINARY_DIR}/not_included.h
+ gen_redirect.c # default location for custom commands is in build tree
)
# Add the rule to create generated.c at build time. This is placed
@@ -191,6 +192,17 @@ ADD_CUSTOM_COMMAND(TARGET CustomCommandUsingTargetTest POST_BUILD
ADD_SUBDIRECTORY(GeneratorInExtraDir)
+##############################################################################
+# Test shell operators in custom commands.
+
+ADD_EXECUTABLE(tcat tcat.cxx)
+
+ADD_CUSTOM_COMMAND(OUTPUT gen_redirect.c
+ DEPENDS tcat gen_redirect_in.c
+ COMMAND tcat < ${CMAKE_CURRENT_SOURCE_DIR}/gen_redirect_in.c > gen_redirect.c
+ COMMAND ${CMAKE_COMMAND} -E echo "#endif" >> gen_redirect.c
+ VERBATIM
+ )
##############################################################################
# Test non-trivial command line arguments in custom commands.
@@ -303,8 +315,8 @@ SET(CHECK_ARGS
"one|pipe w s"
"#two-pounds# w s"
"one#pound w s"
- ~ ` ! @ \# $ % ^ & _ - + = | : "\;" \" ' , . ? "(" ")" { } []
-# < > << >> &> 2>&1 1>&2
+ ~ ` ! @ \# $ % ^ & _ - + = : "\;" \" ' , . ? "(" ")" { } []
+# | < > << >> &> 2>&1 1>&2
# \\ # Need to test last to avoid ; escape in list.
# # Make tools need help when this is the last argument.
)
diff --git a/Tests/CustomCommand/GeneratorInExtraDir/CMakeLists.txt b/Tests/CustomCommand/GeneratorInExtraDir/CMakeLists.txt
index e838e7b..195a477 100644
--- a/Tests/CustomCommand/GeneratorInExtraDir/CMakeLists.txt
+++ b/Tests/CustomCommand/GeneratorInExtraDir/CMakeLists.txt
@@ -1,3 +1,5 @@
+ADD_DEFINITIONS(-DGENERATOR_EXTERN)
+
# add the executable which will be used for generating files
ADD_EXECUTABLE(generator_extern ../generator.cxx)
SET_TARGET_PROPERTIES(generator_extern PROPERTIES OUTPUT_NAME the_external_generator)
diff --git a/Tests/CustomCommand/gen_redirect_in.c b/Tests/CustomCommand/gen_redirect_in.c
new file mode 100644
index 0000000..8dd8f43
--- /dev/null
+++ b/Tests/CustomCommand/gen_redirect_in.c
@@ -0,0 +1,5 @@
+#if 1
+
+int gen_redirect() { return 3; }
+
+/* endif should be concatenated to generated file */
diff --git a/Tests/CustomCommand/generator.cxx b/Tests/CustomCommand/generator.cxx
index 99da90c..cceac07 100644
--- a/Tests/CustomCommand/generator.cxx
+++ b/Tests/CustomCommand/generator.cxx
@@ -8,8 +8,12 @@ int main(int argc, char *argv[])
return 1;
}
FILE *fp = fopen(argv[1],"w");
-
+#ifdef GENERATOR_EXTERN
fprintf(fp,"int generated() { return 3; }\n");
+#else
+ fprintf(fp,"extern int gen_redirect(void);\n");
+ fprintf(fp,"int generated() { return gen_redirect(); }\n");
+#endif
fclose(fp);
return 0;
}
diff --git a/Tests/CustomCommand/tcat.cxx b/Tests/CustomCommand/tcat.cxx
new file mode 100644
index 0000000..89e3cb0
--- /dev/null
+++ b/Tests/CustomCommand/tcat.cxx
@@ -0,0 +1,11 @@
+#include <stdio.h>
+
+int main()
+{
+ int c;
+ while((c = getc(stdin), c != EOF))
+ {
+ putc(c, stdout);
+ }
+ return 0;
+}