You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by je...@apache.org on 2014/04/07 21:22:52 UTC

git commit: THRIFT-2445 (code generation for go maps with binary keys) should be tested

Repository: thrift
Updated Branches:
  refs/heads/master bb2d2fbf6 -> 456879288


THRIFT-2445 (code generation for go maps with binary keys) should be tested

Patch: Aleksey Pesternikov


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/45687928
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/45687928
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/45687928

Branch: refs/heads/master
Commit: 456879288f4915f53fa23b9a72148696da0c5d24
Parents: bb2d2fb
Author: Jens Geyer <je...@apache.org>
Authored: Mon Apr 7 21:20:16 2014 +0200
Committer: Jens Geyer <je...@apache.org>
Committed: Mon Apr 7 21:22:01 2014 +0200

----------------------------------------------------------------------
 lib/go/test/BinaryKeyTest.thrift     | 24 ++++++++++++++++++++++++
 lib/go/test/Makefile.am              | 16 ++++++++--------
 lib/go/test/tests/binary_key_test.go | 12 ++++++++++++
 3 files changed, 44 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/45687928/lib/go/test/BinaryKeyTest.thrift
----------------------------------------------------------------------
diff --git a/lib/go/test/BinaryKeyTest.thrift b/lib/go/test/BinaryKeyTest.thrift
new file mode 100644
index 0000000..71cb614
--- /dev/null
+++ b/lib/go/test/BinaryKeyTest.thrift
@@ -0,0 +1,24 @@
+#
+# 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.
+#
+
+# Make sure that thrift produce compilable code for binary key
+struct testStruct {
+  1: required map<binary,string> bin_to_string
+}
+

http://git-wip-us.apache.org/repos/asf/thrift/blob/45687928/lib/go/test/Makefile.am
----------------------------------------------------------------------
diff --git a/lib/go/test/Makefile.am b/lib/go/test/Makefile.am
index 4e71cd0..cb6073c 100644
--- a/lib/go/test/Makefile.am
+++ b/lib/go/test/Makefile.am
@@ -17,25 +17,25 @@
 # under the License.
 #
 
-THRIFT = $(top_srcdir)/compiler/cpp/thrift
+THRIFT = $(top_srcdir)/compiler/cpp/thrift -out gopath/src/ --gen go:thrift_import=thrift
 THRIFTTEST = $(top_srcdir)/test/ThriftTest.thrift
 
 # Thrift for GO has problems with complex map keys: THRIFT-2063
-gopath: $(THRIFT) $(THRIFTTEST) IncludesTest.thrift NamespacedTest.thrift
+gopath: $(top_srcdir)/compiler/cpp/thrift $(THRIFTTEST) IncludesTest.thrift NamespacedTest.thrift
 	mkdir -p gopath/src
 	grep -v list.*map.*list.*map $(THRIFTTEST) > ThriftTest.thrift
-	$(THRIFT) --gen go:thrift_import=thrift -r IncludesTest.thrift
-	ln -nfs ../../gen-go/ThriftTest gopath/src/ThriftTest
-	ln -nfs ../../gen-go/IncludesTest gopath/src/IncludesTest
-	ln -nfs ../../gen-go/lib gopath/src/lib
+	$(THRIFT) -r IncludesTest.thrift
+	$(THRIFT) BinaryKeyTest.thrift
 	ln -nfs ../../../thrift gopath/src/thrift
+	ln -nfs ../../tests gopath/src/tests
 	touch gopath
 
 check: gopath
-	GOPATH=`pwd`/gopath $(GO) build IncludesTest
+	GOPATH=`pwd`/gopath $(GO) build IncludesTest BinaryKeyTest
+	GOPATH=`pwd`/gopath $(GO) test thrift tests
 
 clean-local:
-	$(RM) -r gen-go gopath ThriftTest.thrift
+	$(RM) -r gopath ThriftTest.thrift
 
 client: stubs
 	$(GO) run TestClient.go

http://git-wip-us.apache.org/repos/asf/thrift/blob/45687928/lib/go/test/tests/binary_key_test.go
----------------------------------------------------------------------
diff --git a/lib/go/test/tests/binary_key_test.go b/lib/go/test/tests/binary_key_test.go
new file mode 100644
index 0000000..271b244
--- /dev/null
+++ b/lib/go/test/tests/binary_key_test.go
@@ -0,0 +1,12 @@
+package tests
+
+import (
+	"BinaryKeyTest"
+	"testing"
+)
+
+func TestBinaryMapKeyGeneratesString(t *testing.T) {
+	s := BinaryKeyTest.NewTestStruct()
+	//This will only compile if BinToString has type of map[string]string
+	s.BinToString = make(map[string]string)
+}