Revert "Clean up some flutter_tools tests and roll dependencies (#33163)" (#33206)

This commit is contained in:
Jonah Williams
2019-05-22 12:20:02 -07:00
committed by GitHub
parent a6f1c095dc
commit a30ffb60ad
46 changed files with 173 additions and 189 deletions

View File

@@ -263,7 +263,6 @@ bool exitsHappy(List<String> cli) {
try {
return processManager.runSync(cli).exitCode == 0;
} catch (error) {
printTrace('$cli failed with $error');
return false;
}
}
@@ -273,7 +272,6 @@ Future<bool> exitsHappyAsync(List<String> cli) async {
try {
return (await processManager.run(cli)).exitCode == 0;
} catch (error) {
printTrace('$cli failed with $error');
return false;
}
}

View File

@@ -7,6 +7,7 @@ import 'package:json_rpc_2/json_rpc_2.dart' as rpc;
import 'package:meta/meta.dart';
import 'asset.dart';
import 'base/common.dart';
import 'base/context.dart';
import 'base/file_system.dart';
import 'base/io.dart';
@@ -45,7 +46,7 @@ abstract class DevFSContent {
Stream<List<int>> contentsAsStream();
Stream<List<int>> contentsAsCompressedStream() {
return contentsAsStream().cast<List<int>>().transform<List<int>>(gzip.encoder);
return contentsAsStream().transform<List<int>>(gzip.encoder);
}
/// Return the list of files this content depends on.
@@ -267,6 +268,7 @@ class _DevFSHttpWriter {
final Uri httpAddress;
static const int kMaxInFlight = 6;
static const int kMaxRetries = 3;
int _inFlight = 0;
Map<Uri, DevFSContent> _outstanding;
@@ -282,17 +284,19 @@ class _DevFSHttpWriter {
}
void _scheduleWrites() {
while ((_inFlight < kMaxInFlight) && (!_completer.isCompleted) && _outstanding.isNotEmpty) {
while (_inFlight < kMaxInFlight) {
if (_outstanding.isEmpty) {
// Finished.
break;
}
final Uri deviceUri = _outstanding.keys.first;
final DevFSContent content = _outstanding.remove(deviceUri);
_startWrite(deviceUri, content);
_inFlight += 1;
_scheduleWrite(deviceUri, content);
_inFlight++;
}
if ((_inFlight == 0) && (!_completer.isCompleted) && _outstanding.isEmpty)
_completer.complete();
}
Future<void> _startWrite(
Future<void> _scheduleWrite(
Uri deviceUri,
DevFSContent content, [
int retry = 0,
@@ -301,19 +305,33 @@ class _DevFSHttpWriter {
final HttpClientRequest request = await _client.putUrl(httpAddress);
request.headers.removeAll(HttpHeaders.acceptEncodingHeader);
request.headers.add('dev_fs_name', fsName);
request.headers.add('dev_fs_uri_b64', base64.encode(utf8.encode('$deviceUri')));
request.headers.add('dev_fs_uri_b64',
base64.encode(utf8.encode(deviceUri.toString())));
final Stream<List<int>> contents = content.contentsAsCompressedStream();
await request.addStream(contents);
final HttpClientResponse response = await request.close();
await response.drain<void>();
} catch (error, trace) {
if (!_completer.isCompleted) {
printTrace('Error writing "$deviceUri" to DevFS: $error');
_completer.completeError(error, trace);
} on SocketException catch (socketException, stackTrace) {
// We have one completer and can get up to kMaxInFlight errors.
if (!_completer.isCompleted)
_completer.completeError(socketException, stackTrace);
return;
} catch (e) {
if (retry < kMaxRetries) {
printTrace('Retrying writing "$deviceUri" to DevFS due to error: $e');
// Synchronization is handled by the _completer below.
unawaited(_scheduleWrite(deviceUri, content, retry + 1));
return;
} else {
printError('Error writing "$deviceUri" to DevFS: $e');
}
}
_inFlight -= 1;
_scheduleWrites();
_inFlight--;
if ((_outstanding.isEmpty) && (_inFlight == 0)) {
_completer.complete();
} else {
_scheduleWrites();
}
}
}

View File

@@ -9,17 +9,17 @@ environment:
dependencies:
# To update these, use "flutter update-packages --force-upgrade".
archive: 2.0.9
archive: 2.0.8
args: 1.5.1
bsdiff: 0.1.0
completion: 0.2.1+1
coverage: 0.12.4
crypto: 2.0.6
file: 5.0.8
file: 5.0.7
http: 0.12.0+2
intl: 0.15.8
json_rpc_2: 2.1.0
linter: 0.1.90
linter: 0.1.87
meta: 1.1.6
multicast_dns: 0.1.1
mustache: 1.1.1
@@ -33,7 +33,7 @@ dependencies:
usage: 3.4.1
vm_service_client: 0.2.6+2
web_socket_channel: 1.0.12
xml: 3.5.0
xml: 3.4.1
yaml: 2.1.15
flutter_goldens_client:
path: ../flutter_goldens_client
@@ -45,20 +45,20 @@ dependencies:
test_core: 0.2.5
# Code generation dependencies
build_runner_core: 3.0.5
build_runner_core: 3.0.4
dart_style: 1.2.7
code_builder: 3.2.0
build: 1.1.4
build_modules: 2.1.3
build_daemon: 0.6.1
build_modules: 2.1.2
build_daemon: 0.6.0
analyzer: 0.36.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
async: 2.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
bazel_worker: 0.1.21 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
bazel_worker: 0.1.20 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
boolean_selector: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
build_config: 0.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
build_resolvers: 1.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
built_collection: 4.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
build_resolvers: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
built_collection: 4.2.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
built_value: 6.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
@@ -68,17 +68,16 @@ dependencies:
glob: 1.1.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
graphs: 0.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
html: 0.14.0+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
http_multi_server: 2.0.6 # 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"
io: 0.3.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
json_annotation: 2.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
json_annotation: 2.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
kernel: 0.3.18 # 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.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
package_resolver: 1.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
path: 1.6.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
pedantic: 1.7.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
petitparser: 2.3.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
pedantic: 1.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
petitparser: 2.2.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
pool: 1.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
protobuf: 0.13.11 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
pub_semver: 1.4.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
@@ -104,8 +103,9 @@ dev_dependencies:
test: 1.6.3
build_runner: 1.4.0
build_vm_compilers: 1.0.0
build_test: 0.10.7+3
build_test: 0.10.7+2
http_multi_server: 2.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
js: 0.6.1+1 # 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"
@@ -117,4 +117,4 @@ dartdoc:
# Exclude this package from the hosted API docs.
nodoc: true
# PUBSPEC CHECKSUM: 087a
# PUBSPEC CHECKSUM: 9773

View File

@@ -171,7 +171,6 @@ void main() {
FileSystem: () => MemoryFileSystem(),
IOSWorkflow: () => MockIosWorkFlow(),
Platform: _kNoColorTerminalPlatform,
OperatingSystemUtils: () => MockOperatingSystemUtils(),
};
testUsingContext('Error on non-existing file', () {
final PrebuiltIOSApp iosApp =
@@ -494,5 +493,3 @@ const String badPlistData = '''
const String plistData = '''
{"CFBundleIdentifier": "fooBundleId"}
''';
class MockOperatingSystemUtils extends Mock implements OperatingSystemUtils { }

View File

@@ -95,7 +95,7 @@ void main() {
}
for (String testOs in testPlatforms) {
testUsingContext('AnsiSpinner works for $testOs (1)', () async {
testUsingContext('AnsiSpinner works for $testOs', () async {
bool done = false;
FakeAsync().run((FakeAsync time) {
final AnsiSpinner ansiSpinner = AnsiSpinner(
@@ -131,18 +131,21 @@ void main() {
Stdio: () => mockStdio,
});
testUsingContext('AnsiSpinner works for $testOs (2)', () async {
testUsingContext('AnsiSpinner works for $testOs', () async {
bool done = false;
mockStopwatch = FakeStopwatch();
FakeAsync().run((FakeAsync time) {
// We pad the time here so that we have a little slack in terms of the first part of this test
// taking longer to run than we'd like, since we are forced to start the timer before the actual
// stopwatch that we're trying to test. This is an unfortunate possible race condition. If this
// turns out to be flaky, we will need to find another solution.
final Future<void> tenMillisecondsLater = Future<void>.delayed(const Duration(milliseconds: 15));
await FakeAsync().run((FakeAsync time) async {
final AnsiSpinner ansiSpinner = AnsiSpinner(
timeout: const Duration(seconds: 2),
timeout: const Duration(milliseconds: 10),
)..start();
mockStopwatch.elapsed = const Duration(seconds: 1);
doWhileAsync(time, () => ansiSpinner.ticks < 10); // one second
expect(ansiSpinner.seemsSlow, isFalse);
expect(outputStdout().join('\n'), isNot(contains('This is taking an unexpectedly long time.')));
mockStopwatch.elapsed = const Duration(seconds: 3);
await tenMillisecondsLater;
doWhileAsync(time, () => ansiSpinner.ticks < 30); // three seconds
expect(ansiSpinner.seemsSlow, isTrue);
// Check the 2nd line to verify there's a newline before the warning
@@ -155,7 +158,6 @@ void main() {
}, overrides: <Type, Generator>{
Platform: () => FakePlatform(operatingSystem: testOs),
Stdio: () => mockStdio,
Stopwatch: () => mockStopwatch,
});
testUsingContext('Stdout startProgress on colored terminal for $testOs', () async {

View File

@@ -26,10 +26,6 @@ void main() {
await tools.main(<String>['devices', '--bug-report']);
expect(exitCode, 0);
verify(os.zip(any, argThat(hasPath(matches(r'bugreport_01\.zip')))));
}, overrides: <Type, Generator>{
OperatingSystemUtils: () => MockOperatingSystemUtils(),
});
});
}
class MockOperatingSystemUtils extends Mock implements OperatingSystemUtils { }

View File

@@ -7,8 +7,8 @@ import 'dart:convert';
import 'package:file/file.dart';
import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/devfs.dart';
import 'package:flutter_tools/src/vmservice.dart';
import 'package:json_rpc_2/json_rpc_2.dart' as rpc;

View File

@@ -386,16 +386,16 @@ abstract class FlutterTestDriver {
final Future<T> future = callback();
future.timeout(timeout ?? defaultTimeout, onTimeout: () {
_debugPrint(messages.toString());
print(messages.toString());
timeoutExpired = true;
_debugPrint('$task is taking longer than usual...');
print('$task is taking longer than usual...');
return null;
});
return future.catchError((dynamic error) {
if (!timeoutExpired) {
timeoutExpired = true;
_debugPrint(messages.toString());
print(messages.toString());
}
throw error;
}).whenComplete(() => subscription.cancel());

View File

@@ -222,42 +222,15 @@ class MockSimControl extends Mock implements SimControl {
}
}
class MockOperatingSystemUtils implements OperatingSystemUtils {
@override
ProcessResult makeExecutable(File file) => null;
@override
File which(String execName) => null;
class MockOperatingSystemUtils extends Mock implements OperatingSystemUtils {
@override
List<File> whichAll(String execName) => <File>[];
@override
File makePipe(String path) => null;
@override
void zip(Directory data, File zipFile) { }
@override
void unzip(File file, Directory targetDirectory) { }
@override
bool verifyZip(File file) => true;
@override
void unpack(File gzippedTarFile, Directory targetDirectory) { }
@override
bool verifyGzip(File gzippedFile) => true;
@override
String get name => 'fake OS name and version';
@override
String get pathVarSeparator => ';';
@override
Future<int> findFreePort({bool ipv6 = false}) async => 12345;
}
class MockIOSSimulatorUtils extends Mock implements IOSSimulatorUtils {}