From bb8fec7930a3a6789d0b9602412ee57a56ad551c Mon Sep 17 00:00:00 2001 From: Yuxuan 'fishy' Wang Date: Thu, 18 Feb 2021 09:09:20 -0800 Subject: [PATCH] Move ConflictingNamesTest to lib/go/test Client: go Also add missing copyright header for files added in https://github.com/apache/thrift/pull/2307. --- lib/go/test/ConflictArgNamesTest.thrift | 32 ++++++++++++++++++++ lib/go/test/EqualsTest.thrift | 21 ++++++++++++- lib/go/test/Makefile.am | 9 ++++-- lib/go/test/tests/conflict_arg_names_test.go | 27 +++++++++++++++++ lib/go/test/tests/equals_test.go | 19 ++++++++++++ test/ThriftTest.thrift | 14 --------- 6 files changed, 105 insertions(+), 17 deletions(-) create mode 100644 lib/go/test/ConflictArgNamesTest.thrift create mode 100644 lib/go/test/tests/conflict_arg_names_test.go diff --git a/lib/go/test/ConflictArgNamesTest.thrift b/lib/go/test/ConflictArgNamesTest.thrift new file mode 100644 index 00000000000..11323ecafb7 --- /dev/null +++ b/lib/go/test/ConflictArgNamesTest.thrift @@ -0,0 +1,32 @@ +/* + * 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. + */ + +service ConflictArgNamesTest { + /** + * Use some names that could conflict with the compiler code as args + * to make sure that the compiler handled them correctly. + */ + void testNameConflicts( + // 1: string args, // args is already a reserved keyword in thrift compiler + 2: string result, + 3: string meta, + 4: string r, + 5: string err, + ) +} diff --git a/lib/go/test/EqualsTest.thrift b/lib/go/test/EqualsTest.thrift index c699232b4d2..57ce131ec09 100644 --- a/lib/go/test/EqualsTest.thrift +++ b/lib/go/test/EqualsTest.thrift @@ -1,3 +1,22 @@ +/* + * 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. + */ + typedef i8 mybyte typedef string mystr typedef binary mybin @@ -106,4 +125,4 @@ struct MapEqualsFoo { 18: optional map OptInt64MyByteMapFoo, 19: map MyByteInt64MapFoo, 20: optional map OptMyByteInt64MapFoo, -} \ No newline at end of file +} diff --git a/lib/go/test/Makefile.am b/lib/go/test/Makefile.am index 2f748c6fa59..4be652ed663 100644 --- a/lib/go/test/Makefile.am +++ b/lib/go/test/Makefile.am @@ -46,7 +46,9 @@ gopath: $(THRIFT) $(THRIFTTEST) \ ConflictNamespaceTestD.thrift \ ConflictNamespaceTestSuperThing.thrift \ ConflictNamespaceServiceTest.thrift \ - DuplicateImportsTest.thrift + DuplicateImportsTest.thrift \ + EqualsTest.thrift \ + ConflictArgNamesTest.thrift mkdir -p gopath/src grep -v list.*map.*list.*map $(THRIFTTEST) | grep -v 'set' > ThriftTest.thrift $(THRIFT) $(THRIFTARGS) -r IncludesTest.thrift @@ -74,6 +76,7 @@ gopath: $(THRIFT) $(THRIFTTEST) \ $(THRIFT) $(THRIFTARGS) ConflictNamespaceServiceTest.thrift $(THRIFT) $(THRIFTARGS) -r DuplicateImportsTest.thrift $(THRIFT) $(THRIFTARGS) EqualsTest.thrift + $(THRIFT) $(THRIFTARGS) ConflictArgNamesTest.thrift GOPATH=`pwd`/gopath $(GO) get github.com/golang/mock/gomock || true sed -i 's/\"context\"/\"golang.org\/x\/net\/context\"/g' gopath/src/github.com/golang/mock/gomock/controller.go || true GOPATH=`pwd`/gopath $(GO) get github.com/golang/mock/gomock @@ -99,7 +102,8 @@ check: gopath conflict/context/conflict_service-remote \ servicestest/container_test-remote \ duplicateimportstest \ - equalstest + equalstest \ + conflictargnamestest GOPATH=`pwd`/gopath $(GO) test thrift tests dontexportrwtest clean-local: @@ -113,6 +117,7 @@ EXTRA_DIST = \ tests \ common \ BinaryKeyTest.thrift \ + ConflictArgNamesTest.thrift \ ConflictNamespaceServiceTest.thrift \ ConflictNamespaceTestA.thrift \ ConflictNamespaceTestB.thrift \ diff --git a/lib/go/test/tests/conflict_arg_names_test.go b/lib/go/test/tests/conflict_arg_names_test.go new file mode 100644 index 00000000000..92791517e22 --- /dev/null +++ b/lib/go/test/tests/conflict_arg_names_test.go @@ -0,0 +1,27 @@ +/* + * 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. + */ + +package tests + +import ( + "conflictargnamestest" +) + +// We just want to make sure that the conflictargnamestest package compiles. +var _ = conflictargnamestest.GoUnusedProtection__ diff --git a/lib/go/test/tests/equals_test.go b/lib/go/test/tests/equals_test.go index 3489efa0d50..deecb77eeb8 100644 --- a/lib/go/test/tests/equals_test.go +++ b/lib/go/test/tests/equals_test.go @@ -1,3 +1,22 @@ +/* + * 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. + */ + package tests import ( diff --git a/test/ThriftTest.thrift b/test/ThriftTest.thrift index c88187c541b..ac49aee01c8 100644 --- a/test/ThriftTest.thrift +++ b/test/ThriftTest.thrift @@ -411,17 +411,3 @@ struct StructB { struct OptionalSetDefaultTest { 1: optional set with_default = [ "test" ] } - -service ConflictingNamesTest { - /** - * Use some names that could conflict with the compiler code as args - * to make sure that the compiler handled them correctly. - */ - void testNameConflicts( - // 1: string args, // args is already a reserved keyword in thrift compiler - // 2: string result, // result will cause problems in compiled netstd code - 3: string meta, - 4: string r, - 5: string err, - ) -}