Shim package:test to avoid matcher issues (#20602)

* Upgrade everything except matcher.
* Roll matcher (and test)
* Adjust tests that depend on flutter:test directly to depend on a shim
* Require use of package:test shim and remove other references to package:test
This commit is contained in:
Ian Hickson
2018-08-14 20:33:58 -07:00
committed by Todd Volkert
parent 8de0e15e4f
commit 686d8f8a22
258 changed files with 629 additions and 468 deletions

View File

@@ -5,7 +5,8 @@
import 'dart:async';
import 'package:args/command_runner.dart';
import 'package:test/test.dart';
import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
import 'package:test/test.dart' as test_package show TypeMatcher;
import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/file_system.dart';
@@ -15,6 +16,12 @@ import 'package:flutter_tools/src/commands/create.dart';
import 'package:flutter_tools/src/runner/flutter_command.dart';
import 'package:flutter_tools/src/runner/flutter_command_runner.dart';
export 'package:test/test.dart' hide TypeMatcher, isInstanceOf; // Defines a 'package:test' shim.
/// A matcher that compares the type of the actual value to the type argument T.
// TODO(ianh): Remove this once https://github.com/dart-lang/matcher/issues/98 is fixed
Matcher isInstanceOf<T>() => new test_package.TypeMatcher<T>(); // ignore: prefer_const_constructors, https://github.com/dart-lang/sdk/issues/32544
/// Gets the path to the root of the Flutter repository.
///
/// This will first look for a `FLUTTER_ROOT` environment variable. If the
@@ -76,7 +83,7 @@ Matcher throwsToolExit({int exitCode, String message}) {
}
/// Matcher for [ToolExit]s.
const Matcher isToolExit = isInstanceOf<ToolExit>();
final Matcher isToolExit = isInstanceOf<ToolExit>();
/// Matcher for functions that throw [ProcessExit].
Matcher throwsProcessExit([dynamic exitCode]) {
@@ -86,7 +93,7 @@ Matcher throwsProcessExit([dynamic exitCode]) {
}
/// Matcher for [ProcessExit]s.
const Matcher isProcessExit = isInstanceOf<ProcessExit>();
final Matcher isProcessExit = isInstanceOf<ProcessExit>();
/// Creates a flutter project in the [temp] directory using the
/// [arguments] list if specified, or `--no-pub` if not.

View File

@@ -23,7 +23,6 @@ import 'package:flutter_tools/src/version.dart';
import 'package:meta/meta.dart';
import 'package:mockito/mockito.dart';
import 'package:quiver/time.dart';
import 'package:test/test.dart';
import 'common.dart';

View File

@@ -19,7 +19,8 @@ import 'package:flutter_tools/src/ios/simulators.dart';
import 'package:flutter_tools/src/runner/flutter_command.dart';
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
import 'package:test/test.dart';
import 'common.dart';
class MockApplicationPackageStore extends ApplicationPackageStore {
MockApplicationPackageStore() : super(