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

Fixed JSPB test failures #2400

Merged
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
2 changes: 1 addition & 1 deletion js/binary/proto_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');


Expand Down
1 change: 1 addition & 0 deletions js/commonjs/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
1 change: 1 addition & 0 deletions js/commonjs/export_testdeps.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions js/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion js/jasmine.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
5 changes: 3 additions & 2 deletions js/message_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1049,12 +1049,13 @@ describe('Message test suite', function() {
var nested = new proto.jspb.test.Deeply.Nested.Message();
nested.setCount(5);
msg.setDeeplyNestedMessage(nested);
assertEquals(5, msg.getDeeplyNestedMessage().getCount());

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this serialize/deserialize roundtrip removed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found that we don't currently generate fromObject methods (the code for it exists in js_generator.cc but is never called), so it seemed simplest to just avoid doing the round trip.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it still have the same test coverage? I thought the original bug can only be revealed after a round-trip. Is it not the case?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I went ahead and added the binary serialization round trip back in.

// After a serialization-deserialization round trip we should get back the
// same data we started with.
var serialized = msg.toObject();
var serialized = msg.serializeBinary();
var deserialized =
proto.jspb.test.ForeignNestedFieldMessage.fromObject(serialized);
proto.jspb.test.ForeignNestedFieldMessage.deserializeBinary(serialized);
assertEquals(5, deserialized.getDeeplyNestedMessage().getCount());
});

Expand Down
6 changes: 3 additions & 3 deletions js/test.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down