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

migrate use_build_context_synchronously integration test #4611

Merged
merged 2 commits into from
Jul 24, 2023
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
39 changes: 0 additions & 39 deletions test/integration/use_build_context_synchronously.dart

This file was deleted.

3 changes: 0 additions & 3 deletions test/integration_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import 'integration/avoid_web_libraries_in_flutter.dart'
as avoid_web_libraries_in_flutter;
import 'integration/close_sinks.dart' as close_sinks;
import 'integration/public_member_api_docs.dart' as public_member_api_docs;
import 'integration/use_build_context_synchronously.dart'
as use_build_context_synchronously;
import 'mocks.dart';
import 'test_constants.dart';

Expand Down Expand Up @@ -128,7 +126,6 @@ void ruleTests() {
avoid_web_libraries_in_flutter.main();
close_sinks.main();
public_member_api_docs.main();
use_build_context_synchronously.main();
});
}

Expand Down
48 changes: 48 additions & 0 deletions test/rules/use_build_context_synchronously_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/src/test_utilities/find_node.dart';
import 'package:analyzer/src/utilities/legacy.dart';
import 'package:linter/src/rules/use_build_context_synchronously.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
Expand All @@ -14,6 +15,7 @@ main() {
defineReflectiveSuite(() {
defineReflectiveTests(AsyncStateTest);
defineReflectiveTests(UseBuildContextSynchronouslyTest);
defineReflectiveTests(UseBuildContextSynchronouslyMixedModeTest);
});
}

Expand Down Expand Up @@ -1630,6 +1632,52 @@ void foo(BuildContext context) async {
}
}

@reflectiveTest
class UseBuildContextSynchronouslyMixedModeTest extends LintRuleTest {
@override
bool get addFlutterPackageDep => true;

@override
String get lintRule => 'use_build_context_synchronously';

/// Ensure we're not run in the test dir.
@override
String get testPackageRootPath => '$workspaceRootPath/lib';

@override
setUp() {
super.setUp();
noSoundNullSafety = false;
}

tearDown() {
noSoundNullSafety = true;
}

/// https://github.com/dart-lang/linter/issues/2572
test_mixedMode() async {
newFile('$testPackageLibPath/migrated.dart', '''
import 'package:flutter/widgets.dart';

BuildContext? get contextOrNull => null;

void f(BuildContext? contextOrNull) {}
''');

await assertNoDiagnostics(r'''
// @dart=2.9

import 'migrated.dart';

void nullableContext() async {
f(contextOrNull);
await Future<void>.delayed(Duration());
f(contextOrNull);
}
''');
}
}

@reflectiveTest
class UseBuildContextSynchronouslyTest extends LintRuleTest {
@override
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.