From b4dd686ab484c7e8ab31b8624c4a70ae355fc614 Mon Sep 17 00:00:00 2001 From: Adam Cozzette Date: Fri, 18 Nov 2016 10:22:46 -0800 Subject: [PATCH 1/4] Updated enum names in test.proto to avoid conflicting with testbinary.proto --- js/test.proto | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js/test.proto b/js/test.proto index 52ba2cc1c83c0..2be5b8c184140 100644 --- a/js/test.proto +++ b/js/test.proto @@ -254,9 +254,9 @@ message TestMapFieldsNoBinary { } enum MapValueEnumNoBinary { - MAP_VALUE_FOO = 0; - MAP_VALUE_BAR = 1; - MAP_VALUE_BAZ = 2; + MAP_VALUE_FOO_NOBINARY = 0; + MAP_VALUE_BAR_NOBINARY = 1; + MAP_VALUE_BAZ_NOBINARY = 2; } message MapValueMessageNoBinary { From 315350b2fa37201851ac298627e5547cfca64798 Mon Sep 17 00:00:00 2001 From: Adam Cozzette Date: Fri, 18 Nov 2016 11:19:30 -0800 Subject: [PATCH 2/4] Updated message_test.js so that it does not depend on fromObject --- js/message_test.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/js/message_test.js b/js/message_test.js index 38ed136087763..c029a04dddcfa 100644 --- a/js/message_test.js +++ b/js/message_test.js @@ -1049,13 +1049,7 @@ describe('Message test suite', function() { var nested = new proto.jspb.test.Deeply.Nested.Message(); nested.setCount(5); msg.setDeeplyNestedMessage(nested); - - // After a serialization-deserialization round trip we should get back the - // same data we started with. - var serialized = msg.toObject(); - var deserialized = - proto.jspb.test.ForeignNestedFieldMessage.fromObject(serialized); - assertEquals(5, deserialized.getDeeplyNestedMessage().getCount()); + assertEquals(5, msg.getDeeplyNestedMessage().getCount()); }); }); From 40f3586412c2efa7a81ccb685e6f96e817996e36 Mon Sep 17 00:00:00 2001 From: Adam Cozzette Date: Fri, 18 Nov 2016 12:32:52 -0800 Subject: [PATCH 3/4] Fixed remaining JSPB test failures --- js/binary/proto_test.js | 2 +- js/commonjs/export.js | 1 + js/commonjs/export_testdeps.js | 1 + js/gulpfile.js | 6 +++--- js/jasmine.json | 5 ++++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/js/binary/proto_test.js b/js/binary/proto_test.js index ae50a703844ca..f86dc6455bb48 100644 --- a/js/binary/proto_test.js +++ b/js/binary/proto_test.js @@ -88,7 +88,7 @@ goog.require('proto.jspb.test.extendRepeatedStringList'); goog.require('proto.jspb.test.extendRepeatedUint32List'); goog.require('proto.jspb.test.extendRepeatedUint64List'); -// CommonJS-LoadFromFile: google/protobuf/any_pb proto.google.protobuf +// CommonJS-LoadFromFile: ../node_modules/google-protobuf/google/protobuf/any_pb proto.google.protobuf goog.require('proto.google.protobuf.Any'); diff --git a/js/commonjs/export.js b/js/commonjs/export.js index 2403b1a490ccc..1eaab5d51cbe4 100644 --- a/js/commonjs/export.js +++ b/js/commonjs/export.js @@ -24,3 +24,4 @@ exports.ExtensionFieldBinaryInfo = jspb.ExtensionFieldBinaryInfo; exports.exportSymbol = goog.exportSymbol; exports.inherits = goog.inherits; exports.object = {extend: goog.object.extend}; +exports.typeOf = goog.typeOf; diff --git a/js/commonjs/export_testdeps.js b/js/commonjs/export_testdeps.js index 59c77ca2cd4f3..174c61e6840c4 100644 --- a/js/commonjs/export_testdeps.js +++ b/js/commonjs/export_testdeps.js @@ -12,6 +12,7 @@ goog.require('jspb.arith.Int64'); goog.require('jspb.arith.UInt64'); goog.require('jspb.BinaryEncoder'); goog.require('jspb.BinaryDecoder'); +goog.require('jspb.BinaryWriter'); goog.require('jspb.utils'); exports.goog = goog; diff --git a/js/gulpfile.js b/js/gulpfile.js index cca99131a77b5..5f1b1d93f6081 100644 --- a/js/gulpfile.js +++ b/js/gulpfile.js @@ -24,7 +24,7 @@ var wellKnownTypes = [ ]; gulp.task('genproto_closure', function (cb) { - exec(protoc + ' --js_out=library=testproto_libs,binary:. -I ../src -I . *.proto ../src/google/protobuf/descriptor.proto', + exec(protoc + ' --js_out=library=testproto_libs,binary:. -I ../src -I . *.proto && ' + protoc + ' --js_out=one_output_file_per_input_file,binary:. -I ../src -I . ' + wellKnownTypes.join(' '), function (err, stdout, stderr) { console.log(stdout); console.log(stderr); @@ -33,7 +33,7 @@ gulp.task('genproto_closure', function (cb) { }); gulp.task('genproto_commonjs', function (cb) { - exec('mkdir -p commonjs_out && ' + protoc + ' --js_out=import_style=commonjs,binary:commonjs_out -I ../src -I commonjs -I . *.proto commonjs/test*/*.proto ../src/google/protobuf/descriptor.proto', + exec('mkdir -p commonjs_out && ' + protoc + ' --js_out=import_style=commonjs,binary:commonjs_out -I ../src -I commonjs -I . *.proto commonjs/test*/*.proto ' + wellKnownTypes.join(' '), function (err, stdout, stderr) { console.log(stdout); console.log(stderr); @@ -42,7 +42,7 @@ gulp.task('genproto_commonjs', function (cb) { }); gulp.task('genproto_commonjs_wellknowntypes', function (cb) { - exec('mkdir -p commonjs_out/node_modules/google-protobuf && ' + protoc + ' --js_out=import_style=commonjs,binary:commonjs_out/node_modules/google-protobuf -I ../src ../src/google/protobuf/descriptor.proto', + exec('mkdir -p commonjs_out/node_modules/google-protobuf && ' + protoc + ' --js_out=import_style=commonjs,binary:commonjs_out/node_modules/google-protobuf -I ../src ' + wellKnownTypes.join(' '), function (err, stdout, stderr) { console.log(stdout); console.log(stderr); diff --git a/js/jasmine.json b/js/jasmine.json index f83c54c09d35d..093f15794f71b 100644 --- a/js/jasmine.json +++ b/js/jasmine.json @@ -7,6 +7,9 @@ "helpers": [ "node_modules/google-closure-library/closure/goog/bootstrap/nodejs.js", "node_loader.js", - "deps.js" + "deps.js", + "google/protobuf/any.js", + "google/protobuf/struct.js", + "google/protobuf/timestamp.js" ] } From fda876a1492fcd7120c66abac1b47a9361f928df Mon Sep 17 00:00:00 2001 From: Adam Cozzette Date: Mon, 21 Nov 2016 12:14:42 -0800 Subject: [PATCH 4/4] Added back in binary serialization round-trip in message_test.js --- js/message_test.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/js/message_test.js b/js/message_test.js index c029a04dddcfa..082da944b3b1f 100644 --- a/js/message_test.js +++ b/js/message_test.js @@ -1050,6 +1050,13 @@ describe('Message test suite', function() { nested.setCount(5); msg.setDeeplyNestedMessage(nested); assertEquals(5, msg.getDeeplyNestedMessage().getCount()); + + // After a serialization-deserialization round trip we should get back the + // same data we started with. + var serialized = msg.serializeBinary(); + var deserialized = + proto.jspb.test.ForeignNestedFieldMessage.deserializeBinary(serialized); + assertEquals(5, deserialized.getDeeplyNestedMessage().getCount()); }); });