diff options
author | Brad King <brad.king@kitware.com> | 2014-04-15 18:29:01 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2014-04-16 13:20:53 (GMT) |
commit | 5ded44aea8b7b5b979f674db531e6aecbb7df44f (patch) | |
tree | 01b31f234c5aeb3a7fc06c112bd8544f693ab68f /test | |
parent | 14920d65e1ae550a375bef282a4232ca317ccfd7 (diff) | |
download | CastXML-5ded44aea8b7b5b979f674db531e6aecbb7df44f.zip CastXML-5ded44aea8b7b5b979f674db531e6aecbb7df44f.tar.gz CastXML-5ded44aea8b7b5b979f674db531e6aecbb7df44f.tar.bz2 |
test: Add cases for --castxml-cc-(gnu|msvc) detection
Create dummy gnu-like and msvc-like compiler binaries. Use them with
the --castxml-cc-<id> options to verify that the preprocessor
definitions and include directories are detected as expected.
Diffstat (limited to 'test')
-rw-r--r-- | test/CMakeLists.txt | 22 | ||||
-rw-r--r-- | test/cc-gnu.c | 15 | ||||
-rw-r--r-- | test/cc-msvc.c | 10 | ||||
-rw-r--r-- | test/cc-msvc.cmake | 1 | ||||
-rw-r--r-- | test/expect/cmd.cc-gnu-c-E.stderr.txt | 1 | ||||
-rw-r--r-- | test/expect/cmd.cc-gnu-c-E.stdout.txt | 1 | ||||
-rw-r--r-- | test/expect/cmd.cc-gnu-c-cmd.stderr.txt | 1 | ||||
-rw-r--r-- | test/expect/cmd.cc-gnu-c-cmd.stdout.txt | 1 | ||||
-rw-r--r-- | test/expect/cmd.cc-gnu-cxx-E.stderr.txt | 1 | ||||
-rw-r--r-- | test/expect/cmd.cc-gnu-cxx-E.stdout.txt | 1 | ||||
-rw-r--r-- | test/expect/cmd.cc-gnu-cxx-cmd.stderr.txt | 1 | ||||
-rw-r--r-- | test/expect/cmd.cc-gnu-cxx-cmd.stdout.txt | 1 | ||||
-rw-r--r-- | test/expect/cmd.cc-msvc-c-E.stderr.txt | 1 | ||||
-rw-r--r-- | test/expect/cmd.cc-msvc-c-E.stdout.txt | 1 | ||||
-rw-r--r-- | test/expect/cmd.cc-msvc-c-cmd.stderr.txt | 1 | ||||
-rw-r--r-- | test/expect/cmd.cc-msvc-c-cmd.stdout.txt | 1 | ||||
-rw-r--r-- | test/expect/cmd.cc-msvc-cxx-E.stderr.txt | 1 | ||||
-rw-r--r-- | test/expect/cmd.cc-msvc-cxx-E.stdout.txt | 1 | ||||
-rw-r--r-- | test/expect/cmd.cc-msvc-cxx-cmd.stderr.txt | 1 | ||||
-rw-r--r-- | test/expect/cmd.cc-msvc-cxx-cmd.stdout.txt | 1 | ||||
-rw-r--r-- | test/run.cmake | 4 |
21 files changed, 68 insertions, 0 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 902f892..618e617 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -14,6 +14,11 @@ # limitations under the License. #============================================================================= +# Keep test binaries away from main binaries. +unset(CMAKE_RUNTIME_OUTPUT_DIRECTORY) +unset(CMAKE_LIBRARY_OUTPUT_DIRECTORY) +unset(CMAKE_ARCHIVE_OUTPUT_DIRECTORY) + find_package(LibXml2 QUIET) macro(castxml_test_cmd test) @@ -23,6 +28,7 @@ macro(castxml_test_cmd test) COMMAND ${CMAKE_COMMAND} "-Dcommand:STRING=${command}" "-Dexpect=cmd.${test}" + ${castxml_test_cmd_extra_arguments} -P ${CMAKE_CURRENT_SOURCE_DIR}/run.cmake ) endmacro() @@ -113,6 +119,22 @@ castxml_test_cmd(rsp-empty @${input}/empty.rsp) castxml_test_cmd(rsp-missing @${input}/does-not-exist.rsp) castxml_test_cmd(rsp-o-missing @${input}/o-missing.rsp) +# Test --castxml-cc-gnu detection. +add_executable(cc-gnu cc-gnu.c) +castxml_test_cmd(cc-gnu-c-E --castxml-cc-gnu $<TARGET_FILE:cc-gnu> ${empty_c} -E -dM) +castxml_test_cmd(cc-gnu-c-cmd --castxml-cc-gnu $<TARGET_FILE:cc-gnu> ${empty_c} "-###") +castxml_test_cmd(cc-gnu-cxx-E --castxml-cc-gnu $<TARGET_FILE:cc-gnu> ${empty_cxx} -E -dM) +castxml_test_cmd(cc-gnu-cxx-cmd --castxml-cc-gnu $<TARGET_FILE:cc-gnu> ${empty_cxx} "-###") + +# Test --castxml-cc-msvc detection. +add_executable(cc-msvc cc-msvc.c) +set(castxml_test_cmd_extra_arguments "-Dprologue=${CMAKE_CURRENT_SOURCE_DIR}/cc-msvc.cmake") +castxml_test_cmd(cc-msvc-c-E --castxml-cc-msvc $<TARGET_FILE:cc-msvc> ${empty_c} -E -dM) +castxml_test_cmd(cc-msvc-c-cmd --castxml-cc-msvc $<TARGET_FILE:cc-msvc> ${empty_c} "-###") +castxml_test_cmd(cc-msvc-cxx-E --castxml-cc-msvc $<TARGET_FILE:cc-msvc> ${empty_cxx} -E -dM) +castxml_test_cmd(cc-msvc-cxx-cmd --castxml-cc-msvc $<TARGET_FILE:cc-msvc> ${empty_cxx} "-###") +unset(castxml_test_cmd_extra_arguments) + castxml_test_gccxml(ArrayType) castxml_test_gccxml(ArrayType-incomplete) castxml_test_gccxml(Class) diff --git a/test/cc-gnu.c b/test/cc-gnu.c new file mode 100644 index 0000000..b1cb2ea --- /dev/null +++ b/test/cc-gnu.c @@ -0,0 +1,15 @@ +#include <stdio.h> + +int main(void) +{ + fprintf(stdout, + "#define __cc_gnu__ 1\n" + ); + fprintf(stderr, + "#include <...> search starts here:\n" + " /some/include\n" + " /some/Frameworks\n" + " /some/CustomFW (framework directory)\n" + ); + return 0; +} diff --git a/test/cc-msvc.c b/test/cc-msvc.c new file mode 100644 index 0000000..8ddbac1 --- /dev/null +++ b/test/cc-msvc.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +int main(void) +{ + fprintf(stdout, + "\n" + "#define __cc_msvc__ 1\n" + ); + return 0; +} diff --git a/test/cc-msvc.cmake b/test/cc-msvc.cmake new file mode 100644 index 0000000..964de6d --- /dev/null +++ b/test/cc-msvc.cmake @@ -0,0 +1 @@ +set(ENV{INCLUDE} "/some/include;/some/other/include") diff --git a/test/expect/cmd.cc-gnu-c-E.stderr.txt b/test/expect/cmd.cc-gnu-c-E.stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/test/expect/cmd.cc-gnu-c-E.stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/test/expect/cmd.cc-gnu-c-E.stdout.txt b/test/expect/cmd.cc-gnu-c-E.stdout.txt new file mode 100644 index 0000000..0a4a576 --- /dev/null +++ b/test/expect/cmd.cc-gnu-c-E.stdout.txt @@ -0,0 +1 @@ +^#define __cc_gnu__ 1$ diff --git a/test/expect/cmd.cc-gnu-c-cmd.stderr.txt b/test/expect/cmd.cc-gnu-c-cmd.stderr.txt new file mode 100644 index 0000000..1ac617b --- /dev/null +++ b/test/expect/cmd.cc-gnu-c-cmd.stderr.txt @@ -0,0 +1 @@ +"clang" .* "-[^i][^"]*" "[^-"][^"]*" "-isystem" "/some/include" "-iframework" "/some/Frameworks" "-iframework" "/some/CustomFW" "-[^i] diff --git a/test/expect/cmd.cc-gnu-c-cmd.stdout.txt b/test/expect/cmd.cc-gnu-c-cmd.stdout.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/test/expect/cmd.cc-gnu-c-cmd.stdout.txt @@ -0,0 +1 @@ +^$ diff --git a/test/expect/cmd.cc-gnu-cxx-E.stderr.txt b/test/expect/cmd.cc-gnu-cxx-E.stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/test/expect/cmd.cc-gnu-cxx-E.stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/test/expect/cmd.cc-gnu-cxx-E.stdout.txt b/test/expect/cmd.cc-gnu-cxx-E.stdout.txt new file mode 100644 index 0000000..0a4a576 --- /dev/null +++ b/test/expect/cmd.cc-gnu-cxx-E.stdout.txt @@ -0,0 +1 @@ +^#define __cc_gnu__ 1$ diff --git a/test/expect/cmd.cc-gnu-cxx-cmd.stderr.txt b/test/expect/cmd.cc-gnu-cxx-cmd.stderr.txt new file mode 100644 index 0000000..1ac617b --- /dev/null +++ b/test/expect/cmd.cc-gnu-cxx-cmd.stderr.txt @@ -0,0 +1 @@ +"clang" .* "-[^i][^"]*" "[^-"][^"]*" "-isystem" "/some/include" "-iframework" "/some/Frameworks" "-iframework" "/some/CustomFW" "-[^i] diff --git a/test/expect/cmd.cc-gnu-cxx-cmd.stdout.txt b/test/expect/cmd.cc-gnu-cxx-cmd.stdout.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/test/expect/cmd.cc-gnu-cxx-cmd.stdout.txt @@ -0,0 +1 @@ +^$ diff --git a/test/expect/cmd.cc-msvc-c-E.stderr.txt b/test/expect/cmd.cc-msvc-c-E.stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/test/expect/cmd.cc-msvc-c-E.stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/test/expect/cmd.cc-msvc-c-E.stdout.txt b/test/expect/cmd.cc-msvc-c-E.stdout.txt new file mode 100644 index 0000000..21445c4 --- /dev/null +++ b/test/expect/cmd.cc-msvc-c-E.stdout.txt @@ -0,0 +1 @@ +^#define __cc_msvc__ 1$ diff --git a/test/expect/cmd.cc-msvc-c-cmd.stderr.txt b/test/expect/cmd.cc-msvc-c-cmd.stderr.txt new file mode 100644 index 0000000..fb9ae02 --- /dev/null +++ b/test/expect/cmd.cc-msvc-c-cmd.stderr.txt @@ -0,0 +1 @@ +"clang" .* "-[^i][^"]*" "[^-"][^"]*" "-isystem" "/some/include" "-isystem" "/some/other/include" "-[^i] diff --git a/test/expect/cmd.cc-msvc-c-cmd.stdout.txt b/test/expect/cmd.cc-msvc-c-cmd.stdout.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/test/expect/cmd.cc-msvc-c-cmd.stdout.txt @@ -0,0 +1 @@ +^$ diff --git a/test/expect/cmd.cc-msvc-cxx-E.stderr.txt b/test/expect/cmd.cc-msvc-cxx-E.stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/test/expect/cmd.cc-msvc-cxx-E.stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/test/expect/cmd.cc-msvc-cxx-E.stdout.txt b/test/expect/cmd.cc-msvc-cxx-E.stdout.txt new file mode 100644 index 0000000..21445c4 --- /dev/null +++ b/test/expect/cmd.cc-msvc-cxx-E.stdout.txt @@ -0,0 +1 @@ +^#define __cc_msvc__ 1$ diff --git a/test/expect/cmd.cc-msvc-cxx-cmd.stderr.txt b/test/expect/cmd.cc-msvc-cxx-cmd.stderr.txt new file mode 100644 index 0000000..fb9ae02 --- /dev/null +++ b/test/expect/cmd.cc-msvc-cxx-cmd.stderr.txt @@ -0,0 +1 @@ +"clang" .* "-[^i][^"]*" "[^-"][^"]*" "-isystem" "/some/include" "-isystem" "/some/other/include" "-[^i] diff --git a/test/expect/cmd.cc-msvc-cxx-cmd.stdout.txt b/test/expect/cmd.cc-msvc-cxx-cmd.stdout.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/test/expect/cmd.cc-msvc-cxx-cmd.stdout.txt @@ -0,0 +1 @@ +^$ diff --git a/test/run.cmake b/test/run.cmake index 854cf8c..0f027ec 100644 --- a/test/run.cmake +++ b/test/run.cmake @@ -19,6 +19,10 @@ if(xml) file(REMOVE "${xml}") endif() +if(prologue) + include(${prologue}) +endif() + execute_process( COMMAND ${command} OUTPUT_VARIABLE actual_stdout |