Nobuaki Sukegawa | 11da87e | 2016-09-10 14:02:19 +0900 | [diff] [blame] | 1 | # |
| 2 | # Licensed to the Apache Software Foundation (ASF) under one |
| 3 | # or more contributor license agreements. See the NOTICE file |
| 4 | # distributed with this work for additional information |
| 5 | # regarding copyright ownership. The ASF licenses this file |
| 6 | # to you under the Apache License, Version 2.0 (the |
| 7 | # "License"); you may not use this file except in compliance |
| 8 | # with the License. You may obtain a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, |
| 13 | # software distributed under the License is distributed on an |
| 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | # KIND, either express or implied. See the License for the |
| 16 | # specific language governing permissions and limitations |
| 17 | # under the License. |
| 18 | # |
| 19 | |
James E. King III | c9ac8d2 | 2019-01-07 16:46:45 -0500 | [diff] [blame] | 20 | # Unit tests for the compiler still require boost |
| 21 | include(BoostMacros) |
| 22 | REQUIRE_BOOST_HEADERS() |
| 23 | set(BOOST_COMPONENTS unit_test_framework) |
| 24 | REQUIRE_BOOST_LIBRARIES(BOOST_COMPONENTS) |
Nobuaki Sukegawa | 11da87e | 2016-09-10 14:02:19 +0900 | [diff] [blame] | 25 | |
| 26 | if(${WITH_PLUGIN}) |
Nobuaki Sukegawa | 11da87e | 2016-09-10 14:02:19 +0900 | [diff] [blame] | 27 | # Make sure gen-cpp files can be included |
| 28 | include_directories("${CMAKE_CURRENT_BINARY_DIR}") |
| 29 | |
| 30 | set(plugintest_SOURCES |
| 31 | plugin/conversion_test.cc |
| 32 | ) |
| 33 | add_executable(plugintest ${plugintest_SOURCES}) |
James E. King III | 278528c | 2019-01-11 12:17:44 -0500 | [diff] [blame] | 34 | target_link_libraries(plugintest |
| 35 | thriftc |
| 36 | ${Boost_LIBRARIES} |
| 37 | ) |
Nobuaki Sukegawa | 11da87e | 2016-09-10 14:02:19 +0900 | [diff] [blame] | 38 | add_test(NAME PluginUnitTest COMMAND plugintest) |
| 39 | |
| 40 | set(thrift-gen-mycpp_SOURCES |
dtmuller | 052abc3 | 2016-07-26 11:58:28 +0200 | [diff] [blame] | 41 | ../src/thrift/generate/t_cpp_generator.cc |
Nobuaki Sukegawa | 11da87e | 2016-09-10 14:02:19 +0900 | [diff] [blame] | 42 | plugin/cpp_plugin.cc |
| 43 | ) |
| 44 | add_executable(thrift-gen-mycpp ${thrift-gen-mycpp_SOURCES}) |
James E. King III | 278528c | 2019-01-11 12:17:44 -0500 | [diff] [blame] | 45 | target_link_libraries(thrift-gen-mycpp thriftc) |
Nobuaki Sukegawa | 11da87e | 2016-09-10 14:02:19 +0900 | [diff] [blame] | 46 | |
| 47 | if(CMAKE_BUILD_TYPE STREQUAL "Debug") |
| 48 | set(BUILDTYPE "Debug") |
| 49 | else() |
| 50 | # RelWithDebInfo generates binaries in "Release" directory too |
| 51 | set(BUILDTYPE "Release") |
| 52 | endif() |
| 53 | |
| 54 | set_directory_properties(PROPERTIES |
| 55 | ADDITIONAL_MAKE_CLEAN_FILES gen-cpp |
| 56 | ADDITIONAL_MAKE_CLEAN_FILES gen-mycpp) |
| 57 | |
| 58 | file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/gen-cpp) |
| 59 | file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/gen-mycpp) |
| 60 | add_test(NAME PluginIntegrationTest |
| 61 | COMMAND ${CMAKE_COMMAND} |
| 62 | -DTHRIFT_COMPILER=${THRIFT_COMPILER} |
| 63 | -DBINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} |
| 64 | -DBUILDTYPE=${BUILDTYPE} |
| 65 | -DCURDIR=${CMAKE_CURRENT_BINARY_DIR} |
| 66 | -DSRCDIR=${CMAKE_CURRENT_SOURCE_DIR} |
| 67 | -P ${CMAKE_CURRENT_SOURCE_DIR}/cpp_plugin_test.cmake) |
| 68 | endif() |
Mustafa Senol Cosar | 09c1f37 | 2018-04-04 15:25:28 +0300 | [diff] [blame] | 69 | |
nsrtvwls | 014f53f | 2018-09-28 08:11:21 -0700 | [diff] [blame] | 70 | file(GLOB KEYWORD_SAMPLES "${CMAKE_CURRENT_SOURCE_DIR}/keyword-samples/*.thrift") |
| 71 | foreach(LANG ${thrift_compiler_LANGS}) |
| 72 | foreach(SAMPLE ${KEYWORD_SAMPLES}) |
| 73 | get_filename_component(FILENAME ${SAMPLE} NAME_WE) |
| 74 | add_test(NAME "${LANG}_${FILENAME}" |
| 75 | COMMAND thrift-compiler --gen ${LANG} ${SAMPLE}) |
| 76 | set_tests_properties("${LANG}_${FILENAME}" PROPERTIES |
| 77 | PASS_REGULAR_EXPRESSION "Cannot use reserved language keyword") |
| 78 | endforeach() |
| 79 | endforeach() |
| 80 | |
| 81 | |
James E. King III | 278528c | 2019-01-11 12:17:44 -0500 | [diff] [blame] | 82 | find_package(PythonInterp QUIET) |
| 83 | if(PYTHONINTERP_FOUND) |
| 84 | add_test(NAME StalenessCheckTest COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/compiler/staleness_check.py ${THRIFT_COMPILER}) |
| 85 | else() |
| 86 | message(WARNING "Skipping StalenessCheckTest as there is no python interpreter available.") |
| 87 | endif() |