blob: 572b55890d474e8346775b2264e0816183a1633e [file] [log] [blame]
Nobuaki Sukegawa11da87e2016-09-10 14:02:19 +09001#
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 IIIc9ac8d22019-01-07 16:46:45 -050020# Unit tests for the compiler still require boost
21include(BoostMacros)
22REQUIRE_BOOST_HEADERS()
23set(BOOST_COMPONENTS unit_test_framework)
24REQUIRE_BOOST_LIBRARIES(BOOST_COMPONENTS)
Nobuaki Sukegawa11da87e2016-09-10 14:02:19 +090025
26if(${WITH_PLUGIN})
Nobuaki Sukegawa11da87e2016-09-10 14:02:19 +090027 # 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})
34 if(WITH_SHARED_LIB AND NOT MSVC)
35 target_link_libraries(plugintest
36 thriftc
37 ${Boost_LIBRARIES}
38 )
39 else()
40 target_link_libraries(plugintest
41 thriftc_static
42 thrift_static
43 ${Boost_LIBRARIES}
44 )
45 endif()
46 add_test(NAME PluginUnitTest COMMAND plugintest)
47
48 set(thrift-gen-mycpp_SOURCES
dtmuller052abc32016-07-26 11:58:28 +020049 ../src/thrift/generate/t_cpp_generator.cc
Nobuaki Sukegawa11da87e2016-09-10 14:02:19 +090050 plugin/cpp_plugin.cc
51 )
52 add_executable(thrift-gen-mycpp ${thrift-gen-mycpp_SOURCES})
53 if(WITH_SHARED_LIB AND NOT MSVC)
54 target_link_libraries(thrift-gen-mycpp thriftc)
55 else()
56 target_link_libraries(thrift-gen-mycpp thriftc_static thrift_static)
57 endif()
58
59 if(CMAKE_BUILD_TYPE STREQUAL "Debug")
60 set(BUILDTYPE "Debug")
61 else()
62 # RelWithDebInfo generates binaries in "Release" directory too
63 set(BUILDTYPE "Release")
64 endif()
65
66 set_directory_properties(PROPERTIES
67 ADDITIONAL_MAKE_CLEAN_FILES gen-cpp
68 ADDITIONAL_MAKE_CLEAN_FILES gen-mycpp)
69
70 file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/gen-cpp)
71 file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/gen-mycpp)
72 add_test(NAME PluginIntegrationTest
73 COMMAND ${CMAKE_COMMAND}
74 -DTHRIFT_COMPILER=${THRIFT_COMPILER}
75 -DBINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
76 -DBUILDTYPE=${BUILDTYPE}
77 -DCURDIR=${CMAKE_CURRENT_BINARY_DIR}
78 -DSRCDIR=${CMAKE_CURRENT_SOURCE_DIR}
79 -P ${CMAKE_CURRENT_SOURCE_DIR}/cpp_plugin_test.cmake)
80endif()
Mustafa Senol Cosar09c1f372018-04-04 15:25:28 +030081
nsrtvwls014f53f2018-09-28 08:11:21 -070082file(GLOB KEYWORD_SAMPLES "${CMAKE_CURRENT_SOURCE_DIR}/keyword-samples/*.thrift")
83foreach(LANG ${thrift_compiler_LANGS})
84 foreach(SAMPLE ${KEYWORD_SAMPLES})
85 get_filename_component(FILENAME ${SAMPLE} NAME_WE)
86 add_test(NAME "${LANG}_${FILENAME}"
87 COMMAND thrift-compiler --gen ${LANG} ${SAMPLE})
88 set_tests_properties("${LANG}_${FILENAME}" PROPERTIES
89 PASS_REGULAR_EXPRESSION "Cannot use reserved language keyword")
90 endforeach()
91endforeach()
92
93
Mustafa Senol Cosar09c1f372018-04-04 15:25:28 +030094find_package(PythonInterp REQUIRED)
nsrtvwls014f53f2018-09-28 08:11:21 -070095add_test(NAME StalenessCheckTest COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/compiler/staleness_check.py ${THRIFT_COMPILER})