CI: Also run plugin tests on Chrome, with dart2js and dart2wasm (#1031)
diff --git a/.github/workflows/protoc_plugin.yaml b/.github/workflows/protoc_plugin.yaml
index 8043eb9..243cab1 100644
--- a/.github/workflows/protoc_plugin.yaml
+++ b/.github/workflows/protoc_plugin.yaml
@@ -35,3 +35,7 @@
- run: dart format --output=none --set-exit-if-changed lib
- run: dart test
+
+ - run: dart test -p chrome -c dart2js
+
+ - run: dart test -p chrome -c dart2wasm
diff --git a/protoc_plugin/test/client_generator_test.dart b/protoc_plugin/test/client_generator_test.dart
index f1fb0b8..4395664 100644
--- a/protoc_plugin/test/client_generator_test.dart
+++ b/protoc_plugin/test/client_generator_test.dart
@@ -2,6 +2,9 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+@TestOn('vm')
+library;
+
import 'package:protoc_plugin/indenting_writer.dart';
import 'package:protoc_plugin/protoc.dart';
import 'package:protoc_plugin/src/linker.dart';
diff --git a/protoc_plugin/test/deprecations_test.dart b/protoc_plugin/test/deprecations_test.dart
index 42a0b2c..1c07e48 100644
--- a/protoc_plugin/test/deprecations_test.dart
+++ b/protoc_plugin/test/deprecations_test.dart
@@ -2,6 +2,9 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+@TestOn('vm')
+library;
+
import 'dart:io';
import 'package:test/test.dart';
diff --git a/protoc_plugin/test/doc_comments_test.dart b/protoc_plugin/test/doc_comments_test.dart
index ccd2edf..db65f17 100644
--- a/protoc_plugin/test/doc_comments_test.dart
+++ b/protoc_plugin/test/doc_comments_test.dart
@@ -2,6 +2,9 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+@TestOn('vm')
+library;
+
import 'dart:io';
import 'package:test/test.dart';
diff --git a/protoc_plugin/test/enum_generator_test.dart b/protoc_plugin/test/enum_generator_test.dart
index a60ad71..f41bd0a 100644
--- a/protoc_plugin/test/enum_generator_test.dart
+++ b/protoc_plugin/test/enum_generator_test.dart
@@ -2,6 +2,9 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+@TestOn('vm')
+library;
+
import 'package:protoc_plugin/indenting_writer.dart';
import 'package:protoc_plugin/protoc.dart';
import 'package:protoc_plugin/src/gen/google/protobuf/descriptor.pb.dart';
diff --git a/protoc_plugin/test/extension_generator_test.dart b/protoc_plugin/test/extension_generator_test.dart
index e09e9f7..bd3775a 100644
--- a/protoc_plugin/test/extension_generator_test.dart
+++ b/protoc_plugin/test/extension_generator_test.dart
@@ -2,6 +2,9 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+@TestOn('vm')
+library;
+
import 'package:protoc_plugin/indenting_writer.dart';
import 'package:protoc_plugin/protoc.dart';
import 'package:protoc_plugin/src/gen/google/protobuf/compiler/plugin.pb.dart'
diff --git a/protoc_plugin/test/file_generator_test.dart b/protoc_plugin/test/file_generator_test.dart
index d561053..13b931d 100644
--- a/protoc_plugin/test/file_generator_test.dart
+++ b/protoc_plugin/test/file_generator_test.dart
@@ -2,6 +2,9 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+@TestOn('vm')
+library;
+
import 'package:protoc_plugin/indenting_writer.dart';
import 'package:protoc_plugin/protoc.dart';
import 'package:protoc_plugin/src/gen/google/api/client.pb.dart';
diff --git a/protoc_plugin/test/generated_message_test.dart b/protoc_plugin/test/generated_message_test.dart
index 6d35ac8..5f7cf9a 100644
--- a/protoc_plugin/test/generated_message_test.dart
+++ b/protoc_plugin/test/generated_message_test.dart
@@ -115,10 +115,10 @@
expect(message.utf8String, '\u1234');
expect(message.infDouble, same(double.infinity));
expect(message.negInfDouble, same(double.negativeInfinity));
- expect(message.nanDouble, same(double.nan));
+ expect(message.nanDouble.isNaN, isTrue);
expect(message.infFloat, same(double.infinity));
expect(message.negInfFloat, same(double.negativeInfinity));
- expect(message.nanFloat, same(double.nan));
+ expect(message.nanFloat.isNaN, isTrue);
expect(message.cppTrigraph, '? ? ?? ?? ??? ??/ ??-');
expect(
message.smallInt64.toRadixString(16).toUpperCase(),
diff --git a/protoc_plugin/test/message_generator_test.dart b/protoc_plugin/test/message_generator_test.dart
index 6d6e070..5585e5c 100644
--- a/protoc_plugin/test/message_generator_test.dart
+++ b/protoc_plugin/test/message_generator_test.dart
@@ -2,6 +2,9 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+@TestOn('vm')
+library;
+
import 'dart:collection';
import 'package:collection/collection.dart';
diff --git a/protoc_plugin/test/oneof_test.dart b/protoc_plugin/test/oneof_test.dart
index 9b17832..a99cc31 100644
--- a/protoc_plugin/test/oneof_test.dart
+++ b/protoc_plugin/test/oneof_test.dart
@@ -113,29 +113,43 @@
});
test('serialize and parse concat oneof', () {
- var foo = Foo()..first = 'oneof';
- expectFirstSet(foo);
+ final foo1 = Foo()..first = 'oneof';
+ expectFirstSet(foo1);
final foo2 = Foo()..second = 1;
expectSecondSet(foo2);
- final concat = [...foo.writeToBuffer(), ...foo2.writeToBuffer()];
- foo = Foo.fromBuffer(concat);
- expectSecondSet(foo);
+ final concat = [...foo1.writeToBuffer(), ...foo2.writeToBuffer()];
+ expectSecondSet(Foo.fromBuffer(concat));
});
test('JSON serialize and parse concat oneof', () {
- var foo = Foo()..first = 'oneof';
- expectFirstSet(foo);
+ final foo1 = Foo()..first = 'oneof';
+ expectFirstSet(foo1);
final foo2 = Foo()..second = 1;
expectSecondSet(foo2);
final jsonConcat =
'${foo2.writeToJson().substring(0, foo2.writeToJson().length - 1)}, '
- '${foo.writeToJson().substring(1)}';
- foo = Foo.fromJson(jsonConcat);
- expectFirstSet(foo);
+ '${foo1.writeToJson().substring(1)}';
+
+ final decoded = Foo.fromJson(jsonConcat);
+
+ // It's unclear how to handle the input `{5:..., 1:...}` in this format. In
+ // the browsers we want to use the browser's JSON decoder, for performance.
+ // However numeric properties in JS objects are always iterated in ascending
+ // order, so that makes `5` override the previous oneof value, regardless of
+ // the orders of keys in the JSON string. In the backends that have their
+ // own map types (VM and Wasm) the key that comes later override the
+ // previous one.
+ if (identical(1.0, 1)) {
+ // In JS: '5' comes last during object key iteration.
+ expectSecondSet(decoded);
+ } else {
+ // In VM and Wasm: '1' comes last during object iteration.
+ expectFirstSet(decoded);
+ }
});
test('set and clear second oneof field', () {
diff --git a/protoc_plugin/test/reserved_names_test.dart b/protoc_plugin/test/reserved_names_test.dart
index 56376c3..26f002c 100644
--- a/protoc_plugin/test/reserved_names_test.dart
+++ b/protoc_plugin/test/reserved_names_test.dart
@@ -2,6 +2,9 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+@TestOn('vm')
+library;
+
import 'dart:collection' show MapMixin;
import 'dart:mirrors';
diff --git a/protoc_plugin/test/send_protos_via_sendports_test.dart b/protoc_plugin/test/send_protos_via_sendports_test.dart
index 39b8b8a..8e60b33 100644
--- a/protoc_plugin/test/send_protos_via_sendports_test.dart
+++ b/protoc_plugin/test/send_protos_via_sendports_test.dart
@@ -2,6 +2,9 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+@TestOn('vm')
+library;
+
import 'dart:isolate';
import 'package:test/test.dart';
diff --git a/protoc_plugin/test/service_generator_test.dart b/protoc_plugin/test/service_generator_test.dart
index 98dfcb4..52c2401 100644
--- a/protoc_plugin/test/service_generator_test.dart
+++ b/protoc_plugin/test/service_generator_test.dart
@@ -2,6 +2,9 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+@TestOn('vm')
+library;
+
import 'package:protoc_plugin/indenting_writer.dart';
import 'package:protoc_plugin/protoc.dart';
import 'package:protoc_plugin/src/linker.dart';