Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[flutter_tools] Migrate more tool tests to null-safety #108639

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

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -1439,7 +1439,7 @@ String generateFakePubspec(
/// It ends up holding the full graph of dependencies, and the version number for
/// each one.
class PubDependencyTree {
final Map<String, String?> _versions = <String, String>{};
final Map<String, String?> _versions = <String, String?>{};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a bug, although apparently didn't get hit in regular usage

final Map<String, Set<String>> _dependencyTree = <String, Set<String>>{};

/// Handles the output from "pub deps --style=compact".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart = 2.8

import 'dart:convert';

import 'package:args/command_runner.dart';
Expand All @@ -23,10 +21,10 @@ import '../../src/context.dart';
import '../../src/test_flutter_command_runner.dart';

void main() {
FakeAndroidStudio fakeAndroidStudio;
FakeAndroidSdk fakeAndroidSdk;
FakeFlutterVersion fakeFlutterVersion;
TestUsage testUsage;
late FakeAndroidStudio fakeAndroidStudio;
late FakeAndroidSdk fakeAndroidSdk;
late FakeFlutterVersion fakeFlutterVersion;
late TestUsage testUsage;

setUpAll(() {
Cache.disableLocking();
Expand Down Expand Up @@ -288,7 +286,7 @@ class FakeAndroidSdk extends Fake implements AndroidSdk {

class FakeFlutterVersion extends Fake implements FlutterVersion {
@override
String channel;
late String channel;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried making this a getter backed by a nullable private, but the analyzer insisted I just use late.


@override
void ensureVersionFile() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart = 2.8

import 'package:args/command_runner.dart';
import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/file_system.dart';
Expand All @@ -12,15 +10,14 @@ import 'package:flutter_tools/src/commands/packages.dart';
import 'package:flutter_tools/src/dart/pub.dart';
import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/reporting/reporting.dart';
import 'package:meta/meta.dart';
import 'package:test/fake.dart';

import '../../src/context.dart';
import '../../src/test_flutter_command_runner.dart';

void main() {
FileSystem fileSystem;
FakePub pub;
late FileSystem fileSystem;
late FakePub pub;

setUp(() {
Cache.disableLocking();
Expand Down Expand Up @@ -124,13 +121,13 @@ class FakePub extends Fake implements Pub {

@override
Future<void> get({
@required PubContext context,
String directory,
required PubContext context,
String? directory,
bool skipIfAbsent = false,
bool upgrade = false,
bool offline = false,
bool generateSyntheticPackage = false,
String flutterRootOverride,
String? flutterRootOverride,
bool checkUpToDate = false,
bool shouldSkipThirdPartyGenerator = true,
bool printProgress = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart = 2.8

import 'package:file/file.dart';
import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/update_packages.dart';
import 'package:flutter_tools/src/dart/pub.dart';
import 'package:meta/meta.dart';
import 'package:test/fake.dart';
import 'package:yaml/yaml.dart';

Expand Down Expand Up @@ -85,10 +82,10 @@ void main() {
});

group('update-packages', () {
FileSystem fileSystem;
Directory flutterSdk;
Directory flutter;
FakePub pub;
late FileSystem fileSystem;
late Directory flutterSdk;
late Directory flutter;
late FakePub pub;

setUpAll(() {
Cache.disableLocking();
Expand Down Expand Up @@ -209,7 +206,6 @@ void main() {
isTransitive: false,
),
],
doUpgrade: false,
);
final YamlMap pubspec = loadYaml(pubspecSource) as YamlMap;
expect((pubspec['dependencies'] as YamlMap)['foo'], prevVersion);
Expand All @@ -226,18 +222,20 @@ class FakePub extends Fake implements Pub {

@override
Future<void> get({
@required PubContext context,
String directory,
required PubContext context,
String? directory,
bool skipIfAbsent = false,
bool upgrade = false,
bool offline = false,
bool generateSyntheticPackage = false,
String flutterRootOverride,
String? flutterRootOverride,
bool checkUpToDate = false,
bool shouldSkipThirdPartyGenerator = true,
bool printProgress = true,
}) async {
pubGetDirectories.add(directory);
if (directory != null) {
pubGetDirectories.add(directory);
}
fileSystem.directory(directory).childFile('pubspec.lock')
..createSync(recursive: true)
..writeAsStringSync('''
Expand All @@ -264,14 +262,16 @@ sdks:
@override
Future<void> batch(
List<String> arguments, {
@required PubContext context,
String directory,
MessageFilter filter,
required PubContext context,
String? directory,
MessageFilter? filter,
String failureMessage = 'pub failed',
@required bool retry,
bool showTraceForErrors,
required bool retry,
bool? showTraceForErrors,
}) async {
pubBatchDirectories.add(directory);
if (directory != null) {
pubBatchDirectories.add(directory);
}

'''
Dart SDK 2.16.0-144.0.dev
Expand All @@ -290,6 +290,6 @@ dev dependencies:
transitive dependencies:
- platform 3.1.0
- process 4.2.4 [file path platform]
'''.split('\n').forEach(filter);
'''.split('\n').forEach(filter!);
}
}