From d0a79d4808a8d28aba3873e8e6225b31b5b57a54 Mon Sep 17 00:00:00 2001 From: "evgeny.bovykin" Date: Wed, 25 Sep 2024 12:42:18 +0200 Subject: [PATCH] Add workspace tests --- pilota-build/src/codegen/workspace.rs | 4 +- pilota-build/src/test/mod.rs | 119 ++++- .../test_data/thrift_workspace/apache.thrift | 426 ++++++++++++++++++ .../thrift_workspace/auto_name.thrift | 33 ++ .../thrift_workspace/binary_bytes.thrift | 4 + .../thrift_workspace/const_val.thrift | 20 + .../thrift_workspace/decode_error.thrift | 14 + .../thrift_workspace/default_value.thrift | 29 ++ .../thrift_workspace/enum_map.thrift | 14 + .../thrift_workspace/enum_test.thrift | 20 + .../test_data/thrift_workspace/multi.thrift | 11 + .../test_data/thrift_workspace/normal.thrift | 37 ++ .../thrift_workspace/path_keyword.thrift | 5 + .../thrift_workspace/pilota_name.thrift | 20 + .../thrift_workspace/recursive_type.thrift | 12 + .../test_data/thrift_workspace/self_kw.thrift | 10 + .../test_data/thrift_workspace/string.thrift | 4 + .../test_data/thrift_workspace/union.thrift | 12 + .../test_data/thrift_workspace/void.thrift | 3 + .../thrift_workspace/wrapper_arc.thrift | 13 + .../thrift_workspace_with_split/apache.thrift | 426 ++++++++++++++++++ .../auto_name.thrift | 33 ++ .../binary_bytes.thrift | 4 + .../const_val.thrift | 20 + .../decode_error.thrift | 14 + .../default_value.thrift | 29 ++ .../enum_map.thrift | 14 + .../enum_test.thrift | 20 + .../thrift_workspace_with_split/multi.thrift | 11 + .../thrift_workspace_with_split/normal.thrift | 37 ++ .../path_keyword.thrift | 5 + .../pilota_name.thrift | 20 + .../recursive_type.thrift | 12 + .../self_kw.thrift | 10 + .../thrift_workspace_with_split/string.thrift | 4 + .../thrift_workspace_with_split/union.thrift | 12 + .../thrift_workspace_with_split/void.thrift | 3 + .../wrapper_arc.thrift | 13 + 38 files changed, 1494 insertions(+), 3 deletions(-) create mode 100644 pilota-build/test_data/thrift_workspace/apache.thrift create mode 100644 pilota-build/test_data/thrift_workspace/auto_name.thrift create mode 100644 pilota-build/test_data/thrift_workspace/binary_bytes.thrift create mode 100644 pilota-build/test_data/thrift_workspace/const_val.thrift create mode 100644 pilota-build/test_data/thrift_workspace/decode_error.thrift create mode 100644 pilota-build/test_data/thrift_workspace/default_value.thrift create mode 100644 pilota-build/test_data/thrift_workspace/enum_map.thrift create mode 100644 pilota-build/test_data/thrift_workspace/enum_test.thrift create mode 100644 pilota-build/test_data/thrift_workspace/multi.thrift create mode 100644 pilota-build/test_data/thrift_workspace/normal.thrift create mode 100644 pilota-build/test_data/thrift_workspace/path_keyword.thrift create mode 100644 pilota-build/test_data/thrift_workspace/pilota_name.thrift create mode 100644 pilota-build/test_data/thrift_workspace/recursive_type.thrift create mode 100644 pilota-build/test_data/thrift_workspace/self_kw.thrift create mode 100644 pilota-build/test_data/thrift_workspace/string.thrift create mode 100644 pilota-build/test_data/thrift_workspace/union.thrift create mode 100644 pilota-build/test_data/thrift_workspace/void.thrift create mode 100644 pilota-build/test_data/thrift_workspace/wrapper_arc.thrift create mode 100644 pilota-build/test_data/thrift_workspace_with_split/apache.thrift create mode 100644 pilota-build/test_data/thrift_workspace_with_split/auto_name.thrift create mode 100644 pilota-build/test_data/thrift_workspace_with_split/binary_bytes.thrift create mode 100644 pilota-build/test_data/thrift_workspace_with_split/const_val.thrift create mode 100644 pilota-build/test_data/thrift_workspace_with_split/decode_error.thrift create mode 100644 pilota-build/test_data/thrift_workspace_with_split/default_value.thrift create mode 100644 pilota-build/test_data/thrift_workspace_with_split/enum_map.thrift create mode 100644 pilota-build/test_data/thrift_workspace_with_split/enum_test.thrift create mode 100644 pilota-build/test_data/thrift_workspace_with_split/multi.thrift create mode 100644 pilota-build/test_data/thrift_workspace_with_split/normal.thrift create mode 100644 pilota-build/test_data/thrift_workspace_with_split/path_keyword.thrift create mode 100644 pilota-build/test_data/thrift_workspace_with_split/pilota_name.thrift create mode 100644 pilota-build/test_data/thrift_workspace_with_split/recursive_type.thrift create mode 100644 pilota-build/test_data/thrift_workspace_with_split/self_kw.thrift create mode 100644 pilota-build/test_data/thrift_workspace_with_split/string.thrift create mode 100644 pilota-build/test_data/thrift_workspace_with_split/union.thrift create mode 100644 pilota-build/test_data/thrift_workspace_with_split/void.thrift create mode 100644 pilota-build/test_data/thrift_workspace_with_split/wrapper_arc.thrift diff --git a/pilota-build/src/codegen/workspace.rs b/pilota-build/src/codegen/workspace.rs index 72f929a9..2cff6189 100644 --- a/pilota-build/src/codegen/workspace.rs +++ b/pilota-build/src/codegen/workspace.rs @@ -184,6 +184,8 @@ where Command::new("cargo") .arg("init") .arg("--lib") + .arg("--vcs") + .arg("none") .current_dir(base_dir.as_ref()) .arg(&*info.name), )?; @@ -246,7 +248,7 @@ where def_id, kind: super::CodegenKind::RePub, })), - base_dir.as_ref(), + base_dir.as_ref().join(&*info.name).join("src").as_path(), ); if let Some(main_mod_path) = info.main_mod_path { gen_rs_stream.push_str(&format!( diff --git a/pilota-build/src/test/mod.rs b/pilota-build/src/test/mod.rs index ff8bf1dd..b594b8a7 100644 --- a/pilota-build/src/test/mod.rs +++ b/pilota-build/src/test/mod.rs @@ -1,7 +1,7 @@ #![cfg(test)] use std::{fs, path::Path}; - +use std::fs::File; use tempfile::tempdir; use crate::{plugin::SerdePlugin, IdlService}; @@ -45,7 +45,14 @@ fn diff_dir(old: impl AsRef, new: impl AsRef) { if !corresponding_new_file.exists() { panic!("File {:?} does not exist in the new directory", file_name); } - diff_file(old_file, corresponding_new_file); + + if old_file.is_file() && corresponding_new_file.is_file() { + diff_file(old_file, corresponding_new_file); + } else if !old_file.is_file() && !corresponding_new_file.is_file() { + diff_dir(old_file, corresponding_new_file) + } else { + panic!("{} and {} are not both files or directories", old_file.to_str().unwrap(), corresponding_new_file.to_str().unwrap()); + } } } @@ -85,6 +92,41 @@ fn test_with_builder( } } +fn test_with_builder_workspace( + source: impl AsRef, + target: impl AsRef, + f: F, +) { + if std::env::var("UPDATE_TEST_DATA").as_deref() == Ok("1") { + fs::remove_dir(&target); + fs::create_dir_all(&target).unwrap(); + let cargo_toml_path = target.as_ref().join("Cargo.toml"); + File::create(cargo_toml_path).unwrap(); + + f(source.as_ref(), target.as_ref()); + } else { + let dir = tempdir().unwrap(); + let path = dir.path().join( + target + .as_ref() + .file_name() + .and_then(|s| s.to_str()) + .unwrap(), + ); + let mut base_dir_tmp = path.clone(); + base_dir_tmp.pop(); + base_dir_tmp.push(path.file_stem().unwrap()); + println!("{path:?}"); + + fs::create_dir_all(&path).unwrap(); + let cargo_toml_path = path.join("Cargo.toml"); + File::create(cargo_toml_path).unwrap(); + + f(source.as_ref(), &path); + diff_dir(target, base_dir_tmp); + } +} + fn test_with_split_builder( source: impl AsRef, target: impl AsRef, @@ -125,6 +167,29 @@ fn test_thrift(source: impl AsRef, target: impl AsRef) { }); } +fn test_thrift_workspace(source: impl AsRef, target: impl AsRef) { + test_with_builder_workspace(source, target, |source, target| { + crate::Builder::thrift() + .ignore_unused(false) + .compile_with_config( + vec![IdlService::from_path(source.to_owned())], + crate::Output::Workspace(target.into()), + ) + }); +} + +fn test_thrift_workspace_with_split(source: impl AsRef, target: impl AsRef) { + test_with_builder_workspace(source, target, |source, target| { + crate::Builder::thrift() + .ignore_unused(false) + .split_generated_files(true) + .compile_with_config( + vec![IdlService::from_path(source.to_owned())], + crate::Output::Workspace(target.into()), + ) + }); +} + fn test_thrift_with_split( source: impl AsRef, target: impl AsRef, @@ -186,6 +251,56 @@ fn test_thrift_gen() { }); } +#[test] +fn test_thrift_workspace_gen() { + let test_data_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("test_data") + .join("thrift_workspace"); + + test_data_dir.read_dir().unwrap().for_each(|f| { + let f = f.unwrap(); + + let path = f.path(); + + if let Some(ext) = path.extension() { + if ext == "thrift" { + let mut dir_path = path.clone(); + let buf = dir_path.clone(); + let dir_name = buf.file_stem().unwrap(); + dir_path.pop(); + dir_path.push(dir_name); + + test_thrift_workspace(path, dir_path); + } + } + }); +} + +#[test] +fn test_thrift_workspace_with_split_gen() { + let test_data_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("test_data") + .join("thrift_workspace_with_split"); + + test_data_dir.read_dir().unwrap().for_each(|f| { + let f = f.unwrap(); + + let path = f.path(); + + if let Some(ext) = path.extension() { + if ext == "thrift" { + let mut dir_path = path.clone(); + let buf = dir_path.clone(); + let dir_name = buf.file_stem().unwrap(); + dir_path.pop(); + dir_path.push(dir_name); + + test_thrift_workspace_with_split(path, dir_path); + } + } + }); +} + #[test] fn test_thrift_gen_with_split() { let test_data_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")) diff --git a/pilota-build/test_data/thrift_workspace/apache.thrift b/pilota-build/test_data/thrift_workspace/apache.thrift new file mode 100644 index 00000000..8de93e4d --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/apache.thrift @@ -0,0 +1,426 @@ +/* + * 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. + * + * Contains some contributions under the Thrift Software License. + * Please see doc/old-thrift-license.txt in the Thrift distribution for + * details. + */ + +namespace c_glib TTest +namespace cpp thrift.test +namespace delphi Thrift.Test +namespace go thrifttest +namespace java thrift.test +namespace js ThriftTest +namespace lua ThriftTest +namespace netstd ThriftTest +namespace perl ThriftTest +namespace php ThriftTest +namespace py ThriftTest +namespace py.twisted ThriftTest +namespace rb Thrift.Test +namespace st ThriftTest +namespace xsd test (uri = 'http://thrift.apache.org/ns/ThriftTest') + +// Presence of namespaces and sub-namespaces for which there is +// no generator should compile with warnings only +// namespace noexist ThriftTest +// namespace cpp.noexist ThriftTest + +namespace * thrift.test + +/** + * Docstring! + */ +enum Numberz +{ + ONE = 1, + TWO, + THREE, + FIVE = 5, + SIX, + EIGHT = 8 +} + +const Numberz myNumberz = Numberz.ONE; +// the following is expected to fail: +// const Numberz urNumberz = ONE; + +typedef i64 UserId + +struct Bonk +{ + 1: string message, + 2: i32 type +} + +typedef map MapType + +struct Bools { + 1: bool im_true, + 2: bool im_false, +} + +struct Xtruct +{ + 1: string string_thing, + 4: i8 byte_thing, + 9: i32 i32_thing, + 11: i64 i64_thing +} + +struct Xtruct2 +{ + 1: i8 byte_thing, // used to be byte, hence the name + 2: Xtruct struct_thing, + 3: i32 i32_thing +} + +struct Xtruct3 +{ + 1: string string_thing, + 4: i32 changed, + 9: i32 i32_thing, + 11: i64 i64_thing +} + + +struct Insanity +{ + 1: map userMap, + 2: list xtructs +} (python.immutable= "") + +struct CrazyNesting { + 1: string string_field, + 2: optional set set_field, + // Do not insert line break as test/go/Makefile.am is removing this line with pattern match + 3: required list (python.immutable = ""), map(python.immutable = "")> (python.immutable = "")>>>> list_field, + 4: binary binary_field + 5: uuid uuid_field +} + +union SomeUnion { + 1: map map_thing, + 2: string string_thing, + 3: i32 i32_thing, + 4: Xtruct3 xtruct_thing, + 5: Insanity insanity_thing +} + +exception Xception { + 1: i32 errorCode, + 2: string message +} + +exception Xception2 { + 1: i32 errorCode, + 2: Xtruct struct_thing +} + +struct EmptyStruct {} + +struct OneField { + 1: EmptyStruct field +} + +service ThriftTest +{ + /** + * Prints "testVoid()" and returns nothing. + */ + void testVoid(), + + /** + * Prints 'testString("%s")' with thing as '%s' + * @param string thing - the string to print + * @return string - returns the string 'thing' + */ + string testString(1: string thing), + + /** + * Prints 'testBool("%s")' where '%s' with thing as 'true' or 'false' + * @param bool thing - the bool data to print + * @return bool - returns the bool 'thing' + */ + bool testBool(1: bool thing), + + /** + * Prints 'testByte("%d")' with thing as '%d' + * The types i8 and byte are synonyms, use of i8 is encouraged, byte still exists for the sake of compatibility. + * @param byte thing - the i8/byte to print + * @return i8 - returns the i8/byte 'thing' + */ + i8 testByte(1: i8 thing), + + /** + * Prints 'testI32("%d")' with thing as '%d' + * @param i32 thing - the i32 to print + * @return i32 - returns the i32 'thing' + */ + i32 testI32(1: i32 thing), + + /** + * Prints 'testI64("%d")' with thing as '%d' + * @param i64 thing - the i64 to print + * @return i64 - returns the i64 'thing' + */ + i64 testI64(1: i64 thing), + + /** + * Prints 'testDouble("%f")' with thing as '%f' + * @param double thing - the double to print + * @return double - returns the double 'thing' + */ + double testDouble(1: double thing), + + /** + * Prints 'testBinary("%s")' where '%s' is a hex-formatted string of thing's data + * @param binary thing - the binary data to print + * @return binary - returns the binary 'thing' + */ + binary testBinary(1: binary thing), + + /** + * Prints 'testUuid("%s")' where '%s' is the uuid given. Note that the uuid byte order should be correct. + * @param uuid thing - the uuid to print + * @return uuid - returns the uuid 'thing' + */ + uuid testUuid(1: uuid thing), + + /** + * Prints 'testStruct("{%s}")' where thing has been formatted into a string of comma separated values + * @param Xtruct thing - the Xtruct to print + * @return Xtruct - returns the Xtruct 'thing' + */ + Xtruct testStruct(1: Xtruct thing), + + /** + * Prints 'testNest("{%s}")' where thing has been formatted into a string of the nested struct + * @param Xtruct2 thing - the Xtruct2 to print + * @return Xtruct2 - returns the Xtruct2 'thing' + */ + Xtruct2 testNest(1: Xtruct2 thing), + + /** + * Prints 'testMap("{%s")' where thing has been formatted into a string of 'key => value' pairs + * separated by commas and new lines + * @param map thing - the map to print + * @return map - returns the map 'thing' + */ + map testMap(1: map thing), + + /** + * Prints 'testStringMap("{%s}")' where thing has been formatted into a string of 'key => value' pairs + * separated by commas and new lines + * @param map thing - the map to print + * @return map - returns the map 'thing' + */ + map testStringMap(1: map thing), + + /** + * Prints 'testSet("{%s}")' where thing has been formatted into a string of values + * separated by commas and new lines + * @param set thing - the set to print + * @return set - returns the set 'thing' + */ + set testSet(1: set thing), + + /** + * Prints 'testList("{%s}")' where thing has been formatted into a string of values + * separated by commas and new lines + * @param list thing - the list to print + * @return list - returns the list 'thing' + */ + list testList(1: list thing), + + /** + * Prints 'testEnum("%d")' where thing has been formatted into its numeric value + * @param Numberz thing - the Numberz to print + * @return Numberz - returns the Numberz 'thing' + */ + Numberz testEnum(1: Numberz thing), + + /** + * Prints 'testTypedef("%d")' with thing as '%d' + * @param UserId thing - the UserId to print + * @return UserId - returns the UserId 'thing' + */ + UserId testTypedef(1: UserId thing), + + /** + * Prints 'testMapMap("%d")' with hello as '%d' + * @param i32 hello - the i32 to print + * @return map> - returns a dictionary with these values: + * {-4 => {-4 => -4, -3 => -3, -2 => -2, -1 => -1, }, 4 => {1 => 1, 2 => 2, 3 => 3, 4 => 4, }, } + */ + map> testMapMap(1: i32 hello), + + /** + * So you think you've got this all worked out, eh? + * + * Creates a map with these values and prints it out: + * { 1 => { 2 => argument, + * 3 => argument, + * }, + * 2 => { 6 => , }, + * } + * @return map> - a map with the above values + */ + map> testInsanity(1: Insanity argument), + + /** + * Prints 'testMulti()' + * @param i8 arg0 - + * @param i32 arg1 - + * @param i64 arg2 - + * @param map arg3 - + * @param Numberz arg4 - + * @param UserId arg5 - + * @return Xtruct - returns an Xtruct with string_thing = "Hello2, byte_thing = arg0, i32_thing = arg1 + * and i64_thing = arg2 + */ + Xtruct testMulti(1: i8 arg0, 2: i32 arg1, 3: i64 arg2, 4: map arg3, 5: Numberz arg4, 6: UserId arg5), + + /** + * Print 'testException(%s)' with arg as '%s' + * @param string arg - a string indication what type of exception to throw + * if arg == "Xception" throw Xception with errorCode = 1001 and message = arg + * else if arg == "TException" throw TException + * else do not throw anything + */ + void testException(1: string arg) throws(1: Xception err1), + + /** + * Print 'testMultiException(%s, %s)' with arg0 as '%s' and arg1 as '%s' + * @param string arg - a string indicating what type of exception to throw + * if arg0 == "Xception" throw Xception with errorCode = 1001 and message = "This is an Xception" + * else if arg0 == "Xception2" throw Xception2 with errorCode = 2002 and struct_thing.string_thing = "This is an Xception2" + * else do not throw anything + * @return Xtruct - an Xtruct with string_thing = arg1 + */ + Xtruct testMultiException(1: string arg0, 2: string arg1) throws(1: Xception err1, 2: Xception2 err2) + + /** + * Print 'testOneway(%d): Sleeping...' with secondsToSleep as '%d' + * sleep 'secondsToSleep' + * Print 'testOneway(%d): done sleeping!' with secondsToSleep as '%d' + * @param i32 secondsToSleep - the number of seconds to sleep + */ + oneway void testOneway(1:i32 secondsToSleep) +} + +service SecondService +{ + /** + * Prints 'testString("%s")' with thing as '%s' + * @param string thing - the string to print + * @return string - returns the string 'thing' + */ + string secondtestString(1: string thing) +} + +struct VersioningTestV1 { + 1: i32 begin_in_both, + 3: string old_string, + 12: i32 end_in_both +} + +struct VersioningTestV2 { + 1: i32 begin_in_both, + + 2: i32 newint, + 3: i8 newbyte, + 4: i16 newshort, + 5: i64 newlong, + 6: double newdouble + 7: Bonk newstruct, + 8: list newlist, + 9: set newset, + 10: map newmap, + 11: string newstring, + 12: i32 end_in_both +} + +struct ListTypeVersioningV1 { + 1: list myints; + 2: string hello; +} + +struct ListTypeVersioningV2 { + 1: list strings; + 2: string hello; +} + +struct GuessProtocolStruct { + 7: map map_field, +} + +struct LargeDeltas { + 1: Bools b1, + 10: Bools b10, + 100: Bools b100, + 500: bool check_true, + 1000: Bools b1000, + 1500: bool check_false, + 2000: VersioningTestV2 vertwo2000, + 2500: set a_set2500, + 3000: VersioningTestV2 vertwo3000, + 4000: list big_numbers +} + +struct NestedListsI32x2 { + 1: list> integerlist +} +struct NestedListsI32x3 { + 1: list>> integerlist +} +struct NestedMixedx2 { + 1: list> int_set_list + 2: map> map_int_strset + 3: list>> map_int_strset_list +} +struct ListBonks { + 1: list bonk +} +struct NestedListsBonk { + 1: list>> bonk +} + +struct BoolTest { + 1: optional bool b = true; + 2: optional string s = "true"; +} + +struct StructA { + 1: required string s; +} + +struct StructB { + 1: optional StructA aa; + 2: required StructA ab; +} + +struct OptionalSetDefaultTest { + 1: optional set with_default = [ "test" ] +} + +struct OptionalBinary { +//1: optional set bin_set = [] + 2: optional map bin_map = {} +} diff --git a/pilota-build/test_data/thrift_workspace/auto_name.thrift b/pilota-build/test_data/thrift_workspace/auto_name.thrift new file mode 100644 index 00000000..badc2e0c --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/auto_name.thrift @@ -0,0 +1,33 @@ + +struct TEST { + 1: required string Id, +} + +const string ip = "ip"; +const string IP = "IP"; + +struct Test { + 1: required string ID, + 2: required string Id, +} + +enum Index { + A, + a, +} + +struct TestException { + +} + +service Service { + Test test(1: TEST req, 2: TEST Req) throws (1: TestException e); + Test Test(1: TEST Req) throws (1: TestException e); + Test Test2(1: TEST type); +} + +service service { + Test test(1: TEST req) throws (1: TestException e); + Test Test(1: TEST Req) throws (1: TestException e); + Test Test2(1: TEST self); +} diff --git a/pilota-build/test_data/thrift_workspace/binary_bytes.thrift b/pilota-build/test_data/thrift_workspace/binary_bytes.thrift new file mode 100644 index 00000000..48422250 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/binary_bytes.thrift @@ -0,0 +1,4 @@ +struct A { + 1: required binary bytes, + 2: required binary vec(pilota.rust_type="vec"), +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace/const_val.thrift b/pilota-build/test_data/thrift_workspace/const_val.thrift new file mode 100644 index 00000000..ff758be7 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/const_val.thrift @@ -0,0 +1,20 @@ +enum Index { + A = 0, + B = 1, +} + +const map TEST_MAP = { + Index.A: "hello", + Index.B: "world", +}; + + +const list TEST_LIST = [ + "hello", + "world", +]; + + +const map> TEST_MAP_LIST = { + 1: ["hello"] +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace/decode_error.thrift b/pilota-build/test_data/thrift_workspace/decode_error.thrift new file mode 100644 index 00000000..003193aa --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/decode_error.thrift @@ -0,0 +1,14 @@ + + + +struct A { + 1: required B b, +} + +struct B { + 2: required C c, +} + +struct C { + 3: required string a, +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace/default_value.thrift b/pilota-build/test_data/thrift_workspace/default_value.thrift new file mode 100644 index 00000000..9db807a4 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/default_value.thrift @@ -0,0 +1,29 @@ +enum B { + Read = 1; + Write = 2; +} + +const string A_S = "string"; + +struct A { + 1: required string faststr = "hello world", + 2: required string string = "test"(pilota.rust_type = "string"), + 3: optional bool a = false, + 4: optional B test_b = B.Read, + 5: optional B test_b2 = 2, + 6: optional i8 test_b3 = B.Read, + 7: optional map map = {"hello": "world"}, + 8: optional double test_double = 1, + 9: optional double test_double2 = 1.2, + 10: optional string alias_str = A_S, + 11: required binary empty = "", + 12: required map test_map = {1.0: 2.0}, + 13: required set test_set = [1.0], + 14: bool a2 = 3, + 15: map map2 = [], + } + +struct C { + 1: string off = "off", + 2: optional byte test_byte = 0, +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace/enum_map.thrift b/pilota-build/test_data/thrift_workspace/enum_map.thrift new file mode 100644 index 00000000..16675284 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/enum_map.thrift @@ -0,0 +1,14 @@ +typedef i32 TypeB + +const TypeB TypeB1 = 1 +const TypeB TypeB2 = 2 + +typedef string TypeA + +const TypeA TypeA1 = "a1" +const TypeA TypeA2 = "a2" + +const map TypeAMap = { + TypeB1: TypeA1, + TypeB2: TypeA2, +} diff --git a/pilota-build/test_data/thrift_workspace/enum_test.thrift b/pilota-build/test_data/thrift_workspace/enum_test.thrift new file mode 100644 index 00000000..d0cbb42e --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/enum_test.thrift @@ -0,0 +1,20 @@ +enum Index { + A = 0x01, + B = 0x10, +} + +enum Err { + +} + +enum Ok { +} + +struct Request { + 1: required Index Index, + 2: Index index, +} +service Test { + Err test_enum(1: Ok req); + Err test_enum_var_type_name_conflict (1: Request req); +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace/multi.thrift b/pilota-build/test_data/thrift_workspace/multi.thrift new file mode 100644 index 00000000..cc3fb25c --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/multi.thrift @@ -0,0 +1,11 @@ +include "default_value.thrift" +include "recursive_type.thrift" + +struct A { + 1: default_value.C c = {"off": "off"}, +} + +struct B { + 1: recursive_type.A a, + 2: recursive_type.C c, +} diff --git a/pilota-build/test_data/thrift_workspace/normal.thrift b/pilota-build/test_data/thrift_workspace/normal.thrift new file mode 100644 index 00000000..11699ed6 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/normal.thrift @@ -0,0 +1,37 @@ + + +struct A { + 1: i32 a, +} + +struct b { + 2: A a, +} + +struct SubMessage { + 2: optional string value; +} + +struct Message { + 1: uuid uid; + 2: optional string value; + 3: optional list subMessages; +} + +struct ObjReq { + 1: required Message msg + 2: required map msgMap + 3: required list subMsgs + 4: optional set msgSet + 5: required string flagMsg + 6: optional string mockCost, +} + +exception STException { + 1: string message; +} + +service Test { + void test_123(); + ObjReq testException(1: ObjReq req) throws (1: STException stException); +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace/path_keyword.thrift b/pilota-build/test_data/thrift_workspace/path_keyword.thrift new file mode 100644 index 00000000..00d6e57f --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/path_keyword.thrift @@ -0,0 +1,5 @@ +namespace rs enum; +struct A { + 1: required binary bytes, + 2: required binary vec(pilota.rust_type="vec"), +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace/pilota_name.thrift b/pilota-build/test_data/thrift_workspace/pilota_name.thrift new file mode 100644 index 00000000..17264f2c --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/pilota_name.thrift @@ -0,0 +1,20 @@ + +struct TEST { + 1: required string ID, +}(pilota.name="Test2") + +const string id = "id" (pilota.name="LANG_ID"); + +struct Test { + 1: required string ID, + 2: required string Id (pilota.name="hello"), +}(pilota.name="Test1") + +enum Index { + A (pilota.name="AA"), + B, +} + +service TestService { + Test test(1: TEST req); +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace/recursive_type.thrift b/pilota-build/test_data/thrift_workspace/recursive_type.thrift new file mode 100644 index 00000000..c5828f68 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/recursive_type.thrift @@ -0,0 +1,12 @@ +struct A { + 1: optional A a, + 2: optional B a_b, +} + +struct B { + 1: optional A b_a, +} + +struct C { + 1: set c, +} diff --git a/pilota-build/test_data/thrift_workspace/self_kw.thrift b/pilota-build/test_data/thrift_workspace/self_kw.thrift new file mode 100644 index 00000000..8c7d7551 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/self_kw.thrift @@ -0,0 +1,10 @@ +enum Index { + A = 0, + Self = 1, +} + +struct A { + 1: required string type, + 2: required string self, + 3: required string protocol, +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace/string.thrift b/pilota-build/test_data/thrift_workspace/string.thrift new file mode 100644 index 00000000..8894e584 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/string.thrift @@ -0,0 +1,4 @@ +struct A { + 1: required string faststr, + 2: required string string(pilota.rust_type = "string"), +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace/union.thrift b/pilota-build/test_data/thrift_workspace/union.thrift new file mode 100644 index 00000000..a1bbd6b8 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/union.thrift @@ -0,0 +1,12 @@ +union Union { + 1: string a, + 2: binary b, +} + +struct A { + 1: Union u, +} + +union Empty { + +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace/void.thrift b/pilota-build/test_data/thrift_workspace/void.thrift new file mode 100644 index 00000000..91c35d7b --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/void.thrift @@ -0,0 +1,3 @@ +service Test { + void test_123(); +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace/wrapper_arc.thrift b/pilota-build/test_data/thrift_workspace/wrapper_arc.thrift new file mode 100644 index 00000000..6bb95526 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/wrapper_arc.thrift @@ -0,0 +1,13 @@ +struct A { + +} + +struct TEST { + 1: required string ID, + 2: required list> Name2(pilota.rust_wrapper_arc="true"), + 3: required map> Name3(pilota.rust_wrapper_arc="true"), +} + +service TestService { + TEST(pilota.rust_wrapper_arc="true") test(1: TEST req(pilota.rust_wrapper_arc="true")); +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache.thrift b/pilota-build/test_data/thrift_workspace_with_split/apache.thrift new file mode 100644 index 00000000..8de93e4d --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache.thrift @@ -0,0 +1,426 @@ +/* + * 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. + * + * Contains some contributions under the Thrift Software License. + * Please see doc/old-thrift-license.txt in the Thrift distribution for + * details. + */ + +namespace c_glib TTest +namespace cpp thrift.test +namespace delphi Thrift.Test +namespace go thrifttest +namespace java thrift.test +namespace js ThriftTest +namespace lua ThriftTest +namespace netstd ThriftTest +namespace perl ThriftTest +namespace php ThriftTest +namespace py ThriftTest +namespace py.twisted ThriftTest +namespace rb Thrift.Test +namespace st ThriftTest +namespace xsd test (uri = 'http://thrift.apache.org/ns/ThriftTest') + +// Presence of namespaces and sub-namespaces for which there is +// no generator should compile with warnings only +// namespace noexist ThriftTest +// namespace cpp.noexist ThriftTest + +namespace * thrift.test + +/** + * Docstring! + */ +enum Numberz +{ + ONE = 1, + TWO, + THREE, + FIVE = 5, + SIX, + EIGHT = 8 +} + +const Numberz myNumberz = Numberz.ONE; +// the following is expected to fail: +// const Numberz urNumberz = ONE; + +typedef i64 UserId + +struct Bonk +{ + 1: string message, + 2: i32 type +} + +typedef map MapType + +struct Bools { + 1: bool im_true, + 2: bool im_false, +} + +struct Xtruct +{ + 1: string string_thing, + 4: i8 byte_thing, + 9: i32 i32_thing, + 11: i64 i64_thing +} + +struct Xtruct2 +{ + 1: i8 byte_thing, // used to be byte, hence the name + 2: Xtruct struct_thing, + 3: i32 i32_thing +} + +struct Xtruct3 +{ + 1: string string_thing, + 4: i32 changed, + 9: i32 i32_thing, + 11: i64 i64_thing +} + + +struct Insanity +{ + 1: map userMap, + 2: list xtructs +} (python.immutable= "") + +struct CrazyNesting { + 1: string string_field, + 2: optional set set_field, + // Do not insert line break as test/go/Makefile.am is removing this line with pattern match + 3: required list (python.immutable = ""), map(python.immutable = "")> (python.immutable = "")>>>> list_field, + 4: binary binary_field + 5: uuid uuid_field +} + +union SomeUnion { + 1: map map_thing, + 2: string string_thing, + 3: i32 i32_thing, + 4: Xtruct3 xtruct_thing, + 5: Insanity insanity_thing +} + +exception Xception { + 1: i32 errorCode, + 2: string message +} + +exception Xception2 { + 1: i32 errorCode, + 2: Xtruct struct_thing +} + +struct EmptyStruct {} + +struct OneField { + 1: EmptyStruct field +} + +service ThriftTest +{ + /** + * Prints "testVoid()" and returns nothing. + */ + void testVoid(), + + /** + * Prints 'testString("%s")' with thing as '%s' + * @param string thing - the string to print + * @return string - returns the string 'thing' + */ + string testString(1: string thing), + + /** + * Prints 'testBool("%s")' where '%s' with thing as 'true' or 'false' + * @param bool thing - the bool data to print + * @return bool - returns the bool 'thing' + */ + bool testBool(1: bool thing), + + /** + * Prints 'testByte("%d")' with thing as '%d' + * The types i8 and byte are synonyms, use of i8 is encouraged, byte still exists for the sake of compatibility. + * @param byte thing - the i8/byte to print + * @return i8 - returns the i8/byte 'thing' + */ + i8 testByte(1: i8 thing), + + /** + * Prints 'testI32("%d")' with thing as '%d' + * @param i32 thing - the i32 to print + * @return i32 - returns the i32 'thing' + */ + i32 testI32(1: i32 thing), + + /** + * Prints 'testI64("%d")' with thing as '%d' + * @param i64 thing - the i64 to print + * @return i64 - returns the i64 'thing' + */ + i64 testI64(1: i64 thing), + + /** + * Prints 'testDouble("%f")' with thing as '%f' + * @param double thing - the double to print + * @return double - returns the double 'thing' + */ + double testDouble(1: double thing), + + /** + * Prints 'testBinary("%s")' where '%s' is a hex-formatted string of thing's data + * @param binary thing - the binary data to print + * @return binary - returns the binary 'thing' + */ + binary testBinary(1: binary thing), + + /** + * Prints 'testUuid("%s")' where '%s' is the uuid given. Note that the uuid byte order should be correct. + * @param uuid thing - the uuid to print + * @return uuid - returns the uuid 'thing' + */ + uuid testUuid(1: uuid thing), + + /** + * Prints 'testStruct("{%s}")' where thing has been formatted into a string of comma separated values + * @param Xtruct thing - the Xtruct to print + * @return Xtruct - returns the Xtruct 'thing' + */ + Xtruct testStruct(1: Xtruct thing), + + /** + * Prints 'testNest("{%s}")' where thing has been formatted into a string of the nested struct + * @param Xtruct2 thing - the Xtruct2 to print + * @return Xtruct2 - returns the Xtruct2 'thing' + */ + Xtruct2 testNest(1: Xtruct2 thing), + + /** + * Prints 'testMap("{%s")' where thing has been formatted into a string of 'key => value' pairs + * separated by commas and new lines + * @param map thing - the map to print + * @return map - returns the map 'thing' + */ + map testMap(1: map thing), + + /** + * Prints 'testStringMap("{%s}")' where thing has been formatted into a string of 'key => value' pairs + * separated by commas and new lines + * @param map thing - the map to print + * @return map - returns the map 'thing' + */ + map testStringMap(1: map thing), + + /** + * Prints 'testSet("{%s}")' where thing has been formatted into a string of values + * separated by commas and new lines + * @param set thing - the set to print + * @return set - returns the set 'thing' + */ + set testSet(1: set thing), + + /** + * Prints 'testList("{%s}")' where thing has been formatted into a string of values + * separated by commas and new lines + * @param list thing - the list to print + * @return list - returns the list 'thing' + */ + list testList(1: list thing), + + /** + * Prints 'testEnum("%d")' where thing has been formatted into its numeric value + * @param Numberz thing - the Numberz to print + * @return Numberz - returns the Numberz 'thing' + */ + Numberz testEnum(1: Numberz thing), + + /** + * Prints 'testTypedef("%d")' with thing as '%d' + * @param UserId thing - the UserId to print + * @return UserId - returns the UserId 'thing' + */ + UserId testTypedef(1: UserId thing), + + /** + * Prints 'testMapMap("%d")' with hello as '%d' + * @param i32 hello - the i32 to print + * @return map> - returns a dictionary with these values: + * {-4 => {-4 => -4, -3 => -3, -2 => -2, -1 => -1, }, 4 => {1 => 1, 2 => 2, 3 => 3, 4 => 4, }, } + */ + map> testMapMap(1: i32 hello), + + /** + * So you think you've got this all worked out, eh? + * + * Creates a map with these values and prints it out: + * { 1 => { 2 => argument, + * 3 => argument, + * }, + * 2 => { 6 => , }, + * } + * @return map> - a map with the above values + */ + map> testInsanity(1: Insanity argument), + + /** + * Prints 'testMulti()' + * @param i8 arg0 - + * @param i32 arg1 - + * @param i64 arg2 - + * @param map arg3 - + * @param Numberz arg4 - + * @param UserId arg5 - + * @return Xtruct - returns an Xtruct with string_thing = "Hello2, byte_thing = arg0, i32_thing = arg1 + * and i64_thing = arg2 + */ + Xtruct testMulti(1: i8 arg0, 2: i32 arg1, 3: i64 arg2, 4: map arg3, 5: Numberz arg4, 6: UserId arg5), + + /** + * Print 'testException(%s)' with arg as '%s' + * @param string arg - a string indication what type of exception to throw + * if arg == "Xception" throw Xception with errorCode = 1001 and message = arg + * else if arg == "TException" throw TException + * else do not throw anything + */ + void testException(1: string arg) throws(1: Xception err1), + + /** + * Print 'testMultiException(%s, %s)' with arg0 as '%s' and arg1 as '%s' + * @param string arg - a string indicating what type of exception to throw + * if arg0 == "Xception" throw Xception with errorCode = 1001 and message = "This is an Xception" + * else if arg0 == "Xception2" throw Xception2 with errorCode = 2002 and struct_thing.string_thing = "This is an Xception2" + * else do not throw anything + * @return Xtruct - an Xtruct with string_thing = arg1 + */ + Xtruct testMultiException(1: string arg0, 2: string arg1) throws(1: Xception err1, 2: Xception2 err2) + + /** + * Print 'testOneway(%d): Sleeping...' with secondsToSleep as '%d' + * sleep 'secondsToSleep' + * Print 'testOneway(%d): done sleeping!' with secondsToSleep as '%d' + * @param i32 secondsToSleep - the number of seconds to sleep + */ + oneway void testOneway(1:i32 secondsToSleep) +} + +service SecondService +{ + /** + * Prints 'testString("%s")' with thing as '%s' + * @param string thing - the string to print + * @return string - returns the string 'thing' + */ + string secondtestString(1: string thing) +} + +struct VersioningTestV1 { + 1: i32 begin_in_both, + 3: string old_string, + 12: i32 end_in_both +} + +struct VersioningTestV2 { + 1: i32 begin_in_both, + + 2: i32 newint, + 3: i8 newbyte, + 4: i16 newshort, + 5: i64 newlong, + 6: double newdouble + 7: Bonk newstruct, + 8: list newlist, + 9: set newset, + 10: map newmap, + 11: string newstring, + 12: i32 end_in_both +} + +struct ListTypeVersioningV1 { + 1: list myints; + 2: string hello; +} + +struct ListTypeVersioningV2 { + 1: list strings; + 2: string hello; +} + +struct GuessProtocolStruct { + 7: map map_field, +} + +struct LargeDeltas { + 1: Bools b1, + 10: Bools b10, + 100: Bools b100, + 500: bool check_true, + 1000: Bools b1000, + 1500: bool check_false, + 2000: VersioningTestV2 vertwo2000, + 2500: set a_set2500, + 3000: VersioningTestV2 vertwo3000, + 4000: list big_numbers +} + +struct NestedListsI32x2 { + 1: list> integerlist +} +struct NestedListsI32x3 { + 1: list>> integerlist +} +struct NestedMixedx2 { + 1: list> int_set_list + 2: map> map_int_strset + 3: list>> map_int_strset_list +} +struct ListBonks { + 1: list bonk +} +struct NestedListsBonk { + 1: list>> bonk +} + +struct BoolTest { + 1: optional bool b = true; + 2: optional string s = "true"; +} + +struct StructA { + 1: required string s; +} + +struct StructB { + 1: optional StructA aa; + 2: required StructA ab; +} + +struct OptionalSetDefaultTest { + 1: optional set with_default = [ "test" ] +} + +struct OptionalBinary { +//1: optional set bin_set = [] + 2: optional map bin_map = {} +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/auto_name.thrift b/pilota-build/test_data/thrift_workspace_with_split/auto_name.thrift new file mode 100644 index 00000000..badc2e0c --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/auto_name.thrift @@ -0,0 +1,33 @@ + +struct TEST { + 1: required string Id, +} + +const string ip = "ip"; +const string IP = "IP"; + +struct Test { + 1: required string ID, + 2: required string Id, +} + +enum Index { + A, + a, +} + +struct TestException { + +} + +service Service { + Test test(1: TEST req, 2: TEST Req) throws (1: TestException e); + Test Test(1: TEST Req) throws (1: TestException e); + Test Test2(1: TEST type); +} + +service service { + Test test(1: TEST req) throws (1: TestException e); + Test Test(1: TEST Req) throws (1: TestException e); + Test Test2(1: TEST self); +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/binary_bytes.thrift b/pilota-build/test_data/thrift_workspace_with_split/binary_bytes.thrift new file mode 100644 index 00000000..48422250 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/binary_bytes.thrift @@ -0,0 +1,4 @@ +struct A { + 1: required binary bytes, + 2: required binary vec(pilota.rust_type="vec"), +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace_with_split/const_val.thrift b/pilota-build/test_data/thrift_workspace_with_split/const_val.thrift new file mode 100644 index 00000000..ff758be7 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/const_val.thrift @@ -0,0 +1,20 @@ +enum Index { + A = 0, + B = 1, +} + +const map TEST_MAP = { + Index.A: "hello", + Index.B: "world", +}; + + +const list TEST_LIST = [ + "hello", + "world", +]; + + +const map> TEST_MAP_LIST = { + 1: ["hello"] +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace_with_split/decode_error.thrift b/pilota-build/test_data/thrift_workspace_with_split/decode_error.thrift new file mode 100644 index 00000000..003193aa --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/decode_error.thrift @@ -0,0 +1,14 @@ + + + +struct A { + 1: required B b, +} + +struct B { + 2: required C c, +} + +struct C { + 3: required string a, +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace_with_split/default_value.thrift b/pilota-build/test_data/thrift_workspace_with_split/default_value.thrift new file mode 100644 index 00000000..9db807a4 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/default_value.thrift @@ -0,0 +1,29 @@ +enum B { + Read = 1; + Write = 2; +} + +const string A_S = "string"; + +struct A { + 1: required string faststr = "hello world", + 2: required string string = "test"(pilota.rust_type = "string"), + 3: optional bool a = false, + 4: optional B test_b = B.Read, + 5: optional B test_b2 = 2, + 6: optional i8 test_b3 = B.Read, + 7: optional map map = {"hello": "world"}, + 8: optional double test_double = 1, + 9: optional double test_double2 = 1.2, + 10: optional string alias_str = A_S, + 11: required binary empty = "", + 12: required map test_map = {1.0: 2.0}, + 13: required set test_set = [1.0], + 14: bool a2 = 3, + 15: map map2 = [], + } + +struct C { + 1: string off = "off", + 2: optional byte test_byte = 0, +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace_with_split/enum_map.thrift b/pilota-build/test_data/thrift_workspace_with_split/enum_map.thrift new file mode 100644 index 00000000..16675284 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/enum_map.thrift @@ -0,0 +1,14 @@ +typedef i32 TypeB + +const TypeB TypeB1 = 1 +const TypeB TypeB2 = 2 + +typedef string TypeA + +const TypeA TypeA1 = "a1" +const TypeA TypeA2 = "a2" + +const map TypeAMap = { + TypeB1: TypeA1, + TypeB2: TypeA2, +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/enum_test.thrift b/pilota-build/test_data/thrift_workspace_with_split/enum_test.thrift new file mode 100644 index 00000000..d0cbb42e --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/enum_test.thrift @@ -0,0 +1,20 @@ +enum Index { + A = 0x01, + B = 0x10, +} + +enum Err { + +} + +enum Ok { +} + +struct Request { + 1: required Index Index, + 2: Index index, +} +service Test { + Err test_enum(1: Ok req); + Err test_enum_var_type_name_conflict (1: Request req); +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace_with_split/multi.thrift b/pilota-build/test_data/thrift_workspace_with_split/multi.thrift new file mode 100644 index 00000000..cc3fb25c --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/multi.thrift @@ -0,0 +1,11 @@ +include "default_value.thrift" +include "recursive_type.thrift" + +struct A { + 1: default_value.C c = {"off": "off"}, +} + +struct B { + 1: recursive_type.A a, + 2: recursive_type.C c, +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/normal.thrift b/pilota-build/test_data/thrift_workspace_with_split/normal.thrift new file mode 100644 index 00000000..11699ed6 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/normal.thrift @@ -0,0 +1,37 @@ + + +struct A { + 1: i32 a, +} + +struct b { + 2: A a, +} + +struct SubMessage { + 2: optional string value; +} + +struct Message { + 1: uuid uid; + 2: optional string value; + 3: optional list subMessages; +} + +struct ObjReq { + 1: required Message msg + 2: required map msgMap + 3: required list subMsgs + 4: optional set msgSet + 5: required string flagMsg + 6: optional string mockCost, +} + +exception STException { + 1: string message; +} + +service Test { + void test_123(); + ObjReq testException(1: ObjReq req) throws (1: STException stException); +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace_with_split/path_keyword.thrift b/pilota-build/test_data/thrift_workspace_with_split/path_keyword.thrift new file mode 100644 index 00000000..00d6e57f --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/path_keyword.thrift @@ -0,0 +1,5 @@ +namespace rs enum; +struct A { + 1: required binary bytes, + 2: required binary vec(pilota.rust_type="vec"), +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace_with_split/pilota_name.thrift b/pilota-build/test_data/thrift_workspace_with_split/pilota_name.thrift new file mode 100644 index 00000000..17264f2c --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/pilota_name.thrift @@ -0,0 +1,20 @@ + +struct TEST { + 1: required string ID, +}(pilota.name="Test2") + +const string id = "id" (pilota.name="LANG_ID"); + +struct Test { + 1: required string ID, + 2: required string Id (pilota.name="hello"), +}(pilota.name="Test1") + +enum Index { + A (pilota.name="AA"), + B, +} + +service TestService { + Test test(1: TEST req); +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace_with_split/recursive_type.thrift b/pilota-build/test_data/thrift_workspace_with_split/recursive_type.thrift new file mode 100644 index 00000000..c5828f68 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/recursive_type.thrift @@ -0,0 +1,12 @@ +struct A { + 1: optional A a, + 2: optional B a_b, +} + +struct B { + 1: optional A b_a, +} + +struct C { + 1: set c, +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/self_kw.thrift b/pilota-build/test_data/thrift_workspace_with_split/self_kw.thrift new file mode 100644 index 00000000..8c7d7551 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/self_kw.thrift @@ -0,0 +1,10 @@ +enum Index { + A = 0, + Self = 1, +} + +struct A { + 1: required string type, + 2: required string self, + 3: required string protocol, +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace_with_split/string.thrift b/pilota-build/test_data/thrift_workspace_with_split/string.thrift new file mode 100644 index 00000000..8894e584 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/string.thrift @@ -0,0 +1,4 @@ +struct A { + 1: required string faststr, + 2: required string string(pilota.rust_type = "string"), +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace_with_split/union.thrift b/pilota-build/test_data/thrift_workspace_with_split/union.thrift new file mode 100644 index 00000000..a1bbd6b8 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/union.thrift @@ -0,0 +1,12 @@ +union Union { + 1: string a, + 2: binary b, +} + +struct A { + 1: Union u, +} + +union Empty { + +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace_with_split/void.thrift b/pilota-build/test_data/thrift_workspace_with_split/void.thrift new file mode 100644 index 00000000..91c35d7b --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/void.thrift @@ -0,0 +1,3 @@ +service Test { + void test_123(); +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace_with_split/wrapper_arc.thrift b/pilota-build/test_data/thrift_workspace_with_split/wrapper_arc.thrift new file mode 100644 index 00000000..6bb95526 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/wrapper_arc.thrift @@ -0,0 +1,13 @@ +struct A { + +} + +struct TEST { + 1: required string ID, + 2: required list> Name2(pilota.rust_wrapper_arc="true"), + 3: required map> Name3(pilota.rust_wrapper_arc="true"), +} + +service TestService { + TEST(pilota.rust_wrapper_arc="true") test(1: TEST req(pilota.rust_wrapper_arc="true")); +}