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

Assertion failure when building test protos with assertions enabled #608

Open
osa1 opened this issue Apr 11, 2022 · 0 comments
Open

Assertion failure when building test protos with assertions enabled #608

osa1 opened this issue Apr 11, 2022 · 0 comments
Labels

Comments

@osa1
Copy link
Member

osa1 commented Apr 11, 2022

Just realized while debugging #605 with assertions that in master branch we currently have assertion failures when test protos are being compiled with assertions enabled. To reproduce enable assertions with this patch:

diff --git a/protoc_plugin/bin/protoc-gen-dart b/protoc_plugin/bin/protoc-gen-dart
index b1f8169..86b62aa 100755
--- a/protoc_plugin/bin/protoc-gen-dart
+++ b/protoc_plugin/bin/protoc-gen-dart
@@ -1,3 +1,3 @@
 #!/bin/bash
 BINDIR=$(dirname "$0")
-dart "$BINDIR/protoc_plugin.dart" -c "$@"
+dart --enable-asserts "$BINDIR/protoc_plugin.dart" -c "$@"

Now build test protos as usual:

$ make protos
[ -d out/protos ] || mkdir -p out/protos
protoc\
		--experimental_allow_proto3_optional\
		--dart_out=out/protos\
		-Iprotos\
		-Itest/protos\
		--plugin=protoc-gen-dart=/Users/omersa/dart/protobuf.dart/protoc_plugin/bin/protoc-gen-dart\
		 test/protos/_leading_underscores.proto  test/protos/google/protobuf/any.proto  test/protos/google/protobuf/api.proto  test/protos/google/protobuf/duration.proto  test/protos/google/protobuf/empty.proto  test/protos/google/protobuf/field_mask.proto  test/protos/google/protobuf/source_context.proto  test/protos/google/protobuf/struct.proto  test/protos/google/protobuf/timestamp.proto  test/protos/google/protobuf/type.proto  test/protos/google/protobuf/unittest_import.proto  test/protos/google/protobuf/unittest_optimize_for.proto  test/protos/google/protobuf/unittest_well_known_types.proto  test/protos/google/protobuf/unittest.proto  test/protos/google/protobuf/wrappers.proto  test/protos/custom_option.proto  test/protos/dart_name.proto  test/protos/default_value_escape.proto  test/protos/enum_extension.proto  test/protos/enum_name.proto  test/protos/extend_unittest.proto  test/protos/ExtensionEnumNameConflict.proto  test/protos/ExtensionNameConflict.proto  test/protos/foo.proto  test/protos/high_tagnumber.proto  test/protos/import_clash.proto  test/protos/import_public.proto  test/protos/json_name.proto  test/protos/map_api.proto  test/protos/map_api2.proto  test/protos/map_enum_value.proto  test/protos/map_field.proto  test/protos/mixins.proto  test/protos/multiple_files_test.proto  test/protos/nested_extension.proto  test/protos/non_nested_extension.proto  test/protos/oneof.proto  test/protos/reserved_names.proto  test/protos/reserved_names_extension.proto  test/protos/reserved_names_message.proto  test/protos/duplicate_names_import.proto  test/protos/package1.proto  test/protos/package2.proto  test/protos/package3.proto  test/protos/proto3_optional.proto  test/protos/service.proto  test/protos/service2.proto  test/protos/service3.proto  test/protos/toplevel_import.proto  test/protos/toplevel.proto  test/protos/using_any.proto
Unhandled exception:
'package:protoc_plugin/src/protobuf_field.dart': Failed assertion: line 313 pos 12: '!isRepeated': is not true.
#0      _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61)
#1      _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5)
#2      ProtobufField.generateDefaultFunction (package:protoc_plugin/src/protobuf_field.dart:313:12)
#3      ProtobufField.generateBuilderInfoCall (package:protoc_plugin/src/protobuf_field.dart:225:39)
#4      MessageGenerator.generate.<anonymous closure>.<anonymous closure> (package:protoc_plugin/src/message_generator.dart:345:29)
#5      IndentingWriter._addBlockBodyAndEnd (package:protoc_plugin/indenting_writer.dart:95:9)
#6      IndentingWriter.addBlock (package:protoc_plugin/indenting_writer.dart:73:5)
#7      MessageGenerator.generate.<anonymous closure> (package:protoc_plugin/src/message_generator.dart:331:11)
#8      IndentingWriter._addBlockBodyAndEnd (package:protoc_plugin/indenting_writer.dart:95:9)
#9      IndentingWriter.addAnnotatedBlock (package:protoc_plugin/indenting_writer.dart:88:5)
#10     MessageGenerator.generate (package:protoc_plugin/src/message_generator.dart:310:9)
#11     FileGenerator.generateMainFile (package:protoc_plugin/src/file_generator.dart:273:9)
#12     FileGenerator.generateFiles (package:protoc_plugin/src/file_generator.dart:232:22)
#13     CodeGenerator.generate.<anonymous closure> (package:protoc_plugin/src/code_generator.dart:127:36)
<asynchronous suspension>
--dart_out: protoc-gen-dart: Plugin failed with status code 255.
make: *** [out/protos/_leading_underscores.pb.dart] Error 1

In general we should run the tests with the assertions enabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant