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

@@ -8,7 +8,7 @@ import 'dart:typed_data';
import 'package:flutter/foundation.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart' show TestFailure;
import 'package:test/test.dart' as test_package show TestFailure;
/// Compares rasterized image bytes against a golden image file.
///
@@ -178,7 +178,7 @@ class LocalFileComparator implements GoldenFileComparator {
Future<bool> compare(Uint8List imageBytes, Uri golden) async {
final File goldenFile = _getFile(golden);
if (!goldenFile.existsSync()) {
throw new TestFailure('Could not be compared against non-existent file: "$golden"');
throw new test_package.TestFailure('Could not be compared against non-existent file: "$golden"');
}
final List<int> goldenBytes = await goldenFile.readAsBytes();
return _areListsEqual(imageBytes, goldenBytes);

View File

@@ -9,7 +9,7 @@ import 'dart:ui';
import 'package:meta/meta.dart';
import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
import 'package:test/test.dart' as test_package show isInstanceOf;
import 'package:test/test.dart' as test_package show TypeMatcher;
import 'package:test/src/frontend/async_matcher.dart'; // ignore: implementation_imports
import 'package:flutter/foundation.dart';
@@ -191,8 +191,8 @@ final Matcher isFlutterError = isInstanceOf<FlutterError>();
final Matcher isAssertionError = isInstanceOf<AssertionError>();
/// A matcher that compares the type of the actual value to the type argument T.
// TODO(ianh): https://github.com/flutter/flutter/issues/18608, https://github.com/dart-lang/matcher/pull/88
Matcher isInstanceOf<T>() => new test_package.isInstanceOf<T>(); // ignore: prefer_const_constructors, https://github.com/dart-lang/sdk/issues/32544
// 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
/// Asserts that two [double]s are equal, within some tolerated error.
///

View File

@@ -8,7 +8,7 @@ dependencies:
# We depend on very specific internal implementation details of the
# 'test' package, which change between versions, so when upgrading
# this, make sure the tests are still running correctly.
test: 0.12.41
test: 0.12.42
# Used by golden file comparator
path: 1.6.2
@@ -32,10 +32,10 @@ dependencies:
collection: 1.14.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
convert: 2.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
crypto: 2.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
csslib: 0.14.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
csslib: 0.14.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
front_end: 0.1.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
glob: 1.1.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
html: 0.13.3+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
html: 0.13.3+3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
http: 0.11.3+17 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
http_multi_server: 2.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
http_parser: 3.1.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
@@ -44,7 +44,7 @@ dependencies:
json_rpc_2: 2.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
kernel: 0.3.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
logging: 0.11.3+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
matcher: 0.12.2+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
matcher: 0.12.3+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
meta: 1.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
mime: 0.9.6+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
multi_server_socket: 1.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
@@ -62,7 +62,7 @@ dependencies:
source_maps: 0.10.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
source_span: 1.4.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
stream_channel: 1.6.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
string_scanner: 1.0.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
string_scanner: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
term_glyph: 1.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
typed_data: 1.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
utf: 0.9.0+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
@@ -72,8 +72,8 @@ dependencies:
yaml: 2.1.15 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
dev_dependencies:
file: 5.0.1
file: 5.0.4
intl: 0.15.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
# PUBSPEC CHECKSUM: d5b8
# PUBSPEC CHECKSUM: 0264

View File

@@ -7,10 +7,8 @@ import 'dart:io' as io;
import 'dart:typed_data';
import 'package:file/memory.dart';
import 'package:test/test.dart' as test_package;
import 'package:test/test.dart' hide test;
import 'package:flutter_test/flutter_test.dart' show goldenFileComparator, LocalFileComparator;
import 'package:flutter_test/flutter_test.dart' hide test;
import 'package:flutter_test/flutter_test.dart' as test_package;
const List<int> _kExpectedBytes = <int>[1, 2, 3];
@@ -59,7 +57,7 @@ void main() {
group('goldenFileComparator', () {
test('is initialized by test framework', () {
expect(goldenFileComparator, isNotNull);
expect(goldenFileComparator, const isInstanceOf<LocalFileComparator>());
expect(goldenFileComparator, isInstanceOf<LocalFileComparator>());
final LocalFileComparator comparator = goldenFileComparator;
expect(comparator.basedir.path, contains('flutter_test'));
});
@@ -133,7 +131,7 @@ void main() {
group('fails', () {
test('when golden file does not exist', () async {
final Future<bool> comparison = doComparison();
expect(comparison, throwsA(const isInstanceOf<TestFailure>()));
expect(comparison, throwsA(isInstanceOf<TestFailure>()));
});
test('when golden bytes are leading subset of image bytes', () async {