[tests] Fix tests for changing type parameters
* Handle inconsistencies in the type of a notice in reload reports. * Update expected error messages when the type parameters of a class change. * Fail reload tests if rejection error was expected but the actual error is null. * Cleanup unused imports in tests. * Delete change_instance_format7 test because it was split into DDC and VM specific versions. Change-Id: I3b4d6cb3126d7c1fad688c393677e053a005687f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/408883 Reviewed-by: Mark Zhou <markzipan@google.com> Commit-Queue: Nicholas Shahan <nshahan@google.com>
This commit is contained in:
committed by
Commit Queue
parent
9e8a21bf52
commit
16960a8638
@@ -752,7 +752,7 @@ abstract class HotReloadSuiteRunner {
|
||||
return false;
|
||||
}
|
||||
final rejectionMessage = reloadReceipt.rejectionMessage;
|
||||
if (rejectionMessage != null &&
|
||||
if (rejectionMessage == null ||
|
||||
!rejectionMessage.contains(expectedError)) {
|
||||
_print(
|
||||
'Generation ${reloadReceipt.generation} was rejected but error '
|
||||
|
||||
@@ -179,7 +179,8 @@ extension on ReloadReport {
|
||||
final notices = this.json?['notices'] as List?;
|
||||
if (notices != null) {
|
||||
for (final notice in notices) {
|
||||
if (notice['type'] == 'ReasonForCancelling') {
|
||||
if (notice['type'] == 'ReasonForCancelling' ||
|
||||
notice['type'] == 'ReasonForCancellingReload') {
|
||||
return notice['message'] as String?;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
{
|
||||
"expectedErrors": {
|
||||
"1": "type parameters have changed"
|
||||
"1": "Limitation: changing type parameters does not work with hot reload."
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// 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.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:reload_test/reload_test_utils.dart';
|
||||
|
||||
// Adapted from:
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// 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.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:reload_test/reload_test_utils.dart';
|
||||
|
||||
// Adapted from:
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
|
||||
// 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.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:reload_test/reload_test_utils.dart';
|
||||
|
||||
// Adapted from:
|
||||
// https://github.com/dart-lang/sdk/blob/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L4051
|
||||
|
||||
// Tests reload succeeds when type parameters are changed for allocated class.
|
||||
// Change: Foo<A,B> {a, b} -> Foo<A> {a}
|
||||
// Validate: return value from main is correct.
|
||||
// Please note: This test works because no instances are created from Foo.
|
||||
|
||||
class Foo<A, B> {
|
||||
var a;
|
||||
var b;
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
await hotReload();
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
|
||||
// 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.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:reload_test/reload_test_utils.dart';
|
||||
|
||||
// Adapted from:
|
||||
// https://github.com/dart-lang/sdk/blob/1a486499bf73ee5b007abbe522b94869a1f36d02/runtime/vm/isolate_reload_test.cc#L4051
|
||||
|
||||
// Tests reload succeeds when type parameters are changed for allocated class.
|
||||
// Change: Foo<A,B> {a, b} -> Foo<A> {a}
|
||||
// Validate: return value from main is correct.
|
||||
// Please note: This test works because no instances are created from Foo.
|
||||
|
||||
class Foo<A> {
|
||||
var a;
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
await hotReload();
|
||||
}
|
||||
|
||||
/** DIFF **/
|
||||
/*
|
||||
// Validate: return value from main is correct.
|
||||
// Please note: This test works because no instances are created from Foo.
|
||||
|
||||
-class Foo<A, B> {
|
||||
+class Foo<A> {
|
||||
var a;
|
||||
- var b;
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
*/
|
||||
@@ -1,6 +1,8 @@
|
||||
{
|
||||
"exclude": ["vm"],
|
||||
"exclude": [
|
||||
"vm"
|
||||
],
|
||||
"expectedErrors": {
|
||||
"1": "type parameters have changed"
|
||||
"1": "Limitation: changing type parameters does not work with hot reload."
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// 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.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:reload_test/reload_test_utils.dart';
|
||||
|
||||
// Adapted from:
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// 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.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:reload_test/reload_test_utils.dart';
|
||||
|
||||
// Adapted from:
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// 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.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:reload_test/reload_test_utils.dart';
|
||||
|
||||
// Adapted from:
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// 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.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:reload_test/reload_test_utils.dart';
|
||||
|
||||
// Adapted from:
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
{
|
||||
"expectedErrors": {
|
||||
"1": "type parameters have changed"
|
||||
"1": "Limitation: changing type parameters does not work with hot reload."
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// 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.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:reload_test/reload_test_utils.dart';
|
||||
|
||||
// Adapted from:
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// 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.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:reload_test/reload_test_utils.dart';
|
||||
|
||||
// Adapted from:
|
||||
|
||||
Reference in New Issue
Block a user