CQ. Merge test classes in AssignmentOfDoNotStoreTest and ReturnOfDoNotStoreTest.

We can do this now, with more precise test directory identification.

Change-Id: I690753c9d9676ed0f60cb4c662df04d853180351
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505520
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
Konstantin Shcheglov
2026-05-22 11:25:50 -07:00
committed by dart-scoped@luci-project-accounts.iam.gserviceaccount.com
parent 7679be813f
commit 19f0f72d9e
2 changed files with 39 additions and 73 deletions
@@ -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:analyzer/file_system/file_system.dart';
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -12,46 +11,12 @@ import '../dart/resolution/node_text_expectations.dart';
main() {
defineReflectiveSuite(() {
defineReflectiveTests(AssignmentOfDoNotStoreTest);
defineReflectiveTests(AssignmentOfDoNotStoreInTestsTest);
defineReflectiveTests(UpdateNodeTextExpectations);
});
}
@reflectiveTest
class AssignmentOfDoNotStoreInTestsTest extends PubPackageResolutionTest {
@override
File get testFile => getFile('$testPackageRootPath/test/test.dart');
@override
void setUp() {
super.setUp();
writeTestPackageConfigWithMeta();
}
test_noHintsInTestDir() async {
// Code that is in a test dir should not trigger the hint.
// (See:https://github.com/dart-lang/sdk/issues/45594)
await resolveTestCodeWithDiagnostics(r'''
import 'package:meta/meta.dart';
class A {
@doNotStore
String get v => '';
}
class B {
String f = A().v;
}
''');
}
}
@reflectiveTest
class AssignmentOfDoNotStoreTest extends PubPackageResolutionTest {
/// Override the default which is in .../test and should not trigger hints.
@override
String get testPackageRootPath => '$workspaceRootPath/test_project';
@override
void setUp() {
super.setUp();
@@ -254,6 +219,24 @@ abstract class A {
''');
}
test_noHintsInTestDir() async {
// Code that is in a test dir should not trigger the hint.
// (See:https://github.com/dart-lang/sdk/issues/45594)
await resolveFileCode('$testPackageRootPath/test/test.dart', r'''
import 'package:meta/meta.dart';
class A {
@doNotStore
String get v => '';
}
class B {
String f = A().v;
}
''');
assertNoErrorsInResult();
}
test_tearOff() async {
await resolveTestCodeWithDiagnostics(r'''
import 'package:meta/meta.dart';
@@ -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:analyzer/file_system/file_system.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
import '../dart/resolution/context_collection_resolution.dart';
@@ -10,50 +9,13 @@ import '../dart/resolution/node_text_expectations.dart';
main() {
defineReflectiveSuite(() {
defineReflectiveTests(ReturnOfDoNotStoreInTestsTest);
defineReflectiveTests(ReturnOfDoNotStoreTest);
defineReflectiveTests(UpdateNodeTextExpectations);
});
}
@reflectiveTest
class ReturnOfDoNotStoreInTestsTest extends PubPackageResolutionTest {
@override
File get testFile => getFile('$testPackageRootPath/test/test.dart');
@override
void setUp() {
super.setUp();
writeTestPackageConfigWithMeta();
}
test_noHintsInTestDir() async {
// Code that is in a test dir should not trigger the hint.
// (See:https://github.com/dart-lang/sdk/issues/45594)
await resolveTestCodeWithDiagnostics(r'''
import 'package:meta/meta.dart';
@doNotStore
String get _v => '';
String f() {
var v = () => _v;
return v();
}
String g() {
return _v;
}
''');
}
}
@reflectiveTest
class ReturnOfDoNotStoreTest extends PubPackageResolutionTest {
/// Override the default which is in .../test and should not trigger hints.
@override
String get testPackageRootPath => '$workspaceRootPath/test_project';
@override
void setUp() {
super.setUp();
@@ -78,6 +40,27 @@ class A {
''');
}
test_noHintsInTestDir() async {
// Code that is in a test dir should not trigger the hint.
// (See:https://github.com/dart-lang/sdk/issues/45594)
await resolveFileCode('$testPackageRootPath/test/test.dart', r'''
import 'package:meta/meta.dart';
@doNotStore
String get _v => '';
String f() {
var v = () => _v;
return v();
}
String g() {
return _v;
}
''');
assertNoErrorsInResult();
}
test_returnFromClosureInFunction() async {
await resolveTestCodeWithDiagnostics(r'''
import 'package:meta/meta.dart';