diff options
author | Yuxuan 'fishy' Wang <yuxuan.wang@reddit.com> | 2023-02-15 12:19:44 -0800 |
---|---|---|
committer | Jens Geyer <jensg@apache.org> | 2023-03-01 22:58:55 +0100 |
commit | dca42ab4b521bd4b0ffda67ae47a75b47045af24 (patch) | |
tree | d4344dac3e68e35f0a1696c9b1d1528139b8df06 /lib | |
parent | bb80ef4e7db152eb744b0bf47cb196059021266f (diff) | |
download | thrift-dca42ab4b521bd4b0ffda67ae47a75b47045af24.tar.gz |
THRIFT-5685: Revert "THRIFT-5601: Fix forward typedef in go compiler"
This reverts commit b39370ec3bc96d201bbc82fbde136f98ae605ed1, and also
adds a test case for THRIFT-5685.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/go/test/ForwardType.thrift (renamed from lib/go/test/ForwardTypedef.thrift) | 9 | ||||
-rw-r--r-- | lib/go/test/Makefile.am | 7 | ||||
-rw-r--r-- | lib/go/test/tests/forwardtype_test.go | 41 |
3 files changed, 48 insertions, 9 deletions
diff --git a/lib/go/test/ForwardTypedef.thrift b/lib/go/test/ForwardType.thrift index 4266b7a28..0433c97cf 100644 --- a/lib/go/test/ForwardTypedef.thrift +++ b/lib/go/test/ForwardType.thrift @@ -17,17 +17,14 @@ * under the License. */ -// https://issues.apache.org/jira/browse/THRIFT-5601 +// https://issues.apache.org/jira/browse/THRIFT-5685 -namespace go forwardtypedef +namespace go forwardtypetest struct Struct { - 1: optional Def foo - 2: optional Exc bar + 1: optional Exc foo } -typedef i32 Def - exception Exc { 1: optional i32 code } diff --git a/lib/go/test/Makefile.am b/lib/go/test/Makefile.am index c255a8e48..cb8928bc8 100644 --- a/lib/go/test/Makefile.am +++ b/lib/go/test/Makefile.am @@ -62,7 +62,7 @@ gopath: $(THRIFT) $(THRIFTTEST) \ ProcessorMiddlewareTest.thrift \ ClientMiddlewareExceptionTest.thrift \ ValidateTest.thrift \ - ForwardTypedef.thrift + ForwardType.thrift mkdir -p gopath/src grep -v list.*map.*list.*map $(THRIFTTEST) | grep -v 'set<Insanity>' > ThriftTest.thrift $(THRIFT) $(THRIFTARGS) -r IncludesTest.thrift @@ -97,7 +97,7 @@ gopath: $(THRIFT) $(THRIFTTEST) \ $(THRIFT) $(THRIFTARGS_SKIP_REMOTE) ProcessorMiddlewareTest.thrift $(THRIFT) $(THRIFTARGS) ClientMiddlewareExceptionTest.thrift $(THRIFT) $(THRIFTARGS) ValidateTest.thrift - $(THRIFT) $(THRIFTARGS) ForwardTypedef.thrift + $(THRIFT) $(THRIFTARGS) ForwardType.thrift ln -nfs ../../tests gopath/src/tests cp -r ./dontexportrwtest gopath/src touch gopath @@ -124,7 +124,7 @@ check: gopath ./gopath/src/processormiddlewaretest \ ./gopath/src/clientmiddlewareexceptiontest \ ./gopath/src/validatetest \ - ./gopath/src/forwardtypedef + ./gopath/src/forwardtypetest $(GO) test github.com/apache/thrift/lib/go/thrift $(GO) test ./gopath/src/tests ./gopath/src/dontexportrwtest @@ -155,6 +155,7 @@ EXTRA_DIST = \ DuplicateImportsTest.thrift \ ErrorTest.thrift \ EqualsTest.thrift \ + ForwardType.thrift \ GoTagTest.thrift \ IgnoreInitialismsTest.thrift \ IncludesTest.thrift \ diff --git a/lib/go/test/tests/forwardtype_test.go b/lib/go/test/tests/forwardtype_test.go new file mode 100644 index 000000000..99b7890e6 --- /dev/null +++ b/lib/go/test/tests/forwardtype_test.go @@ -0,0 +1,41 @@ +/* + * 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 ( + "testing" + + "github.com/apache/thrift/lib/go/test/gopath/src/forwardtypetest" + "github.com/apache/thrift/lib/go/thrift" +) + +func TestForwardType(t *testing.T) { + // See https://issues.apache.org/jira/browse/THRIFT-5685 + + const code = int32(1) + foo := &forwardtypetest.Struct{ + Foo: &forwardtypetest.Exc{ + Code: thrift.Pointer(code), + }, + } + if got, want := foo.GetFoo().GetCode(), code; got != want { + t.Errorf("code got %v want %v", got, want) + } +} |