Migrate pub in flutter_tools to null safety (#80548)

This commit is contained in:
Jenn Magder
2021-04-16 17:23:00 -07:00
committed by GitHub
parent 72976f552c
commit 8d5f08fe02
5 changed files with 57 additions and 64 deletions

View File

@@ -13,7 +13,7 @@ import 'package:flutter_tools/src/build_system/exceptions.dart';
import 'package:flutter_tools/src/globals.dart' as globals;
import '../../src/common.dart';
import '../../src/context.dart';
import '../../src/fake_process_manager.dart';
import '../../src/testbed.dart';
final Platform windowsPlatform = FakePlatform(

View File

@@ -16,7 +16,7 @@ import 'package:flutter_tools/src/build_system/targets/web.dart';
import 'package:flutter_tools/src/globals_null_migrated.dart' as globals;
import '../../../src/common.dart';
import '../../../src/context.dart';
import '../../../src/fake_process_manager.dart';
import '../../../src/testbed.dart';
const List<String> kDart2jsLinuxArgs = <String>[

View File

@@ -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:file/file.dart';
import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/bot_detector.dart';
@@ -288,7 +286,7 @@ void main() {
});
testWithoutContext('pub get 69', () async {
String error;
String? error;
const FakeCommand pubGetCommand = FakeCommand(
command: <String>[
@@ -429,7 +427,7 @@ void main() {
});
testWithoutContext('pub cache in root is used', () async {
String error;
String? error;
final FileSystem fileSystem = MemoryFileSystem.test();
final Directory pubCache = fileSystem.directory(Cache.flutterRoot).childDirectory('.pub-cache')..createSync();
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
@@ -503,7 +501,7 @@ void main() {
);
FakeAsync().run((FakeAsync time) {
String error;
String? error;
pub.get(context: PubContext.flutterTests).then((void value) {
error = 'test completed unexpectedly';
}, onError: (dynamic thrownError) {

View File

@@ -2,36 +2,33 @@
// 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:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/dart/pub.dart';
import 'package:meta/meta.dart';
class ThrowingPub implements Pub {
@override
Future<void> batch(List<String> arguments, {
PubContext context,
String directory,
MessageFilter filter,
String failureMessage = 'pub failed',
bool retry,
bool showTraceForErrors,
PubContext? context,
String? directory,
MessageFilter? filter,
String? failureMessage = 'pub failed',
bool? retry,
bool? showTraceForErrors,
}) {
throw UnsupportedError('Attempted to invoke pub during test.');
}
@override
Future<void> get({
PubContext context,
String directory,
PubContext? context,
String? directory,
bool skipIfAbsent = false,
bool upgrade = false,
bool offline = false,
bool checkLastModified = true,
bool skipPubspecYamlCheck = false,
bool generateSyntheticPackage = false,
String flutterRootOverride,
String? flutterRootOverride,
bool checkUpToDate = false,
}) {
throw UnsupportedError('Attempted to invoke pub during test.');
@@ -40,8 +37,8 @@ class ThrowingPub implements Pub {
@override
Future<void> interactively(
List<String> arguments, {
String directory,
@required Stdio stdio,
String? directory,
required Stdio stdio,
bool touchesPackageConfig = false,
bool generateSyntheticPackage = false,
}) {