Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fieldmask test #71

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ output/*
testdata/

# Files produced by run.sh
kitex_gen/
kitex_gen_slim/
grpc_gen/
*_gen/
go.mod
go.sum
bin
Expand Down
14 changes: 14 additions & 0 deletions CREDITS
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright 2023 CloudWeGo Authors
//
// Licensed 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.

2 changes: 0 additions & 2 deletions codegen/.gitignore

This file was deleted.

35 changes: 32 additions & 3 deletions codegen/codegen_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function check_cmd {
"kitex -module codegen-test -thrift template=slim $filename"
"kitex -module codegen-test -thrift keep_unknown_fields $filename"
"kitex -module codegen-test -thrift template=slim -thrift keep_unknown_fields $filename"
"kitex -module codegen-test -thrift with_field_mask -thrift with_reflection -thrift keep_unknown_fields $filename"
)

skip_error_info=(
Expand All @@ -43,7 +44,8 @@ function check_cmd {
if ! grep -q -E "$(printf '%s\n' "${skip_error_info[@]}" | paste -sd '|' -)" "$tmp_file"; then
echo "$cmd" >> "errors.txt"
cat "$tmp_file" >> "errors.txt" # 将错误输出添加到错误文件中
echo "Error: $cmd"
echo "Kitex Error: $cmd"
exit 1
fi
rm "$tmp_file" # 删除临时文件
continue
Expand All @@ -52,27 +54,49 @@ function check_cmd {
rm "$tmp_file" # 删除临时文件

# go mod 不展示输出,会干扰看结果,如果这一步出问题了,下一步 go build 会报错,所以不用担心
go get github.com/cloudwego/thriftgo@main 2>&1
go mod tidy > /dev/null 2>&1


# 验证编译
local tmp_file_2=$(mktemp) # 创建一个临时文件来存储输出
if ! eval "go build ./..." > "$tmp_file_2" 2>&1; then
echo "$cmd" >> "errors.txt"
cat "$tmp_file_2" >> "errors.txt" # 将错误输出添加到错误文件中
echo "Error: $cmd"
echo "Go Error: $cmd"
exit 2
fi
rm "$tmp_file_2" # 删除临时文件
done
}

function run_test {
echo "run test..."

#run fieldmask tests...
cd fieldmask
sh run.sh
if test $? != 0
then
echo "run fieldmask test failed"
exit 3
fi
cd ..
}

function main {

mkdir -p testdata
cd testdata

clean_codegen

if [ -e "errors.txt" ]; then
rm errors.txt
fi
touch errors.txt

basic_file_dir="basic_idls"
basic_file_dir="../basic_idls"
basic_files=($(find "$basic_file_dir" -name "*.thrift" -type f -print))
basic_total=${#basic_files[@]}
echo "starting test"
Expand All @@ -92,6 +116,11 @@ function main {
cat errors.txt
exit 1
fi

cd ..

run_test

}

main
76 changes: 76 additions & 0 deletions codegen/fieldmask/baseline.thrift
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// Copyright 2024 CloudWeGo Authors
//
// Licensed 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.

namespace go baseline

struct Simple {
1: byte ByteField
2: i64 I64Field (api.js_conv = "")
3: double DoubleField
4: i32 I32Field
5: string StringField,
6: binary BinaryField
}

struct PartialSimple {
1: byte ByteField
3: double DoubleField
6: binary BinaryField
}

struct Nesting {
1: string String (api.header = "String")
2: list<Simple> ListSimple
3: double Double (api.path = "double")
4: i32 I32 (api.http_code = "", api.body = "I32")
5: list<i32> ListI32 (api.query = "ListI32")
6: i64 I64
7: map<string, string> MapStringString
8: Simple SimpleStruct
9: map<i32, i64> MapI32I64
10: list<string> ListString
11: binary Binary
12: map<i64, string> MapI64String
13: list<i64> ListI64 (api.cookie = "list_i64"),
14: byte Byte
15: map<string, Simple> MapStringSimple
}

struct PartialNesting {
2: list<PartialSimple> ListSimple
8: PartialSimple SimpleStruct
15: map<string, PartialSimple> MapStringSimple
}

struct Nesting2 {
1: map<Simple, Nesting> MapSimpleNesting
2: Simple SimpleStruct
3: byte Byte
4: double Double
5: list<Nesting> ListNesting
6: i64 I64
7: Nesting NestingStruct
8: binary Binary
9: string String
10: set<Nesting> SetNesting
11: i32 I32
}

service BaselineService {
Simple SimpleMethod(1: Simple req) (api.post = "/simple")
PartialSimple PartialSimpleMethod(1: PartialSimple req)
Nesting NestingMethod(1: Nesting req) (api.post = "/nesting")
PartialNesting PartialNestingMethod(1: PartialNesting req)
Nesting2 Nesting2Method(1: Nesting2 req) (api.post = "/nesting2")
}
Loading
Loading