Upgrading dependency to Thrift 0.12.0
This commit is contained in:
parent
3e4590dcc0
commit
356978cb42
1302 changed files with 101701 additions and 26784 deletions
15
vendor/git.apache.org/thrift.git/compiler/cpp/test/CMakeLists.txt
generated
vendored
15
vendor/git.apache.org/thrift.git/compiler/cpp/test/CMakeLists.txt
generated
vendored
|
@ -75,3 +75,18 @@ if(${WITH_PLUGIN})
|
|||
-DSRCDIR=${CMAKE_CURRENT_SOURCE_DIR}
|
||||
-P ${CMAKE_CURRENT_SOURCE_DIR}/cpp_plugin_test.cmake)
|
||||
endif()
|
||||
|
||||
file(GLOB KEYWORD_SAMPLES "${CMAKE_CURRENT_SOURCE_DIR}/keyword-samples/*.thrift")
|
||||
foreach(LANG ${thrift_compiler_LANGS})
|
||||
foreach(SAMPLE ${KEYWORD_SAMPLES})
|
||||
get_filename_component(FILENAME ${SAMPLE} NAME_WE)
|
||||
add_test(NAME "${LANG}_${FILENAME}"
|
||||
COMMAND thrift-compiler --gen ${LANG} ${SAMPLE})
|
||||
set_tests_properties("${LANG}_${FILENAME}" PROPERTIES
|
||||
PASS_REGULAR_EXPRESSION "Cannot use reserved language keyword")
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
|
||||
find_package(PythonInterp REQUIRED)
|
||||
add_test(NAME StalenessCheckTest COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/compiler/staleness_check.py ${THRIFT_COMPILER})
|
||||
|
|
13
vendor/git.apache.org/thrift.git/compiler/cpp/test/Makefile.am
generated
vendored
13
vendor/git.apache.org/thrift.git/compiler/cpp/test/Makefile.am
generated
vendored
|
@ -32,6 +32,8 @@ check_PROGRAMS = plugintest
|
|||
|
||||
noinst_PROGRAMS = thrift-gen-mycpp
|
||||
|
||||
all-local: thrift-gen-bincat
|
||||
|
||||
AM_CPPFLAGS += -I$(top_srcdir)/lib/cpp/src -I$(top_builddir)/lib/cpp/src
|
||||
|
||||
plugintest_SOURCES = plugin/conversion_test.cc
|
||||
|
@ -43,9 +45,16 @@ thrift_gen_mycpp_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/compiler/cpp -I$(top_
|
|||
thrift_gen_mycpp_LDADD = $(top_builddir)/compiler/cpp/libthriftc.la
|
||||
|
||||
cpp_plugin_test.sh: thrift-gen-mycpp
|
||||
TESTS = $(check_PROGRAMS) cpp_plugin_test.sh
|
||||
|
||||
thrift-gen-bincat:
|
||||
cp bincat.sh $@
|
||||
chmod 755 $@
|
||||
|
||||
plugin_stability_test.sh: thrift-gen-bincat
|
||||
|
||||
TESTS = $(check_PROGRAMS) cpp_plugin_test.sh plugin_stability_test.sh
|
||||
|
||||
clean-local:
|
||||
$(RM) -rf gen-cpp gen-mycpp
|
||||
$(RM) -rf gen-cpp gen-mycpp gen-bincat thrift-gen-bincat
|
||||
|
||||
endif
|
||||
|
|
3
vendor/git.apache.org/thrift.git/compiler/cpp/test/bincat.sh
generated
vendored
Executable file
3
vendor/git.apache.org/thrift.git/compiler/cpp/test/bincat.sh
generated
vendored
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
exec /bin/cat
|
18
vendor/git.apache.org/thrift.git/compiler/cpp/test/compiler/Included.thrift
generated
vendored
Normal file
18
vendor/git.apache.org/thrift.git/compiler/cpp/test/compiler/Included.thrift
generated
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
const string foo = "bar"
|
||||
|
||||
struct a_struct {
|
||||
1: bool im_true,
|
||||
2: bool im_false,
|
||||
3: i8 a_bite,
|
||||
4: i16 integer16,
|
||||
5: i32 integer32,
|
||||
6: i64 integer64,
|
||||
7: double double_precision,
|
||||
8: string some_characters,
|
||||
9: string zomg_unicode,
|
||||
10: bool what_who,
|
||||
}
|
||||
|
||||
service AService {
|
||||
i32 a_procedure(1: i32 arg)
|
||||
}
|
7
vendor/git.apache.org/thrift.git/compiler/cpp/test/compiler/Including.thrift
generated
vendored
Normal file
7
vendor/git.apache.org/thrift.git/compiler/cpp/test/compiler/Including.thrift
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
include "Included.thrift"
|
||||
|
||||
const string s = "string"
|
||||
|
||||
struct BStruct {
|
||||
1: Included.a_struct one_of_each
|
||||
}
|
1
vendor/git.apache.org/thrift.git/compiler/cpp/test/compiler/Single.thrift
generated
vendored
Normal file
1
vendor/git.apache.org/thrift.git/compiler/cpp/test/compiler/Single.thrift
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
const string foo = "bar"
|
142
vendor/git.apache.org/thrift.git/compiler/cpp/test/compiler/staleness_check.py
generated
vendored
Executable file
142
vendor/git.apache.org/thrift.git/compiler/cpp/test/compiler/staleness_check.py
generated
vendored
Executable file
|
@ -0,0 +1,142 @@
|
|||
#!/usr/bin/env python3
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
from __future__ import print_function
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
import unittest
|
||||
|
||||
|
||||
class TestStalenessCheck(unittest.TestCase):
|
||||
|
||||
CURRENT_DIR_PATH = os.path.dirname(os.path.realpath(__file__))
|
||||
THRIFT_EXECUTABLE_PATH = None
|
||||
SINGLE_THRIFT_FILE_PATH = os.path.join(CURRENT_DIR_PATH, "Single.thrift")
|
||||
INCLUDING_THRIFT_FILE_PATH = os.path.join(CURRENT_DIR_PATH, "Including.thrift")
|
||||
INCLUDED_THRIFT_FILE_PATH = os.path.join(CURRENT_DIR_PATH, "Included.thrift")
|
||||
|
||||
def test_staleness_check_of_single_thrift_file_without_changed_output(self):
|
||||
temp_dir = tempfile.mkdtemp(dir=TestStalenessCheck.CURRENT_DIR_PATH)
|
||||
|
||||
command = [TestStalenessCheck.THRIFT_EXECUTABLE_PATH, "-gen", "cpp", "-o", temp_dir]
|
||||
command += [TestStalenessCheck.SINGLE_THRIFT_FILE_PATH]
|
||||
subprocess.call(command)
|
||||
|
||||
used_file_path = os.path.join(temp_dir, "gen-cpp", "Single_constants.cpp")
|
||||
|
||||
first_modification_time = os.path.getmtime(os.path.join(used_file_path))
|
||||
|
||||
time.sleep(0.1)
|
||||
|
||||
subprocess.call(command)
|
||||
|
||||
second_modification_time = os.path.getmtime(used_file_path)
|
||||
|
||||
self.assertEqual(second_modification_time, first_modification_time)
|
||||
|
||||
shutil.rmtree(temp_dir, ignore_errors=True)
|
||||
|
||||
def test_staleness_check_of_single_thrift_file_with_changed_output(self):
|
||||
temp_dir = tempfile.mkdtemp(dir=TestStalenessCheck.CURRENT_DIR_PATH)
|
||||
|
||||
command = [TestStalenessCheck.THRIFT_EXECUTABLE_PATH, "-gen", "cpp", "-o", temp_dir]
|
||||
command += [TestStalenessCheck.SINGLE_THRIFT_FILE_PATH]
|
||||
subprocess.call(command)
|
||||
|
||||
used_file_path = os.path.join(temp_dir, "gen-cpp", "Single_constants.cpp")
|
||||
|
||||
first_modification_time = os.path.getmtime(os.path.join(used_file_path))
|
||||
used_file = open(used_file_path, "r")
|
||||
first_contents = used_file.read()
|
||||
used_file.close()
|
||||
|
||||
used_file = open(used_file_path, "a")
|
||||
used_file.write("\n/* This is a comment */\n")
|
||||
used_file.close()
|
||||
|
||||
time.sleep(0.1)
|
||||
|
||||
subprocess.call(command)
|
||||
|
||||
second_modification_time = os.path.getmtime(used_file_path)
|
||||
used_file = open(used_file_path, "r")
|
||||
second_contents = used_file.read()
|
||||
used_file.close()
|
||||
|
||||
self.assertGreater(second_modification_time, first_modification_time)
|
||||
self.assertEqual(first_contents, second_contents)
|
||||
|
||||
shutil.rmtree(temp_dir, ignore_errors=True)
|
||||
|
||||
def test_staleness_check_of_included_file(self):
|
||||
temp_dir = tempfile.mkdtemp(dir=TestStalenessCheck.CURRENT_DIR_PATH)
|
||||
|
||||
temp_included_file_path = os.path.join(temp_dir, "Included.thrift")
|
||||
temp_including_file_path = os.path.join(temp_dir, "Including.thrift")
|
||||
|
||||
shutil.copy2(TestStalenessCheck.INCLUDED_THRIFT_FILE_PATH, temp_included_file_path)
|
||||
shutil.copy2(TestStalenessCheck.INCLUDING_THRIFT_FILE_PATH, temp_including_file_path)
|
||||
|
||||
command = [TestStalenessCheck.THRIFT_EXECUTABLE_PATH, "-gen", "cpp", "-recurse", "-o", temp_dir]
|
||||
command += [temp_including_file_path]
|
||||
|
||||
subprocess.call(command)
|
||||
|
||||
included_constants_cpp_file_path = os.path.join(temp_dir, "gen-cpp", "Included_constants.cpp")
|
||||
including_constants_cpp_file_path = os.path.join(temp_dir, "gen-cpp", "Including_constants.cpp")
|
||||
|
||||
included_constants_cpp_first_modification_time = os.path.getmtime(included_constants_cpp_file_path)
|
||||
including_constants_cpp_first_modification_time = os.path.getmtime(including_constants_cpp_file_path)
|
||||
|
||||
temp_included_file = open(temp_included_file_path, "a")
|
||||
temp_included_file.write("\nconst i32 an_integer = 42\n")
|
||||
temp_included_file.close()
|
||||
|
||||
time.sleep(0.1)
|
||||
|
||||
subprocess.call(command)
|
||||
|
||||
included_constants_cpp_second_modification_time = os.path.getmtime(included_constants_cpp_file_path)
|
||||
including_constants_cpp_second_modification_time = os.path.getmtime(including_constants_cpp_file_path)
|
||||
|
||||
self.assertGreater(
|
||||
included_constants_cpp_second_modification_time, included_constants_cpp_first_modification_time)
|
||||
self.assertEqual(
|
||||
including_constants_cpp_first_modification_time, including_constants_cpp_second_modification_time)
|
||||
|
||||
shutil.rmtree(temp_dir, ignore_errors=True)
|
||||
|
||||
|
||||
def suite():
|
||||
suite = unittest.TestSuite()
|
||||
loader = unittest.TestLoader()
|
||||
suite.addTest(loader.loadTestsFromTestCase(TestStalenessCheck))
|
||||
return suite
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# The path of Thrift compiler is passed as an argument to the test script.
|
||||
# Remove it to not confuse the unit testing framework
|
||||
TestStalenessCheck.THRIFT_EXECUTABLE_PATH = sys.argv[-1]
|
||||
del sys.argv[-1]
|
||||
unittest.main(defaultTest="suite", testRunner=unittest.TextTestRunner(verbosity=2))
|
1
vendor/git.apache.org/thrift.git/compiler/cpp/test/keyword-samples/const1_return.thrift
generated
vendored
Normal file
1
vendor/git.apache.org/thrift.git/compiler/cpp/test/keyword-samples/const1_return.thrift
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
const bool return = 0
|
2
vendor/git.apache.org/thrift.git/compiler/cpp/test/keyword-samples/enum1_return.thrift
generated
vendored
Normal file
2
vendor/git.apache.org/thrift.git/compiler/cpp/test/keyword-samples/enum1_return.thrift
generated
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
enum return {
|
||||
}
|
3
vendor/git.apache.org/thrift.git/compiler/cpp/test/keyword-samples/enum2_return.thrift
generated
vendored
Normal file
3
vendor/git.apache.org/thrift.git/compiler/cpp/test/keyword-samples/enum2_return.thrift
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
enum enum_name {
|
||||
return
|
||||
}
|
1
vendor/git.apache.org/thrift.git/compiler/cpp/test/keyword-samples/exception1_return.thrift
generated
vendored
Normal file
1
vendor/git.apache.org/thrift.git/compiler/cpp/test/keyword-samples/exception1_return.thrift
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
exception return {}
|
3
vendor/git.apache.org/thrift.git/compiler/cpp/test/keyword-samples/exception2_return.thrift
generated
vendored
Normal file
3
vendor/git.apache.org/thrift.git/compiler/cpp/test/keyword-samples/exception2_return.thrift
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
exception exception_name {
|
||||
1: required i8 return
|
||||
}
|
1
vendor/git.apache.org/thrift.git/compiler/cpp/test/keyword-samples/service1_return.thrift
generated
vendored
Normal file
1
vendor/git.apache.org/thrift.git/compiler/cpp/test/keyword-samples/service1_return.thrift
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
service return {}
|
3
vendor/git.apache.org/thrift.git/compiler/cpp/test/keyword-samples/service2_return.thrift
generated
vendored
Normal file
3
vendor/git.apache.org/thrift.git/compiler/cpp/test/keyword-samples/service2_return.thrift
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
service service_name {
|
||||
bool function_name(1: i32 return)
|
||||
}
|
3
vendor/git.apache.org/thrift.git/compiler/cpp/test/keyword-samples/service3_return.thrift
generated
vendored
Normal file
3
vendor/git.apache.org/thrift.git/compiler/cpp/test/keyword-samples/service3_return.thrift
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
service service_name {
|
||||
void return()
|
||||
}
|
5
vendor/git.apache.org/thrift.git/compiler/cpp/test/keyword-samples/service4_return.thrift
generated
vendored
Normal file
5
vendor/git.apache.org/thrift.git/compiler/cpp/test/keyword-samples/service4_return.thrift
generated
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
exception exception_name {}
|
||||
|
||||
service service_name {
|
||||
void function_name() throws ( 1: exception_name return)
|
||||
}
|
1
vendor/git.apache.org/thrift.git/compiler/cpp/test/keyword-samples/struct1_return.thrift
generated
vendored
Normal file
1
vendor/git.apache.org/thrift.git/compiler/cpp/test/keyword-samples/struct1_return.thrift
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
struct return {}
|
3
vendor/git.apache.org/thrift.git/compiler/cpp/test/keyword-samples/struct2_return.thrift
generated
vendored
Normal file
3
vendor/git.apache.org/thrift.git/compiler/cpp/test/keyword-samples/struct2_return.thrift
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
struct struct_name {
|
||||
1: required bool return = 1
|
||||
}
|
1
vendor/git.apache.org/thrift.git/compiler/cpp/test/keyword-samples/typedef1_return.thrift
generated
vendored
Normal file
1
vendor/git.apache.org/thrift.git/compiler/cpp/test/keyword-samples/typedef1_return.thrift
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
typedef bool return
|
1
vendor/git.apache.org/thrift.git/compiler/cpp/test/keyword-samples/union1_return.thrift
generated
vendored
Normal file
1
vendor/git.apache.org/thrift.git/compiler/cpp/test/keyword-samples/union1_return.thrift
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
union return {}
|
3
vendor/git.apache.org/thrift.git/compiler/cpp/test/keyword-samples/union2_return.thrift
generated
vendored
Normal file
3
vendor/git.apache.org/thrift.git/compiler/cpp/test/keyword-samples/union2_return.thrift
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
union union_name {
|
||||
1: optional bool return=1
|
||||
}
|
6
vendor/git.apache.org/thrift.git/compiler/cpp/test/plugin/conversion_test.cc
generated
vendored
6
vendor/git.apache.org/thrift.git/compiler/cpp/test/plugin/conversion_test.cc
generated
vendored
|
@ -234,6 +234,8 @@ void migrate_global_cache() {
|
|||
template <typename T>
|
||||
T* round_trip(T* t) {
|
||||
typename plugin::ToType<T>::type p;
|
||||
plugin::clear_global_cache();
|
||||
plugin_output::clear_global_cache();
|
||||
plugin_output::convert(t, p);
|
||||
migrate_global_cache();
|
||||
return plugin::convert(p);
|
||||
|
@ -275,12 +277,12 @@ void test_const_value(t_const_value* sut) {
|
|||
BOOST_CHECK_EQUAL(sut->get_map().size(), sut2->get_map().size());
|
||||
{
|
||||
std::map<t_const_value::t_const_value_type, t_const_value::t_const_value_type> sut_values;
|
||||
for (std::map<t_const_value*, t_const_value*>::const_iterator it = sut->get_map().begin();
|
||||
for (std::map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator it = sut->get_map().begin();
|
||||
it != sut->get_map().end(); it++) {
|
||||
sut_values[it->first->get_type()] = it->second->get_type();
|
||||
}
|
||||
std::map<t_const_value::t_const_value_type, t_const_value::t_const_value_type> sut2_values;
|
||||
for (std::map<t_const_value*, t_const_value*>::const_iterator it = sut2->get_map().begin();
|
||||
for (std::map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator it = sut2->get_map().begin();
|
||||
it != sut2->get_map().end(); it++) {
|
||||
sut2_values[it->first->get_type()] = it->second->get_type();
|
||||
}
|
||||
|
|
32
vendor/git.apache.org/thrift.git/compiler/cpp/test/plugin_stability_test.sh
generated
vendored
Executable file
32
vendor/git.apache.org/thrift.git/compiler/cpp/test/plugin_stability_test.sh
generated
vendored
Executable file
|
@ -0,0 +1,32 @@
|
|||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
|
||||
# this file is intended to be invoked by make.
|
||||
#
|
||||
# This file runs the compiler twice, using a plugin that just invokes
|
||||
# /bin/cat, and compares the output. If GeneratorInput is
|
||||
# nondeterminsitic, you'd expect the output to differ from run-to-run.
|
||||
# So this tests that in fact, the output is stable from run-to-run.
|
||||
set -e
|
||||
mkdir -p gen-bincat
|
||||
PATH=.:"$PATH" ../thrift -r -gen bincat ../../../test/Include.thrift > gen-bincat/1.ser
|
||||
PATH=.:"$PATH" ../thrift -r -gen bincat ../../../test/Include.thrift > gen-bincat/2.ser
|
||||
diff --binary gen-bincat/1.ser gen-bincat/2.ser
|
Loading…
Add table
Add a link
Reference in a new issue