Unnecessary new (#20138)
* enable lint unnecessary_new * fix tests * fix tests * fix tests
This commit is contained in:
committed by
GitHub
parent
d7a0dcaa4a
commit
d927c93310
@@ -69,7 +69,7 @@ Future<Null> main(List<String> rawArgs) async {
|
||||
}
|
||||
|
||||
/// Command-line options for the `run.dart` command.
|
||||
final ArgParser _argParser = new ArgParser()
|
||||
final ArgParser _argParser = ArgParser()
|
||||
..addMultiOption(
|
||||
'task',
|
||||
abbr: 't',
|
||||
@@ -89,7 +89,7 @@ final ArgParser _argParser = new ArgParser()
|
||||
_taskNames.add(nameOrPath);
|
||||
} else if (!isDartFile || fragments.length != 3 || !_listsEqual(<String>['bin', 'tasks'], fragments.take(2).toList())) {
|
||||
// Unsupported executable location
|
||||
throw new FormatException('Invalid value for option -t (--task): $nameOrPath');
|
||||
throw FormatException('Invalid value for option -t (--task): $nameOrPath');
|
||||
} else {
|
||||
_taskNames.add(path.withoutExtension(fragments.last));
|
||||
}
|
||||
|
||||
@@ -21,14 +21,14 @@ void main() {
|
||||
await device.unlock();
|
||||
final Directory appDir = dir(path.join(flutterDirectory.path, 'dev/integration_tests/ui'));
|
||||
await inDirectory(appDir, () async {
|
||||
final Completer<Null> ready = new Completer<Null>();
|
||||
final Completer<Null> ready = Completer<Null>();
|
||||
bool ok;
|
||||
print('run: starting...');
|
||||
final Process run = await startProcess(
|
||||
path.join(flutterDirectory.path, 'bin', 'flutter'),
|
||||
<String>['run', '--verbose', '-d', device.deviceId, 'lib/commands.dart'],
|
||||
);
|
||||
final StreamController<String> stdout = new StreamController<String>.broadcast();
|
||||
final StreamController<String> stdout = StreamController<String>.broadcast();
|
||||
run.stdout
|
||||
.transform(utf8.decoder)
|
||||
.transform(const LineSplitter())
|
||||
@@ -56,9 +56,9 @@ void main() {
|
||||
if (!ok)
|
||||
throw 'Failed to run test app.';
|
||||
|
||||
final VMServiceClient client = new VMServiceClient.connect('ws://localhost:$vmServicePort/ws');
|
||||
final VMServiceClient client = VMServiceClient.connect('ws://localhost:$vmServicePort/ws');
|
||||
|
||||
final DriveHelper driver = new DriveHelper(vmServicePort);
|
||||
final DriveHelper driver = DriveHelper(vmServicePort);
|
||||
|
||||
await driver.drive('none');
|
||||
print('test: pressing "p" to enable debugPaintSize...');
|
||||
@@ -98,7 +98,7 @@ void main() {
|
||||
print('test: validating that the app has in fact closed...');
|
||||
await client.done.timeout(const Duration(seconds: 5));
|
||||
});
|
||||
return new TaskResult.success(null);
|
||||
return TaskResult.success(null);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import 'package:flutter_devicelab/tasks/perf_tests.dart';
|
||||
|
||||
Future<Null> main() async {
|
||||
deviceOperatingSystem = DeviceOperatingSystem.android;
|
||||
await task(new MemoryTest(
|
||||
await task(MemoryTest(
|
||||
'${flutterDirectory.path}/dev/benchmarks/complex_layout',
|
||||
'test_memory/scroll_perf.dart',
|
||||
'com.yourcompany.complexLayout',
|
||||
|
||||
@@ -31,7 +31,7 @@ void main() {
|
||||
});
|
||||
|
||||
final String dataPath = p.join(complexLayoutPath, 'build', 'complex_layout_semantics_perf.json');
|
||||
return new TaskResult.successFromFile(file(dataPath), benchmarkScoreKeys: <String>[
|
||||
return TaskResult.successFromFile(file(dataPath), benchmarkScoreKeys: <String>[
|
||||
'initialSemanticsTreeCreation',
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -12,7 +12,7 @@ import 'package:path/path.dart' as path;
|
||||
|
||||
Future<Null> main() async {
|
||||
await task(() async {
|
||||
final Stopwatch clock = new Stopwatch()..start();
|
||||
final Stopwatch clock = Stopwatch()..start();
|
||||
final Process analysis = await startProcess(
|
||||
path.join(flutterDirectory.path, 'bin', 'flutter'),
|
||||
<String>['analyze', '--no-preamble', '--no-congratulate', '--flutter-repo', '--dartdocs'],
|
||||
@@ -47,16 +47,16 @@ Future<Null> main() async {
|
||||
final int result = await analysis.exitCode;
|
||||
clock.stop();
|
||||
if (publicMembers == 0 && otherErrors == 0 && result != 0)
|
||||
throw new Exception('flutter analyze exited with unexpected error code $result');
|
||||
throw Exception('flutter analyze exited with unexpected error code $result');
|
||||
if (publicMembers != 0 && otherErrors != 0 && result == 0)
|
||||
throw new Exception('flutter analyze exited with successful status code despite reporting errors');
|
||||
throw Exception('flutter analyze exited with successful status code despite reporting errors');
|
||||
if (otherLines != 0)
|
||||
throw new Exception('flutter analyze had unexpected output (we saw $otherLines unexpected line${ otherLines == 1 ? "" : "s" })');
|
||||
throw Exception('flutter analyze had unexpected output (we saw $otherLines unexpected line${ otherLines == 1 ? "" : "s" })');
|
||||
final Map<String, dynamic> data = <String, dynamic>{
|
||||
'members_missing_dartdocs': publicMembers,
|
||||
'analysis_errors': otherErrors,
|
||||
'elapsed_time_ms': clock.elapsedMilliseconds,
|
||||
};
|
||||
return new TaskResult.success(data, benchmarkScoreKeys: data.keys.toList());
|
||||
return TaskResult.success(data, benchmarkScoreKeys: data.keys.toList());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -13,11 +13,11 @@ import 'package:flutter_devicelab/framework/utils.dart';
|
||||
|
||||
Future<void> testReload(Process process, { Future<void> Function() onListening }) async {
|
||||
section('Testing hot reload, restart and quit');
|
||||
final Completer<Null> listening = new Completer<Null>();
|
||||
final Completer<Null> ready = new Completer<Null>();
|
||||
final Completer<Null> reloaded = new Completer<Null>();
|
||||
final Completer<Null> restarted = new Completer<Null>();
|
||||
final Completer<Null> finished = new Completer<Null>();
|
||||
final Completer<Null> listening = Completer<Null>();
|
||||
final Completer<Null> ready = Completer<Null>();
|
||||
final Completer<Null> reloaded = Completer<Null>();
|
||||
final Completer<Null> restarted = Completer<Null>();
|
||||
final Completer<Null> finished = Completer<Null>();
|
||||
final List<String> stdout = <String>[];
|
||||
final List<String> stderr = <String>[];
|
||||
|
||||
@@ -96,7 +96,7 @@ void main() {
|
||||
<String>['--suppress-analytics', 'build', 'apk', '--debug', 'lib/main.dart'],
|
||||
);
|
||||
final String lastLine = buildStdout.split('\n').last;
|
||||
final RegExp builtRegExp = new RegExp(r'Built (.+)( \(|\.$)');
|
||||
final RegExp builtRegExp = RegExp(r'Built (.+)( \(|\.$)');
|
||||
final String apkPath = builtRegExp.firstMatch(lastLine)[1];
|
||||
|
||||
section('Installing $apkPath');
|
||||
@@ -116,7 +116,7 @@ void main() {
|
||||
});
|
||||
|
||||
// Give the device the time to really shut down the app.
|
||||
await new Future<Null>.delayed(const Duration(milliseconds: 200));
|
||||
await Future<Null>.delayed(const Duration(milliseconds: 200));
|
||||
// After the delay, force-stopping it shouldn't do anything, but doesn't hurt.
|
||||
await device.shellExec('am', <String>['force-stop', kAppId]);
|
||||
|
||||
@@ -128,7 +128,7 @@ void main() {
|
||||
// If the next line fails, your device may not support regexp search.
|
||||
final String observatoryLine = await device.adb(<String>['logcat', '-e', 'Observatory listening on http:', '-m', '1', '-T', currentTime]);
|
||||
print('Found observatory line: $observatoryLine');
|
||||
final String observatoryPort = new RegExp(r'Observatory listening on http://.*:([0-9]+)').firstMatch(observatoryLine)[1];
|
||||
final String observatoryPort = RegExp(r'Observatory listening on http://.*:([0-9]+)').firstMatch(observatoryLine)[1];
|
||||
print('Extracted observatory port: $observatoryPort');
|
||||
|
||||
section('Launching attach with given port');
|
||||
@@ -144,6 +144,6 @@ void main() {
|
||||
await device.adb(<String>['uninstall', kAppId]);
|
||||
}
|
||||
});
|
||||
return new TaskResult.success(null);
|
||||
return TaskResult.success(null);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ class BackButtonMemoryTest extends MemoryTest {
|
||||
await receivedNextMessage;
|
||||
|
||||
// Give Android time to settle (e.g. run GCs) after closing the app.
|
||||
await new Future<Null>.delayed(const Duration(milliseconds: 100));
|
||||
await Future<Null>.delayed(const Duration(milliseconds: 100));
|
||||
|
||||
// Relaunch the app, wait for it to launch.
|
||||
prepareForNextMessage('READY');
|
||||
@@ -46,7 +46,7 @@ class BackButtonMemoryTest extends MemoryTest {
|
||||
await receivedNextMessage;
|
||||
|
||||
// Wait for the Flutter app to settle (e.g. run GCs).
|
||||
await new Future<Null>.delayed(const Duration(milliseconds: 100));
|
||||
await Future<Null>.delayed(const Duration(milliseconds: 100));
|
||||
}
|
||||
await recordEnd();
|
||||
}
|
||||
@@ -54,5 +54,5 @@ class BackButtonMemoryTest extends MemoryTest {
|
||||
|
||||
Future<Null> main() async {
|
||||
deviceOperatingSystem = DeviceOperatingSystem.android;
|
||||
await task(new BackButtonMemoryTest().run);
|
||||
await task(BackButtonMemoryTest().run);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import 'package:flutter_devicelab/framework/utils.dart';
|
||||
import 'package:flutter_devicelab/tasks/perf_tests.dart';
|
||||
|
||||
Future<Null> main() async {
|
||||
await task(new MemoryTest(
|
||||
await task(MemoryTest(
|
||||
'${flutterDirectory.path}/examples/flutter_gallery',
|
||||
'test_memory/memory_nav.dart',
|
||||
'io.flutter.demo.gallery',
|
||||
|
||||
@@ -24,6 +24,6 @@ Future<Null> main() async {
|
||||
benchmarkScoreKeys.add(deltaKey);
|
||||
}
|
||||
|
||||
return new TaskResult.success(data, benchmarkScoreKeys: benchmarkScoreKeys);
|
||||
return TaskResult.success(data, benchmarkScoreKeys: benchmarkScoreKeys);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -30,6 +30,6 @@ Future<Null> main() async {
|
||||
});
|
||||
});
|
||||
|
||||
return new TaskResult.success(null);
|
||||
return TaskResult.success(null);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import 'package:flutter_devicelab/framework/framework.dart';
|
||||
import 'package:flutter_devicelab/framework/utils.dart';
|
||||
|
||||
// Matches the output of the "test" package, e.g.: "00:01 +1 loading foo"
|
||||
final RegExp testOutputPattern = new RegExp(r'^[0-9][0-9]:[0-9][0-9] \+[0-9]+: (.+?) *$');
|
||||
final RegExp testOutputPattern = RegExp(r'^[0-9][0-9]:[0-9][0-9] \+[0-9]+: (.+?) *$');
|
||||
|
||||
enum TestStep {
|
||||
starting,
|
||||
@@ -37,7 +37,7 @@ enum TestStep {
|
||||
}
|
||||
|
||||
Future<int> runTest() async {
|
||||
final Stopwatch clock = new Stopwatch()..start();
|
||||
final Stopwatch clock = Stopwatch()..start();
|
||||
final Process analysis = await startProcess(
|
||||
path.join(flutterDirectory.path, 'bin', 'flutter'),
|
||||
<String>['test', path.join('flutter_test', 'trivial_widget_test.dart')],
|
||||
@@ -83,18 +83,18 @@ Future<int> runTest() async {
|
||||
final int result = await analysis.exitCode;
|
||||
clock.stop();
|
||||
if (result != 0)
|
||||
throw new Exception('flutter test failed with exit code $result');
|
||||
throw Exception('flutter test failed with exit code $result');
|
||||
if (badLines > 0)
|
||||
throw new Exception('flutter test renderered unexpected output ($badLines bad lines)');
|
||||
throw Exception('flutter test renderered unexpected output ($badLines bad lines)');
|
||||
if (step != TestStep.testPassed)
|
||||
throw new Exception('flutter test did not finish (only reached step $step)');
|
||||
throw Exception('flutter test did not finish (only reached step $step)');
|
||||
print('elapsed time: ${clock.elapsedMilliseconds}ms');
|
||||
return clock.elapsedMilliseconds;
|
||||
}
|
||||
|
||||
void main() {
|
||||
task(() async {
|
||||
final File nodeSourceFile = new File(path.join(
|
||||
final File nodeSourceFile = File(path.join(
|
||||
flutterDirectory.path, 'packages', 'flutter', 'lib', 'src', 'foundation', 'node.dart',
|
||||
));
|
||||
final String originalSource = await nodeSourceFile.readAsString();
|
||||
@@ -118,7 +118,7 @@ void main() {
|
||||
'implementation_change_elapsed_time_ms': implementationChange,
|
||||
'interface_change_elapsed_time_ms': interfaceChange,
|
||||
};
|
||||
return new TaskResult.success(data, benchmarkScoreKeys: data.keys.toList());
|
||||
return TaskResult.success(data, benchmarkScoreKeys: data.keys.toList());
|
||||
} finally {
|
||||
await nodeSourceFile.writeAsString(originalSource);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ Future<void> main() async {
|
||||
|
||||
javaHome = await findJavaHome();
|
||||
if (javaHome == null)
|
||||
return new TaskResult.failure('Could not find Java');
|
||||
return TaskResult.failure('Could not find Java');
|
||||
print('\nUsing JAVA_HOME=$javaHome');
|
||||
|
||||
try {
|
||||
@@ -51,7 +51,7 @@ Future<void> main() async {
|
||||
await project.runGradleTask('assembleDebug');
|
||||
errorMessage = _validateSnapshotDependency(project, 'build/app.dill');
|
||||
if (errorMessage != null) {
|
||||
throw new TaskResult.failure(errorMessage);
|
||||
throw TaskResult.failure(errorMessage);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -125,15 +125,15 @@ Future<void> main() async {
|
||||
section('gradlew assembleDebug on plugin example');
|
||||
await pluginProject.runGradleTask('assembleDebug');
|
||||
if (!pluginProject.hasDebugApk)
|
||||
throw new TaskResult.failure(
|
||||
throw TaskResult.failure(
|
||||
'Gradle did not produce an apk file at the expected place');
|
||||
});
|
||||
|
||||
return new TaskResult.success(null);
|
||||
return TaskResult.success(null);
|
||||
} on TaskResult catch (taskResult) {
|
||||
return taskResult;
|
||||
} catch (e) {
|
||||
return new TaskResult.failure(e.toString());
|
||||
return TaskResult.failure(e.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -143,7 +143,7 @@ TaskResult _failure(String message, ProcessResult result) {
|
||||
print('Exit code: ${result.exitCode}');
|
||||
print('Std out :\n${result.stdout}');
|
||||
print('Std err :\n${result.stderr}');
|
||||
return new TaskResult.failure(message);
|
||||
return TaskResult.failure(message);
|
||||
}
|
||||
|
||||
bool _hasMultipleOccurrences(String text, Pattern pattern) {
|
||||
@@ -160,14 +160,14 @@ class FlutterProject {
|
||||
await inDirectory(directory, () async {
|
||||
await flutter('create', options: <String>[name]);
|
||||
});
|
||||
return new FlutterProject(directory, name);
|
||||
return FlutterProject(directory, name);
|
||||
}
|
||||
|
||||
String get rootPath => path.join(parent.path, name);
|
||||
String get androidPath => path.join(rootPath, 'android');
|
||||
|
||||
Future<Null> addCustomBuildType(String name, {String initWith}) async {
|
||||
final File buildScript = new File(
|
||||
final File buildScript = File(
|
||||
path.join(androidPath, 'app', 'build.gradle'),
|
||||
);
|
||||
|
||||
@@ -184,7 +184,7 @@ android {
|
||||
}
|
||||
|
||||
Future<Null> addProductFlavor(String name) async {
|
||||
final File buildScript = new File(
|
||||
final File buildScript = File(
|
||||
path.join(androidPath, 'app', 'build.gradle'),
|
||||
);
|
||||
|
||||
@@ -203,7 +203,7 @@ android {
|
||||
}
|
||||
|
||||
Future<Null> introduceError() async {
|
||||
final File buildScript = new File(
|
||||
final File buildScript = File(
|
||||
path.join(androidPath, 'app', 'build.gradle'),
|
||||
);
|
||||
await buildScript.writeAsString((await buildScript.readAsString()).replaceAll('buildTypes', 'builTypes'));
|
||||
@@ -236,7 +236,7 @@ class FlutterPluginProject {
|
||||
await inDirectory(directory, () async {
|
||||
await flutter('create', options: <String>['-t', 'plugin', name]);
|
||||
});
|
||||
return new FlutterPluginProject(directory, name);
|
||||
return FlutterPluginProject(directory, name);
|
||||
}
|
||||
|
||||
String get rootPath => path.join(parent.path, name);
|
||||
@@ -248,7 +248,7 @@ class FlutterPluginProject {
|
||||
return _runGradleTask(workingDirectory: exampleAndroidPath, task: task, options: options);
|
||||
}
|
||||
|
||||
bool get hasDebugApk => new File(debugApkPath).existsSync();
|
||||
bool get hasDebugApk => File(debugApkPath).existsSync();
|
||||
}
|
||||
|
||||
Future<Null> _runGradleTask({String workingDirectory, String task, List<String> options}) async {
|
||||
@@ -284,12 +284,12 @@ class _Dependencies {
|
||||
String target;
|
||||
Set<String> dependencies;
|
||||
_Dependencies(String depfilePath) {
|
||||
final RegExp _separatorExpr = new RegExp(r'([^\\]) ');
|
||||
final RegExp _escapeExpr = new RegExp(r'\\(.)');
|
||||
final RegExp _separatorExpr = RegExp(r'([^\\]) ');
|
||||
final RegExp _escapeExpr = RegExp(r'\\(.)');
|
||||
|
||||
// Depfile format:
|
||||
// outfile1 outfile2 : file1.dart file2.dart file3.dart file\ 4.dart
|
||||
final String contents = new File(depfilePath).readAsStringSync();
|
||||
final String contents = File(depfilePath).readAsStringSync();
|
||||
final List<String> colonSeparated = contents.split(': ');
|
||||
target = colonSeparated[0].trim();
|
||||
dependencies = colonSeparated[1]
|
||||
@@ -305,7 +305,7 @@ class _Dependencies {
|
||||
|
||||
/// Returns [null] if target matches [expectedTarget], otherwise returns an error message.
|
||||
String _validateSnapshotDependency(FlutterProject project, String expectedTarget) {
|
||||
final _Dependencies deps = new _Dependencies(
|
||||
final _Dependencies deps = _Dependencies(
|
||||
path.join(project.rootPath, 'build', 'app', 'intermediates',
|
||||
'flutter', 'debug', 'snapshot_blob.bin.d'));
|
||||
return deps.target == expectedTarget ? null :
|
||||
|
||||
@@ -27,13 +27,13 @@ class HelloWorldMemoryTest extends MemoryTest {
|
||||
'-d', device.deviceId,
|
||||
test,
|
||||
]);
|
||||
await new Future<Null>.delayed(const Duration(milliseconds: 1500));
|
||||
await Future<Null>.delayed(const Duration(milliseconds: 1500));
|
||||
await recordStart();
|
||||
await new Future<Null>.delayed(const Duration(milliseconds: 3000));
|
||||
await Future<Null>.delayed(const Duration(milliseconds: 3000));
|
||||
await recordEnd();
|
||||
}
|
||||
}
|
||||
|
||||
Future<Null> main() async {
|
||||
await task(new HelloWorldMemoryTest().run);
|
||||
await task(HelloWorldMemoryTest().run);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ Future<Null> main() async {
|
||||
|
||||
final String javaHome = await findJavaHome();
|
||||
if (javaHome == null)
|
||||
return new TaskResult.failure('Could not find Java');
|
||||
return TaskResult.failure('Could not find Java');
|
||||
print('\nUsing JAVA_HOME=$javaHome');
|
||||
|
||||
section('Create Flutter module project');
|
||||
@@ -34,14 +34,14 @@ Future<Null> main() async {
|
||||
|
||||
section('Add plugins');
|
||||
|
||||
final File pubspec = new File(path.join(tempDir.path, 'hello', 'pubspec.yaml'));
|
||||
final File pubspec = File(path.join(tempDir.path, 'hello', 'pubspec.yaml'));
|
||||
String content = await pubspec.readAsString();
|
||||
content = content.replaceFirst(
|
||||
'\ndependencies:\n',
|
||||
'\ndependencies:\n battery:\n package_info:\n',
|
||||
);
|
||||
await pubspec.writeAsString(content, flush: true);
|
||||
await inDirectory(new Directory(path.join(tempDir.path, 'hello')), () async {
|
||||
await inDirectory(Directory(path.join(tempDir.path, 'hello')), () async {
|
||||
await flutter(
|
||||
'packages',
|
||||
options: <String>['get'],
|
||||
@@ -50,7 +50,7 @@ Future<Null> main() async {
|
||||
|
||||
section('Build Flutter module library archive');
|
||||
|
||||
await inDirectory(new Directory(path.join(tempDir.path, 'hello', '.android')), () async {
|
||||
await inDirectory(Directory(path.join(tempDir.path, 'hello', '.android')), () async {
|
||||
await exec(
|
||||
'./gradlew',
|
||||
<String>['flutter:assembleDebug'],
|
||||
@@ -58,7 +58,7 @@ Future<Null> main() async {
|
||||
);
|
||||
});
|
||||
|
||||
final bool aarBuilt = exists(new File(path.join(
|
||||
final bool aarBuilt = exists(File(path.join(
|
||||
tempDir.path,
|
||||
'hello',
|
||||
'.android',
|
||||
@@ -70,19 +70,19 @@ Future<Null> main() async {
|
||||
)));
|
||||
|
||||
if (!aarBuilt) {
|
||||
return new TaskResult.failure('Failed to build .aar');
|
||||
return TaskResult.failure('Failed to build .aar');
|
||||
}
|
||||
|
||||
section('Build ephemeral host app');
|
||||
|
||||
await inDirectory(new Directory(path.join(tempDir.path, 'hello')), () async {
|
||||
await inDirectory(Directory(path.join(tempDir.path, 'hello')), () async {
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>['apk'],
|
||||
);
|
||||
});
|
||||
|
||||
final bool ephemeralHostApkBuilt = exists(new File(path.join(
|
||||
final bool ephemeralHostApkBuilt = exists(File(path.join(
|
||||
tempDir.path,
|
||||
'hello',
|
||||
'build',
|
||||
@@ -94,18 +94,18 @@ Future<Null> main() async {
|
||||
)));
|
||||
|
||||
if (!ephemeralHostApkBuilt) {
|
||||
return new TaskResult.failure('Failed to build ephemeral host .apk');
|
||||
return TaskResult.failure('Failed to build ephemeral host .apk');
|
||||
}
|
||||
|
||||
section('Clean build');
|
||||
|
||||
await inDirectory(new Directory(path.join(tempDir.path, 'hello')), () async {
|
||||
await inDirectory(Directory(path.join(tempDir.path, 'hello')), () async {
|
||||
await flutter('clean');
|
||||
});
|
||||
|
||||
section('Materialize host app');
|
||||
|
||||
await inDirectory(new Directory(path.join(tempDir.path, 'hello')), () async {
|
||||
await inDirectory(Directory(path.join(tempDir.path, 'hello')), () async {
|
||||
await flutter(
|
||||
'materialize',
|
||||
options: <String>['android'],
|
||||
@@ -114,14 +114,14 @@ Future<Null> main() async {
|
||||
|
||||
section('Build materialized host app');
|
||||
|
||||
await inDirectory(new Directory(path.join(tempDir.path, 'hello')), () async {
|
||||
await inDirectory(Directory(path.join(tempDir.path, 'hello')), () async {
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>['apk'],
|
||||
);
|
||||
});
|
||||
|
||||
final bool materializedHostApkBuilt = exists(new File(path.join(
|
||||
final bool materializedHostApkBuilt = exists(File(path.join(
|
||||
tempDir.path,
|
||||
'hello',
|
||||
'build',
|
||||
@@ -133,24 +133,24 @@ Future<Null> main() async {
|
||||
)));
|
||||
|
||||
if (!materializedHostApkBuilt) {
|
||||
return new TaskResult.failure('Failed to build materialized host .apk');
|
||||
return TaskResult.failure('Failed to build materialized host .apk');
|
||||
}
|
||||
|
||||
section('Add to Android app');
|
||||
|
||||
final Directory hostApp = new Directory(path.join(tempDir.path, 'hello_host_app'));
|
||||
final Directory hostApp = Directory(path.join(tempDir.path, 'hello_host_app'));
|
||||
mkdir(hostApp);
|
||||
recursiveCopy(
|
||||
new Directory(path.join(flutterDirectory.path, 'dev', 'integration_tests', 'android_host_app')),
|
||||
Directory(path.join(flutterDirectory.path, 'dev', 'integration_tests', 'android_host_app')),
|
||||
hostApp,
|
||||
);
|
||||
copy(
|
||||
new File(path.join(tempDir.path, 'hello', '.android', 'gradlew')),
|
||||
File(path.join(tempDir.path, 'hello', '.android', 'gradlew')),
|
||||
hostApp,
|
||||
);
|
||||
copy(
|
||||
new File(path.join(tempDir.path, 'hello', '.android', 'gradle', 'wrapper', 'gradle-wrapper.jar')),
|
||||
new Directory(path.join(hostApp.path, 'gradle', 'wrapper')),
|
||||
File(path.join(tempDir.path, 'hello', '.android', 'gradle', 'wrapper', 'gradle-wrapper.jar')),
|
||||
Directory(path.join(hostApp.path, 'gradle', 'wrapper')),
|
||||
);
|
||||
|
||||
await inDirectory(hostApp, () async {
|
||||
@@ -161,7 +161,7 @@ Future<Null> main() async {
|
||||
);
|
||||
});
|
||||
|
||||
final bool existingAppBuilt = exists(new File(path.join(
|
||||
final bool existingAppBuilt = exists(File(path.join(
|
||||
hostApp.path,
|
||||
'app',
|
||||
'build',
|
||||
@@ -172,11 +172,11 @@ Future<Null> main() async {
|
||||
)));
|
||||
|
||||
if (!existingAppBuilt) {
|
||||
return new TaskResult.failure('Failed to build existing app .apk');
|
||||
return TaskResult.failure('Failed to build existing app .apk');
|
||||
}
|
||||
return new TaskResult.success(null);
|
||||
return TaskResult.success(null);
|
||||
} catch (e) {
|
||||
return new TaskResult.failure(e.toString());
|
||||
return TaskResult.failure(e.toString());
|
||||
} finally {
|
||||
rmTree(tempDir);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import 'package:flutter_devicelab/framework/framework.dart';
|
||||
|
||||
Future<Null> main() async {
|
||||
await task(combine(<TaskFunction>[
|
||||
new PluginTest('apk', <String>['-a', 'java']),
|
||||
new PluginTest('apk', <String>['-a', 'kotlin']),
|
||||
PluginTest('apk', <String>['-a', 'java']),
|
||||
PluginTest('apk', <String>['-a', 'kotlin']),
|
||||
]));
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import 'package:flutter_devicelab/framework/framework.dart';
|
||||
|
||||
Future<Null> main() async {
|
||||
await task(combine(<TaskFunction>[
|
||||
new PluginTest('ios', <String>['-i', 'objc']),
|
||||
new PluginTest('ios', <String>['-i', 'swift']),
|
||||
PluginTest('ios', <String>['-i', 'objc']),
|
||||
PluginTest('ios', <String>['-i', 'swift']),
|
||||
]));
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import 'package:flutter_devicelab/framework/framework.dart';
|
||||
|
||||
Future<Null> main() async {
|
||||
await task(combine(<TaskFunction>[
|
||||
new PluginTest('apk', <String>['-a', 'java']),
|
||||
new PluginTest('apk', <String>['-a', 'kotlin']),
|
||||
PluginTest('apk', <String>['-a', 'java']),
|
||||
PluginTest('apk', <String>['-a', 'kotlin']),
|
||||
]));
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ void main() {
|
||||
});
|
||||
section('TEST WHETHER `flutter run --route` WORKS');
|
||||
await inDirectory(appDir, () async {
|
||||
final Completer<Null> ready = new Completer<Null>();
|
||||
final Completer<Null> ready = Completer<Null>();
|
||||
bool ok;
|
||||
print('run: starting...');
|
||||
final Process run = await startProcess(
|
||||
@@ -86,6 +86,6 @@ void main() {
|
||||
if (result != 0)
|
||||
throw 'Received unexpected exit code $result from run process.';
|
||||
});
|
||||
return new TaskResult.success(null);
|
||||
return TaskResult.success(null);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ void main() {
|
||||
final Directory appDir =
|
||||
dir(path.join(flutterDirectory.path, 'dev/integration_tests/ui'));
|
||||
await inDirectory(appDir, () async {
|
||||
final Completer<Null> ready = new Completer<Null>();
|
||||
final Completer<Null> ready = Completer<Null>();
|
||||
bool ok;
|
||||
print('run: starting...');
|
||||
final Process run = await startProcess(
|
||||
@@ -54,7 +54,7 @@ void main() {
|
||||
],
|
||||
);
|
||||
final StreamController<String> stdout =
|
||||
new StreamController<String>.broadcast();
|
||||
StreamController<String>.broadcast();
|
||||
transformToLines(run.stdout).listen((String line) {
|
||||
print('run:stdout: $line');
|
||||
stdout.add(line);
|
||||
@@ -80,14 +80,14 @@ void main() {
|
||||
throw 'Failed to run test app.';
|
||||
|
||||
final VMServiceClient client =
|
||||
new VMServiceClient.connect('ws://localhost:$vmServicePort/ws');
|
||||
VMServiceClient.connect('ws://localhost:$vmServicePort/ws');
|
||||
|
||||
int id = 1;
|
||||
Future<Map<String, dynamic>> sendRequest(
|
||||
String method, dynamic params) async {
|
||||
final int requestId = id++;
|
||||
final Completer<Map<String, dynamic>> response =
|
||||
new Completer<Map<String, dynamic>>();
|
||||
Completer<Map<String, dynamic>>();
|
||||
final StreamSubscription<String> responseSubscription =
|
||||
stdout.stream.listen((String line) {
|
||||
final Map<String, dynamic> json = parseFlutterResponse(line);
|
||||
@@ -150,6 +150,6 @@ void main() {
|
||||
print('test: validating that the app has in fact closed...');
|
||||
await client.done.timeout(const Duration(seconds: 5));
|
||||
});
|
||||
return new TaskResult.success(null);
|
||||
return TaskResult.success(null);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ void main() {
|
||||
await device.unlock();
|
||||
final Directory appDir = dir(path.join(flutterDirectory.path, 'dev/integration_tests/ui'));
|
||||
await inDirectory(appDir, () async {
|
||||
final Completer<Null> ready = new Completer<Null>();
|
||||
final Completer<Null> ready = Completer<Null>();
|
||||
print('run: starting...');
|
||||
final Process run = await startProcess(
|
||||
path.join(flutterDirectory.path, 'bin', 'flutter'),
|
||||
@@ -76,6 +76,6 @@ void main() {
|
||||
'${stdout.join('\n')}';
|
||||
}
|
||||
});
|
||||
return new TaskResult.success(null);
|
||||
return TaskResult.success(null);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ void main() {
|
||||
await device.unlock();
|
||||
final Directory appDir = dir(path.join(flutterDirectory.path, 'dev/integration_tests/ui'));
|
||||
await inDirectory(appDir, () async {
|
||||
final Completer<Null> ready = new Completer<Null>();
|
||||
final Completer<Null> ready = Completer<Null>();
|
||||
bool ok;
|
||||
print('run: starting...');
|
||||
final Process run = await startProcess(
|
||||
@@ -54,7 +54,7 @@ void main() {
|
||||
if (!ok)
|
||||
throw 'Failed to run test app.';
|
||||
|
||||
final VMServiceClient client = new VMServiceClient.connect('ws://localhost:$vmServicePort/ws');
|
||||
final VMServiceClient client = VMServiceClient.connect('ws://localhost:$vmServicePort/ws');
|
||||
final VM vm = await client.getVM();
|
||||
final VMIsolateRef isolate = vm.isolates.first;
|
||||
final Stream<VMExtensionEvent> frameEvents = isolate.onExtensionEvent.where(
|
||||
@@ -82,7 +82,7 @@ void main() {
|
||||
if (result != 0)
|
||||
throw 'Received unexpected exit code $result from run process.';
|
||||
});
|
||||
return new TaskResult.success(null);
|
||||
return TaskResult.success(null);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,6 @@ import 'package:flutter_devicelab/framework/framework.dart';
|
||||
/// Smoke test of a task that fails by returning an unsuccessful response.
|
||||
Future<Null> main() async {
|
||||
await task(() async {
|
||||
return new TaskResult.failure('Failed');
|
||||
return TaskResult.failure('Failed');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -9,6 +9,6 @@ import 'package:flutter_devicelab/framework/framework.dart';
|
||||
/// Smoke test of a successful task.
|
||||
Future<Null> main() async {
|
||||
await task(() async {
|
||||
return new TaskResult.success(<String, dynamic>{});
|
||||
return TaskResult.success(<String, dynamic>{});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@ const double skipCost = 2473.0; // 20 hours: 5 to fix the issue we're ignoring,
|
||||
const double ignoreForFileCost = 2477.0; // similar thinking as skipCost
|
||||
const double asDynamicCost = 2003.0; // same as ignoring analyzer warning
|
||||
|
||||
final RegExp todoPattern = new RegExp(r'(?://|#) *TODO');
|
||||
final RegExp ignorePattern = new RegExp(r'// *ignore:');
|
||||
final RegExp ignoreForFilePattern = new RegExp(r'// *ignore_for_file:');
|
||||
final RegExp asDynamicPattern = new RegExp(r'as dynamic');
|
||||
final RegExp todoPattern = RegExp(r'(?://|#) *TODO');
|
||||
final RegExp ignorePattern = RegExp(r'// *ignore:');
|
||||
final RegExp ignoreForFilePattern = RegExp(r'// *ignore_for_file:');
|
||||
final RegExp asDynamicPattern = RegExp(r'as dynamic');
|
||||
|
||||
Future<double> findCostsForFile(File file) async {
|
||||
if (path.extension(file.path) == '.py')
|
||||
@@ -55,10 +55,10 @@ Future<double> findCostsForRepo() async {
|
||||
);
|
||||
double total = 0.0;
|
||||
await for (String entry in git.stdout.transform(utf8.decoder).transform(const LineSplitter()))
|
||||
total += await findCostsForFile(new File(path.join(flutterDirectory.path, entry)));
|
||||
total += await findCostsForFile(File(path.join(flutterDirectory.path, entry)));
|
||||
final int gitExitCode = await git.exitCode;
|
||||
if (gitExitCode != 0)
|
||||
throw new Exception('git exit with unexpected error code $gitExitCode');
|
||||
throw Exception('git exit with unexpected error code $gitExitCode');
|
||||
return total;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ Future<int> countDependencies() async {
|
||||
)).split('\n');
|
||||
final int count = lines.where((String line) => line.contains('->')).length;
|
||||
if (count < 2) // we'll always have flutter and flutter_test, at least...
|
||||
throw new Exception('"flutter update-packages --transitive-closure" returned bogus output:\n${lines.join("\n")}');
|
||||
throw Exception('"flutter update-packages --transitive-closure" returned bogus output:\n${lines.join("\n")}');
|
||||
return count;
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ const String _kNumberOfDependenciesKey = 'dependencies_count';
|
||||
|
||||
Future<Null> main() async {
|
||||
await task(() async {
|
||||
return new TaskResult.success(
|
||||
return TaskResult.success(
|
||||
<String, dynamic>{
|
||||
_kCostBenchmarkKey: await findCostsForRepo(),
|
||||
_kNumberOfDependenciesKey: await countDependencies(),
|
||||
|
||||
@@ -13,7 +13,7 @@ import 'package:path/path.dart' as path;
|
||||
import 'utils.dart';
|
||||
|
||||
/// The root of the API for controlling devices.
|
||||
DeviceDiscovery get devices => new DeviceDiscovery();
|
||||
DeviceDiscovery get devices => DeviceDiscovery();
|
||||
|
||||
/// Device operating system the test is configured to test.
|
||||
enum DeviceOperatingSystem { android, ios }
|
||||
@@ -26,11 +26,11 @@ abstract class DeviceDiscovery {
|
||||
factory DeviceDiscovery() {
|
||||
switch (deviceOperatingSystem) {
|
||||
case DeviceOperatingSystem.android:
|
||||
return new AndroidDeviceDiscovery();
|
||||
return AndroidDeviceDiscovery();
|
||||
case DeviceOperatingSystem.ios:
|
||||
return new IosDeviceDiscovery();
|
||||
return IosDeviceDiscovery();
|
||||
default:
|
||||
throw new StateError('Unsupported device operating system: {config.deviceOperatingSystem}');
|
||||
throw StateError('Unsupported device operating system: {config.deviceOperatingSystem}');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,12 +103,12 @@ class AndroidDeviceDiscovery implements DeviceDiscovery {
|
||||
// Parses information about a device. Example:
|
||||
//
|
||||
// 015d172c98400a03 device usb:340787200X product:nakasi model:Nexus_7 device:grouper
|
||||
static final RegExp _kDeviceRegex = new RegExp(r'^(\S+)\s+(\S+)(.*)');
|
||||
static final RegExp _kDeviceRegex = RegExp(r'^(\S+)\s+(\S+)(.*)');
|
||||
|
||||
static AndroidDeviceDiscovery _instance;
|
||||
|
||||
factory AndroidDeviceDiscovery() {
|
||||
return _instance ??= new AndroidDeviceDiscovery._();
|
||||
return _instance ??= AndroidDeviceDiscovery._();
|
||||
}
|
||||
|
||||
AndroidDeviceDiscovery._();
|
||||
@@ -129,14 +129,14 @@ class AndroidDeviceDiscovery implements DeviceDiscovery {
|
||||
@override
|
||||
Future<Null> chooseWorkingDevice() async {
|
||||
final List<Device> allDevices = (await discoverDevices())
|
||||
.map((String id) => new AndroidDevice(deviceId: id))
|
||||
.map((String id) => AndroidDevice(deviceId: id))
|
||||
.toList();
|
||||
|
||||
if (allDevices.isEmpty)
|
||||
throw 'No Android devices detected';
|
||||
|
||||
// TODO(yjbanov): filter out and warn about those with low battery level
|
||||
_workingDevice = allDevices[new math.Random().nextInt(allDevices.length)];
|
||||
_workingDevice = allDevices[math.Random().nextInt(allDevices.length)];
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -174,13 +174,13 @@ class AndroidDeviceDiscovery implements DeviceDiscovery {
|
||||
final Map<String, HealthCheckResult> results = <String, HealthCheckResult>{};
|
||||
for (String deviceId in await discoverDevices()) {
|
||||
try {
|
||||
final AndroidDevice device = new AndroidDevice(deviceId: deviceId);
|
||||
final AndroidDevice device = AndroidDevice(deviceId: deviceId);
|
||||
// Just a smoke test that we can read wakefulness state
|
||||
// TODO(yjbanov): check battery level
|
||||
await device._getWakefulness();
|
||||
results['android-device-$deviceId'] = new HealthCheckResult.success();
|
||||
results['android-device-$deviceId'] = HealthCheckResult.success();
|
||||
} catch (e, s) {
|
||||
results['android-device-$deviceId'] = new HealthCheckResult.error(e, s);
|
||||
results['android-device-$deviceId'] = HealthCheckResult.error(e, s);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
@@ -278,7 +278,7 @@ class AndroidDevice implements Device {
|
||||
@override
|
||||
Future<Map<String, dynamic>> getMemoryStats(String packageName) async {
|
||||
final String meminfo = await shellEval('dumpsys', <String>['meminfo', packageName]);
|
||||
final Match match = new RegExp(r'TOTAL\s+(\d+)').firstMatch(meminfo);
|
||||
final Match match = RegExp(r'TOTAL\s+(\d+)').firstMatch(meminfo);
|
||||
assert(match != null, 'could not parse dumpsys meminfo output');
|
||||
return <String, dynamic>{
|
||||
'total_kb': int.parse(match.group(1)),
|
||||
@@ -287,13 +287,13 @@ class AndroidDevice implements Device {
|
||||
|
||||
@override
|
||||
Stream<String> get logcat {
|
||||
final Completer<void> stdoutDone = new Completer<void>();
|
||||
final Completer<void> stderrDone = new Completer<void>();
|
||||
final Completer<void> processDone = new Completer<void>();
|
||||
final Completer<void> abort = new Completer<void>();
|
||||
final Completer<void> stdoutDone = Completer<void>();
|
||||
final Completer<void> stderrDone = Completer<void>();
|
||||
final Completer<void> processDone = Completer<void>();
|
||||
final Completer<void> abort = Completer<void>();
|
||||
bool aborted = false;
|
||||
StreamController<String> stream;
|
||||
stream = new StreamController<String>(
|
||||
stream = StreamController<String>(
|
||||
onListen: () async {
|
||||
await adb(<String>['logcat', '--clear']);
|
||||
final Process process = await startProcess(adbPath, <String>['-s', deviceId, 'logcat']);
|
||||
@@ -353,7 +353,7 @@ class IosDeviceDiscovery implements DeviceDiscovery {
|
||||
static IosDeviceDiscovery _instance;
|
||||
|
||||
factory IosDeviceDiscovery() {
|
||||
return _instance ??= new IosDeviceDiscovery._();
|
||||
return _instance ??= IosDeviceDiscovery._();
|
||||
}
|
||||
|
||||
IosDeviceDiscovery._();
|
||||
@@ -374,14 +374,14 @@ class IosDeviceDiscovery implements DeviceDiscovery {
|
||||
@override
|
||||
Future<Null> chooseWorkingDevice() async {
|
||||
final List<IosDevice> allDevices = (await discoverDevices())
|
||||
.map((String id) => new IosDevice(deviceId: id))
|
||||
.map((String id) => IosDevice(deviceId: id))
|
||||
.toList();
|
||||
|
||||
if (allDevices.isEmpty)
|
||||
throw 'No iOS devices detected';
|
||||
|
||||
// TODO(yjbanov): filter out and warn about those with low battery level
|
||||
_workingDevice = allDevices[new math.Random().nextInt(allDevices.length)];
|
||||
_workingDevice = allDevices[math.Random().nextInt(allDevices.length)];
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -400,7 +400,7 @@ class IosDeviceDiscovery implements DeviceDiscovery {
|
||||
final Map<String, HealthCheckResult> results = <String, HealthCheckResult>{};
|
||||
for (String deviceId in await discoverDevices()) {
|
||||
// TODO(ianh): do a more meaningful connectivity check than just recording the ID
|
||||
results['ios-device-$deviceId'] = new HealthCheckResult.success();
|
||||
results['ios-device-$deviceId'] = HealthCheckResult.success();
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ bool _isTaskRegistered = false;
|
||||
/// registered per Dart VM.
|
||||
Future<TaskResult> task(TaskFunction task) {
|
||||
if (_isTaskRegistered)
|
||||
throw new StateError('A task is already registered');
|
||||
throw StateError('A task is already registered');
|
||||
|
||||
_isTaskRegistered = true;
|
||||
|
||||
@@ -43,13 +43,13 @@ Future<TaskResult> task(TaskFunction task) {
|
||||
print('${rec.level.name}: ${rec.time}: ${rec.message}');
|
||||
});
|
||||
|
||||
final _TaskRunner runner = new _TaskRunner(task);
|
||||
final _TaskRunner runner = _TaskRunner(task);
|
||||
runner.keepVmAliveUntilTaskRunRequested();
|
||||
return runner.whenDone;
|
||||
}
|
||||
|
||||
class _TaskRunner {
|
||||
static final Logger logger = new Logger('TaskRunner');
|
||||
static final Logger logger = Logger('TaskRunner');
|
||||
|
||||
final TaskFunction task;
|
||||
|
||||
@@ -58,20 +58,20 @@ class _TaskRunner {
|
||||
Timer _startTaskTimeout;
|
||||
bool _taskStarted = false;
|
||||
|
||||
final Completer<TaskResult> _completer = new Completer<TaskResult>();
|
||||
final Completer<TaskResult> _completer = Completer<TaskResult>();
|
||||
|
||||
_TaskRunner(this.task) {
|
||||
registerExtension('ext.cocoonRunTask',
|
||||
(String method, Map<String, String> parameters) async {
|
||||
final Duration taskTimeout = parameters.containsKey('timeoutInMinutes')
|
||||
? new Duration(minutes: int.parse(parameters['timeoutInMinutes']))
|
||||
? Duration(minutes: int.parse(parameters['timeoutInMinutes']))
|
||||
: _kDefaultTaskTimeout;
|
||||
final TaskResult result = await run(taskTimeout);
|
||||
return new ServiceExtensionResponse.result(json.encode(result.toJson()));
|
||||
return ServiceExtensionResponse.result(json.encode(result.toJson()));
|
||||
});
|
||||
registerExtension('ext.cocoonRunnerReady',
|
||||
(String method, Map<String, String> parameters) async {
|
||||
return new ServiceExtensionResponse.result('"ready"');
|
||||
return ServiceExtensionResponse.result('"ready"');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ class _TaskRunner {
|
||||
return result;
|
||||
} on TimeoutException catch (_) {
|
||||
print('Task timed out in framework.dart after $taskTimeout.');
|
||||
return new TaskResult.failure('Task timed out after $taskTimeout');
|
||||
return TaskResult.failure('Task timed out after $taskTimeout');
|
||||
} finally {
|
||||
print('Cleaning up after task...');
|
||||
await forceQuitRunningProcesses();
|
||||
@@ -99,15 +99,15 @@ class _TaskRunner {
|
||||
/// received via the VM service protocol.
|
||||
void keepVmAliveUntilTaskRunRequested() {
|
||||
if (_taskStarted)
|
||||
throw new StateError('Task already started.');
|
||||
throw StateError('Task already started.');
|
||||
|
||||
// Merely creating this port object will cause the VM to stay alive and keep
|
||||
// the VM service server running until the port is disposed of.
|
||||
_keepAlivePort = new RawReceivePort();
|
||||
_keepAlivePort = RawReceivePort();
|
||||
|
||||
// Timeout if nothing bothers to connect and ask us to run the task.
|
||||
const Duration taskStartTimeout = Duration(seconds: 60);
|
||||
_startTaskTimeout = new Timer(taskStartTimeout, () {
|
||||
_startTaskTimeout = Timer(taskStartTimeout, () {
|
||||
if (!_taskStarted) {
|
||||
logger.severe('Task did not start in $taskStartTimeout.');
|
||||
_closeKeepAlivePort();
|
||||
@@ -123,7 +123,7 @@ class _TaskRunner {
|
||||
}
|
||||
|
||||
Future<TaskResult> _performTask() {
|
||||
final Completer<TaskResult> completer = new Completer<TaskResult>();
|
||||
final Completer<TaskResult> completer = Completer<TaskResult>();
|
||||
Chain.capture(() async {
|
||||
completer.complete(await task());
|
||||
}, onError: (dynamic taskError, Chain taskErrorStack) {
|
||||
@@ -138,7 +138,7 @@ class _TaskRunner {
|
||||
// code. Our goal is to convert the failure into a readable message.
|
||||
// Propagating it further is not useful.
|
||||
if (!completer.isCompleted)
|
||||
completer.complete(new TaskResult.failure(message));
|
||||
completer.complete(TaskResult.failure(message));
|
||||
});
|
||||
return completer.future;
|
||||
}
|
||||
@@ -167,7 +167,7 @@ class TaskResult {
|
||||
/// Constructs a successful result using JSON data stored in a file.
|
||||
factory TaskResult.successFromFile(File file,
|
||||
{List<String> benchmarkScoreKeys}) {
|
||||
return new TaskResult.success(json.decode(file.readAsStringSync()),
|
||||
return TaskResult.success(json.decode(file.readAsStringSync()),
|
||||
benchmarkScoreKeys: benchmarkScoreKeys);
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ class ManifestError extends Error {
|
||||
// manually. It's not too much code and produces good error messages.
|
||||
Manifest _validateAndParseManifest(Map<dynamic, dynamic> manifestYaml) {
|
||||
_checkKeys(manifestYaml, 'manifest', const <String>['tasks']);
|
||||
return new Manifest._(_validateAndParseTasks(manifestYaml['tasks']));
|
||||
return Manifest._(_validateAndParseTasks(manifestYaml['tasks']));
|
||||
}
|
||||
|
||||
List<ManifestTask> _validateAndParseTasks(dynamic tasksYaml) {
|
||||
@@ -108,7 +108,7 @@ ManifestTask _validateAndParseTask(dynamic taskName, dynamic taskYaml) {
|
||||
}
|
||||
|
||||
final List<dynamic> capabilities = _validateAndParseCapabilities(taskName, taskYaml['required_agent_capabilities']);
|
||||
return new ManifestTask._(
|
||||
return ManifestTask._(
|
||||
name: taskName,
|
||||
description: taskYaml['description'],
|
||||
stage: taskYaml['stage'],
|
||||
@@ -129,7 +129,7 @@ List<String> _validateAndParseCapabilities(String taskName, dynamic capabilities
|
||||
|
||||
void _checkType(bool isValid, dynamic value, String variableName, String typeName) {
|
||||
if (!isValid) {
|
||||
throw new ManifestError(
|
||||
throw ManifestError(
|
||||
'$variableName must be a $typeName but was ${value.runtimeType}: $value',
|
||||
);
|
||||
}
|
||||
@@ -137,14 +137,14 @@ void _checkType(bool isValid, dynamic value, String variableName, String typeNam
|
||||
|
||||
void _checkIsNotBlank(dynamic value, String variableName, String ownerName) {
|
||||
if (value == null || value.isEmpty) {
|
||||
throw new ManifestError('$variableName must not be empty in $ownerName.');
|
||||
throw ManifestError('$variableName must not be empty in $ownerName.');
|
||||
}
|
||||
}
|
||||
|
||||
void _checkKeys(Map<dynamic, dynamic> map, String variableName, List<String> allowedKeys) {
|
||||
for (String key in map.keys) {
|
||||
if (!allowedKeys.contains(key)) {
|
||||
throw new ManifestError(
|
||||
throw ManifestError(
|
||||
'Unrecognized property "$key" in $variableName. '
|
||||
'Allowed properties: ${allowedKeys.join(', ')}');
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ Future<Map<String, dynamic>> runTask(String taskName, { bool silent = false }) a
|
||||
runnerFinished = true;
|
||||
});
|
||||
|
||||
final Completer<int> port = new Completer<int>();
|
||||
final Completer<int> port = Completer<int>();
|
||||
|
||||
final StreamSubscription<String> stdoutSub = runner.stdout
|
||||
.transform(const Utf8Decoder())
|
||||
@@ -90,14 +90,14 @@ Future<Map<String, dynamic>> runTask(String taskName, { bool silent = false }) a
|
||||
|
||||
Future<VMIsolateRef> _connectToRunnerIsolate(int vmServicePort) async {
|
||||
final String url = 'ws://localhost:$vmServicePort/ws';
|
||||
final DateTime started = new DateTime.now();
|
||||
final DateTime started = DateTime.now();
|
||||
|
||||
// TODO(yjbanov): due to lack of imagination at the moment the handshake with
|
||||
// the task process is very rudimentary and requires this small
|
||||
// delay to let the task process open up the VM service port.
|
||||
// Otherwise we almost always hit the non-ready case first and
|
||||
// wait a whole 1 second, which is annoying.
|
||||
await new Future<Null>.delayed(const Duration(milliseconds: 100));
|
||||
await Future<Null>.delayed(const Duration(milliseconds: 100));
|
||||
|
||||
while (true) {
|
||||
try {
|
||||
@@ -105,7 +105,7 @@ Future<VMIsolateRef> _connectToRunnerIsolate(int vmServicePort) async {
|
||||
await (await WebSocket.connect(url)).close();
|
||||
|
||||
// Look up the isolate.
|
||||
final VMServiceClient client = new VMServiceClient.connect(url);
|
||||
final VMServiceClient client = VMServiceClient.connect(url);
|
||||
final VM vm = await client.getVM();
|
||||
final VMIsolateRef isolate = vm.isolates.single;
|
||||
final String response = await isolate.invokeExtension('ext.cocoonRunnerReady');
|
||||
@@ -114,8 +114,8 @@ Future<VMIsolateRef> _connectToRunnerIsolate(int vmServicePort) async {
|
||||
return isolate;
|
||||
} catch (error) {
|
||||
const Duration connectionTimeout = Duration(seconds: 10);
|
||||
if (new DateTime.now().difference(started) > connectionTimeout) {
|
||||
throw new TimeoutException(
|
||||
if (DateTime.now().difference(started) > connectionTimeout) {
|
||||
throw TimeoutException(
|
||||
'Failed to connect to the task runner process',
|
||||
connectionTimeout,
|
||||
);
|
||||
@@ -123,7 +123,7 @@ Future<VMIsolateRef> _connectToRunnerIsolate(int vmServicePort) async {
|
||||
print('VM service not ready yet: $error');
|
||||
const Duration pauseBetweenRetries = Duration(milliseconds: 200);
|
||||
print('Will retry in $pauseBetweenRetries.');
|
||||
await new Future<Null>.delayed(pauseBetweenRetries);
|
||||
await Future<Null>.delayed(pauseBetweenRetries);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -142,8 +142,8 @@ Future<void> cleanupSystem() async {
|
||||
print('\nTelling Gradle to shut down (JAVA_HOME=$javaHome)');
|
||||
final String gradlewBinaryName = Platform.isWindows ? 'gradlew.bat' : 'gradlew';
|
||||
final Directory tempDir = Directory.systemTemp.createTempSync('flutter_devicelab_shutdown_gradle.');
|
||||
recursiveCopy(new Directory(path.join(flutterDirectory.path, 'bin', 'cache', 'artifacts', 'gradle_wrapper')), tempDir);
|
||||
copy(new File(path.join(path.join(flutterDirectory.path, 'packages', 'flutter_tools'), 'templates', 'create', 'android.tmpl', 'gradle', 'wrapper', 'gradle-wrapper.properties')), new Directory(path.join(tempDir.path, 'gradle', 'wrapper')));
|
||||
recursiveCopy(Directory(path.join(flutterDirectory.path, 'bin', 'cache', 'artifacts', 'gradle_wrapper')), tempDir);
|
||||
copy(File(path.join(path.join(flutterDirectory.path, 'packages', 'flutter_tools'), 'templates', 'create', 'android.tmpl', 'gradle', 'wrapper', 'gradle-wrapper.properties')), Directory(path.join(tempDir.path, 'gradle', 'wrapper')));
|
||||
if (!Platform.isWindows) {
|
||||
await exec(
|
||||
'chmod',
|
||||
|
||||
@@ -24,7 +24,7 @@ ProcessManager _processManager = const LocalProcessManager();
|
||||
class ProcessInfo {
|
||||
ProcessInfo(this.command, this.process);
|
||||
|
||||
final DateTime startTime = new DateTime.now();
|
||||
final DateTime startTime = DateTime.now();
|
||||
final String command;
|
||||
final Process process;
|
||||
|
||||
@@ -52,7 +52,7 @@ class HealthCheckResult {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
final StringBuffer buf = new StringBuffer(succeeded ? 'succeeded' : 'failed');
|
||||
final StringBuffer buf = StringBuffer(succeeded ? 'succeeded' : 'failed');
|
||||
if (details != null && details.trim().isNotEmpty) {
|
||||
buf.writeln();
|
||||
// Indent details by 4 spaces
|
||||
@@ -74,7 +74,7 @@ class BuildFailedError extends Error {
|
||||
}
|
||||
|
||||
void fail(String message) {
|
||||
throw new BuildFailedError(message);
|
||||
throw BuildFailedError(message);
|
||||
}
|
||||
|
||||
// Remove the given file or directory.
|
||||
@@ -98,9 +98,9 @@ void rmTree(FileSystemEntity entity) {
|
||||
|
||||
List<FileSystemEntity> ls(Directory directory) => directory.listSync();
|
||||
|
||||
Directory dir(String path) => new Directory(path);
|
||||
Directory dir(String path) => Directory(path);
|
||||
|
||||
File file(String path) => new File(path);
|
||||
File file(String path) => File(path);
|
||||
|
||||
void copy(File sourceFile, Directory targetDirectory, {String name}) {
|
||||
final File target = file(
|
||||
@@ -115,9 +115,9 @@ void recursiveCopy(Directory source, Directory target) {
|
||||
for (FileSystemEntity entity in source.listSync(followLinks: false)) {
|
||||
final String name = path.basename(entity.path);
|
||||
if (entity is Directory)
|
||||
recursiveCopy(entity, new Directory(path.join(target.path, name)));
|
||||
recursiveCopy(entity, Directory(path.join(target.path, name)));
|
||||
else if (entity is File) {
|
||||
final File dest = new File(path.join(target.path, name));
|
||||
final File dest = File(path.join(target.path, name));
|
||||
dest.writeAsBytesSync(entity.readAsBytesSync());
|
||||
}
|
||||
}
|
||||
@@ -187,7 +187,7 @@ Future<DateTime> getFlutterRepoCommitTimestamp(String commit) {
|
||||
commit,
|
||||
]);
|
||||
final int secondsSinceEpoch = int.parse(unixTimestamp);
|
||||
return new DateTime.fromMillisecondsSinceEpoch(secondsSinceEpoch * 1000);
|
||||
return DateTime.fromMillisecondsSinceEpoch(secondsSinceEpoch * 1000);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ Future<Process> startProcess(
|
||||
environment: environment,
|
||||
workingDirectory: workingDirectory ?? cwd,
|
||||
);
|
||||
final ProcessInfo processInfo = new ProcessInfo(command, process);
|
||||
final ProcessInfo processInfo = ProcessInfo(command, process);
|
||||
_runningProcesses.add(processInfo);
|
||||
|
||||
process.exitCode.then((int exitCode) {
|
||||
@@ -248,7 +248,7 @@ Future<Null> forceQuitRunningProcesses() async {
|
||||
return;
|
||||
|
||||
// Give normally quitting processes a chance to report their exit code.
|
||||
await new Future<Null>.delayed(const Duration(seconds: 1));
|
||||
await Future<Null>.delayed(const Duration(seconds: 1));
|
||||
|
||||
// Whatever's left, kill it.
|
||||
for (ProcessInfo p in _runningProcesses) {
|
||||
@@ -270,8 +270,8 @@ Future<int> exec(
|
||||
}) async {
|
||||
final Process process = await startProcess(executable, arguments, environment: environment, workingDirectory: workingDirectory);
|
||||
|
||||
final Completer<Null> stdoutDone = new Completer<Null>();
|
||||
final Completer<Null> stderrDone = new Completer<Null>();
|
||||
final Completer<Null> stdoutDone = Completer<Null>();
|
||||
final Completer<Null> stderrDone = Completer<Null>();
|
||||
process.stdout
|
||||
.transform(utf8.decoder)
|
||||
.transform(const LineSplitter())
|
||||
@@ -306,9 +306,9 @@ Future<String> eval(
|
||||
}) async {
|
||||
final Process process = await startProcess(executable, arguments, environment: environment, workingDirectory: workingDirectory);
|
||||
|
||||
final StringBuffer output = new StringBuffer();
|
||||
final Completer<Null> stdoutDone = new Completer<Null>();
|
||||
final Completer<Null> stderrDone = new Completer<Null>();
|
||||
final StringBuffer output = StringBuffer();
|
||||
final Completer<Null> stdoutDone = Completer<Null>();
|
||||
final Completer<Null> stderrDone = Completer<Null>();
|
||||
process.stdout
|
||||
.transform(utf8.decoder)
|
||||
.transform(const LineSplitter())
|
||||
@@ -496,7 +496,7 @@ Iterable<String> grep(Pattern pattern, {@required String from}) {
|
||||
///
|
||||
/// }
|
||||
Future<Null> runAndCaptureAsyncStacks(Future<Null> callback()) {
|
||||
final Completer<Null> completer = new Completer<Null>();
|
||||
final Completer<Null> completer = Completer<Null>();
|
||||
Chain.capture(() async {
|
||||
await callback();
|
||||
completer.complete();
|
||||
@@ -507,7 +507,7 @@ Future<Null> runAndCaptureAsyncStacks(Future<Null> callback()) {
|
||||
bool canRun(String path) => _processManager.canRun(path);
|
||||
|
||||
String extractCloudAuthTokenArg(List<String> rawArgs) {
|
||||
final ArgParser argParser = new ArgParser()..addOption('cloud-auth-token');
|
||||
final ArgParser argParser = ArgParser()..addOption('cloud-auth-token');
|
||||
ArgResults args;
|
||||
try {
|
||||
args = argParser.parse(rawArgs);
|
||||
@@ -536,7 +536,7 @@ int parseServicePort(String line, {
|
||||
bool multiLine = false,
|
||||
}) {
|
||||
// e.g. "An Observatory debugger and profiler on ... is available at: http://127.0.0.1:8100/"
|
||||
final RegExp pattern = new RegExp('$prefix(\\S+:(\\d+)/\\S*)\$', multiLine: multiLine);
|
||||
final RegExp pattern = RegExp('$prefix(\\S+:(\\d+)/\\S*)\$', multiLine: multiLine);
|
||||
final Match match = pattern.firstMatch(line);
|
||||
return match == null ? null : int.parse(match.group(2));
|
||||
}
|
||||
|
||||
@@ -29,12 +29,12 @@ Future<TaskResult> analyzerBenchmarkTask() async {
|
||||
});
|
||||
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data.addAll((await _run(new _FlutterRepoBenchmark())).asMap('flutter_repo', 'batch'));
|
||||
data.addAll((await _run(new _FlutterRepoBenchmark(watch: true))).asMap('flutter_repo', 'watch'));
|
||||
data.addAll((await _run(new _MegaGalleryBenchmark())).asMap('mega_gallery', 'batch'));
|
||||
data.addAll((await _run(new _MegaGalleryBenchmark(watch: true))).asMap('mega_gallery', 'watch'));
|
||||
data.addAll((await _run(_FlutterRepoBenchmark())).asMap('flutter_repo', 'batch'));
|
||||
data.addAll((await _run(_FlutterRepoBenchmark(watch: true))).asMap('flutter_repo', 'watch'));
|
||||
data.addAll((await _run(_MegaGalleryBenchmark())).asMap('mega_gallery', 'batch'));
|
||||
data.addAll((await _run(_MegaGalleryBenchmark(watch: true))).asMap('mega_gallery', 'watch'));
|
||||
|
||||
return new TaskResult.success(data, benchmarkScoreKeys: data.keys.toList());
|
||||
return TaskResult.success(data, benchmarkScoreKeys: data.keys.toList());
|
||||
}
|
||||
|
||||
class _BenchmarkResult {
|
||||
@@ -73,7 +73,7 @@ abstract class _Benchmark {
|
||||
|
||||
Future<double> execute(int iteration, int targetIterations) async {
|
||||
section('Analyze $title ${watch ? 'with watcher' : ''} - ${iteration + 1} / $targetIterations');
|
||||
final Stopwatch stopwatch = new Stopwatch();
|
||||
final Stopwatch stopwatch = Stopwatch();
|
||||
await inDirectory(directory, () async {
|
||||
stopwatch.start();
|
||||
await flutter('analyze', options: options);
|
||||
@@ -124,5 +124,5 @@ Future<_BenchmarkResult> _run(_Benchmark benchmark) async {
|
||||
0.0,
|
||||
(double previousValue, double element) => previousValue + element,
|
||||
);
|
||||
return new _BenchmarkResult(sum / results.length, results.first, results.last);
|
||||
return _BenchmarkResult(sum / results.length, results.first, results.last);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import '../framework/ios.dart';
|
||||
import '../framework/utils.dart';
|
||||
|
||||
TaskFunction createGalleryTransitionTest({ bool semanticsEnabled = false }) {
|
||||
return new GalleryTransitionTest(semanticsEnabled: semanticsEnabled);
|
||||
return GalleryTransitionTest(semanticsEnabled: semanticsEnabled);
|
||||
}
|
||||
|
||||
class GalleryTransitionTest {
|
||||
@@ -67,7 +67,7 @@ class GalleryTransitionTest {
|
||||
};
|
||||
data.addAll(summary);
|
||||
|
||||
return new TaskResult.success(data, benchmarkScoreKeys: <String>[
|
||||
return TaskResult.success(data, benchmarkScoreKeys: <String>[
|
||||
'missed_transition_count',
|
||||
'average_frame_build_time_millis',
|
||||
'worst_frame_build_time_millis',
|
||||
|
||||
@@ -43,8 +43,8 @@ TaskFunction createHotModeTest() {
|
||||
environment: null
|
||||
);
|
||||
|
||||
final Completer<Null> stdoutDone = new Completer<Null>();
|
||||
final Completer<Null> stderrDone = new Completer<Null>();
|
||||
final Completer<Null> stdoutDone = Completer<Null>();
|
||||
final Completer<Null> stderrDone = Completer<Null>();
|
||||
process.stdout
|
||||
.transform(utf8.decoder)
|
||||
.transform(const LineSplitter())
|
||||
@@ -96,8 +96,8 @@ TaskFunction createHotModeTest() {
|
||||
<String>['run']..addAll(options),
|
||||
environment: null
|
||||
);
|
||||
final Completer<Null> stdoutDone = new Completer<Null>();
|
||||
final Completer<Null> stderrDone = new Completer<Null>();
|
||||
final Completer<Null> stdoutDone = Completer<Null>();
|
||||
final Completer<Null> stderrDone = Completer<Null>();
|
||||
process.stdout
|
||||
.transform(utf8.decoder)
|
||||
.transform(const LineSplitter())
|
||||
@@ -130,7 +130,7 @@ TaskFunction createHotModeTest() {
|
||||
|
||||
|
||||
|
||||
return new TaskResult.success(
|
||||
return TaskResult.success(
|
||||
<String, dynamic> {
|
||||
'hotReloadInitialDevFSSyncMilliseconds': twoReloadsData['hotReloadInitialDevFSSyncMilliseconds'][0],
|
||||
'hotRestartMillisecondsToFrame': twoReloadsData['hotRestartMillisecondsToFrame'][0],
|
||||
|
||||
@@ -10,21 +10,21 @@ import '../framework/ios.dart';
|
||||
import '../framework/utils.dart';
|
||||
|
||||
TaskFunction createChannelsIntegrationTest() {
|
||||
return new DriverTest(
|
||||
return DriverTest(
|
||||
'${flutterDirectory.path}/dev/integration_tests/channels',
|
||||
'lib/main.dart',
|
||||
);
|
||||
}
|
||||
|
||||
TaskFunction createPlatformInteractionTest() {
|
||||
return new DriverTest(
|
||||
return DriverTest(
|
||||
'${flutterDirectory.path}/dev/integration_tests/platform_interaction',
|
||||
'lib/main.dart',
|
||||
);
|
||||
}
|
||||
|
||||
TaskFunction createFlavorsTest() {
|
||||
return new DriverTest(
|
||||
return DriverTest(
|
||||
'${flutterDirectory.path}/dev/integration_tests/flavors',
|
||||
'lib/main.dart',
|
||||
extraOptions: <String>['--flavor', 'paid']
|
||||
@@ -32,28 +32,28 @@ TaskFunction createFlavorsTest() {
|
||||
}
|
||||
|
||||
TaskFunction createExternalUiIntegrationTest() {
|
||||
return new DriverTest(
|
||||
return DriverTest(
|
||||
'${flutterDirectory.path}/dev/integration_tests/external_ui',
|
||||
'lib/main.dart',
|
||||
);
|
||||
}
|
||||
|
||||
TaskFunction createPlatformChannelSampleTest() {
|
||||
return new DriverTest(
|
||||
return DriverTest(
|
||||
'${flutterDirectory.path}/examples/platform_channel',
|
||||
'test_driver/button_tap.dart',
|
||||
);
|
||||
}
|
||||
|
||||
TaskFunction createEmbeddedAndroidViewsIntegrationTest() {
|
||||
return new DriverTest(
|
||||
return DriverTest(
|
||||
'${flutterDirectory.path}/dev/integration_tests/android_views',
|
||||
'lib/main.dart',
|
||||
);
|
||||
}
|
||||
|
||||
TaskFunction createAndroidSemanticsIntegrationTest() {
|
||||
return new DriverTest(
|
||||
return DriverTest(
|
||||
'${flutterDirectory.path}/dev/integration_tests/android_semantics_testing',
|
||||
'lib/main.dart',
|
||||
);
|
||||
@@ -91,7 +91,7 @@ class DriverTest {
|
||||
options.addAll(extraOptions);
|
||||
await flutter('drive', options: options);
|
||||
|
||||
return new TaskResult.success(null);
|
||||
return TaskResult.success(null);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,5 +33,5 @@ Future<TaskResult> runEndToEndTests() async {
|
||||
}
|
||||
});
|
||||
|
||||
return new TaskResult.success(<String, dynamic>{});
|
||||
return TaskResult.success(<String, dynamic>{});
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ TaskFunction createMicrobenchmarkTask() {
|
||||
allResults.addAll(await _runMicrobench('lib/gestures/velocity_tracker_bench.dart'));
|
||||
allResults.addAll(await _runMicrobench('lib/stocks/animation_bench.dart'));
|
||||
|
||||
return new TaskResult.success(allResults, benchmarkScoreKeys: allResults.keys.toList());
|
||||
return TaskResult.success(allResults, benchmarkScoreKeys: allResults.keys.toList());
|
||||
};
|
||||
}
|
||||
|
||||
@@ -74,8 +74,8 @@ Future<Map<String, double>> _readJsonResults(Process process) {
|
||||
const String jsonEnd = '================ FORMATTED ==============';
|
||||
const String jsonPrefix = ':::JSON:::';
|
||||
bool jsonStarted = false;
|
||||
final StringBuffer jsonBuf = new StringBuffer();
|
||||
final Completer<Map<String, double>> completer = new Completer<Map<String, double>>();
|
||||
final StringBuffer jsonBuf = StringBuffer();
|
||||
final Completer<Map<String, double>> completer = Completer<Map<String, double>>();
|
||||
|
||||
final StreamSubscription<String> stderrSub = process.stderr
|
||||
.transform(const Utf8Decoder())
|
||||
@@ -126,7 +126,7 @@ Future<Map<String, double>> _readJsonResults(Process process) {
|
||||
// Also send a kill signal in case the `q` above didn't work.
|
||||
process.kill(ProcessSignal.sigint); // ignore: deprecated_member_use
|
||||
try {
|
||||
completer.complete(new Map<String, double>.from(json.decode(jsonOutput)));
|
||||
completer.complete(Map<String, double>.from(json.decode(jsonOutput)));
|
||||
} catch (ex) {
|
||||
completer.completeError('Decoding JSON failed ($ex). JSON string was: $jsonOutput');
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import '../framework/ios.dart';
|
||||
import '../framework/utils.dart';
|
||||
|
||||
TaskFunction createComplexLayoutScrollPerfTest() {
|
||||
return new PerfTest(
|
||||
return PerfTest(
|
||||
'${flutterDirectory.path}/dev/benchmarks/complex_layout',
|
||||
'test_driver/scroll_perf.dart',
|
||||
'complex_layout_scroll_perf',
|
||||
@@ -23,7 +23,7 @@ TaskFunction createComplexLayoutScrollPerfTest() {
|
||||
}
|
||||
|
||||
TaskFunction createTilesScrollPerfTest() {
|
||||
return new PerfTest(
|
||||
return PerfTest(
|
||||
'${flutterDirectory.path}/dev/benchmarks/complex_layout',
|
||||
'test_driver/scroll_perf.dart',
|
||||
'tiles_scroll_perf',
|
||||
@@ -31,38 +31,38 @@ TaskFunction createTilesScrollPerfTest() {
|
||||
}
|
||||
|
||||
TaskFunction createFlutterGalleryStartupTest() {
|
||||
return new StartupTest(
|
||||
return StartupTest(
|
||||
'${flutterDirectory.path}/examples/flutter_gallery',
|
||||
).run;
|
||||
}
|
||||
|
||||
TaskFunction createComplexLayoutStartupTest() {
|
||||
return new StartupTest(
|
||||
return StartupTest(
|
||||
'${flutterDirectory.path}/dev/benchmarks/complex_layout',
|
||||
).run;
|
||||
}
|
||||
|
||||
TaskFunction createFlutterGalleryCompileTest() {
|
||||
return new CompileTest('${flutterDirectory.path}/examples/flutter_gallery').run;
|
||||
return CompileTest('${flutterDirectory.path}/examples/flutter_gallery').run;
|
||||
}
|
||||
|
||||
TaskFunction createHelloWorldCompileTest() {
|
||||
return new CompileTest('${flutterDirectory.path}/examples/hello_world', reportPackageContentSizes: true).run;
|
||||
return CompileTest('${flutterDirectory.path}/examples/hello_world', reportPackageContentSizes: true).run;
|
||||
}
|
||||
|
||||
TaskFunction createComplexLayoutCompileTest() {
|
||||
return new CompileTest('${flutterDirectory.path}/dev/benchmarks/complex_layout').run;
|
||||
return CompileTest('${flutterDirectory.path}/dev/benchmarks/complex_layout').run;
|
||||
}
|
||||
|
||||
TaskFunction createFlutterViewStartupTest() {
|
||||
return new StartupTest(
|
||||
return StartupTest(
|
||||
'${flutterDirectory.path}/examples/flutter_view',
|
||||
reportMetrics: false,
|
||||
).run;
|
||||
}
|
||||
|
||||
TaskFunction createPlatformViewStartupTest() {
|
||||
return new StartupTest(
|
||||
return StartupTest(
|
||||
'${flutterDirectory.path}/examples/platform_view',
|
||||
reportMetrics: false,
|
||||
).run;
|
||||
@@ -82,7 +82,7 @@ TaskFunction createBasicMaterialCompileTest() {
|
||||
if (!(await sampleDir.exists()))
|
||||
throw 'Failed to create default Flutter app in ${sampleDir.path}';
|
||||
|
||||
return new CompileTest(sampleDir.path).run();
|
||||
return CompileTest(sampleDir.path).run();
|
||||
};
|
||||
}
|
||||
|
||||
@@ -112,9 +112,9 @@ class StartupTest {
|
||||
final Map<String, dynamic> data = json.decode(file('$testDirectory/build/start_up_info.json').readAsStringSync());
|
||||
|
||||
if (!reportMetrics)
|
||||
return new TaskResult.success(data);
|
||||
return TaskResult.success(data);
|
||||
|
||||
return new TaskResult.success(data, benchmarkScoreKeys: <String>[
|
||||
return TaskResult.success(data, benchmarkScoreKeys: <String>[
|
||||
'timeToFirstFrameMicros',
|
||||
]);
|
||||
});
|
||||
@@ -152,13 +152,13 @@ class PerfTest {
|
||||
final Map<String, dynamic> data = json.decode(file('$testDirectory/build/$timelineFileName.timeline_summary.json').readAsStringSync());
|
||||
|
||||
if (data['frame_count'] < 5) {
|
||||
return new TaskResult.failure(
|
||||
return TaskResult.failure(
|
||||
'Timeline contains too few frames: ${data['frame_count']}. Possibly '
|
||||
'trace events are not being captured.',
|
||||
);
|
||||
}
|
||||
|
||||
return new TaskResult.success(data, benchmarkScoreKeys: <String>[
|
||||
return TaskResult.success(data, benchmarkScoreKeys: <String>[
|
||||
'average_frame_build_time_millis',
|
||||
'worst_frame_build_time_millis',
|
||||
'missed_frame_build_budget_count',
|
||||
@@ -190,14 +190,14 @@ class CompileTest {
|
||||
..addAll(await _compileApp(reportPackageContentSizes: reportPackageContentSizes))
|
||||
..addAll(await _compileDebug());
|
||||
|
||||
return new TaskResult.success(metrics, benchmarkScoreKeys: metrics.keys.toList());
|
||||
return TaskResult.success(metrics, benchmarkScoreKeys: metrics.keys.toList());
|
||||
});
|
||||
}
|
||||
|
||||
static Future<Map<String, dynamic>> _compileAot() async {
|
||||
// Generate blobs instead of assembly.
|
||||
await flutter('clean');
|
||||
final Stopwatch watch = new Stopwatch()..start();
|
||||
final Stopwatch watch = Stopwatch()..start();
|
||||
final List<String> options = <String>[
|
||||
'aot',
|
||||
'-v',
|
||||
@@ -218,7 +218,7 @@ class CompileTest {
|
||||
final String compileLog = await evalFlutter('build', options: options);
|
||||
watch.stop();
|
||||
|
||||
final RegExp metricExpression = new RegExp(r'([a-zA-Z]+)\(CodeSize\)\: (\d+)');
|
||||
final RegExp metricExpression = RegExp(r'([a-zA-Z]+)\(CodeSize\)\: (\d+)');
|
||||
final Map<String, dynamic> metrics = <String, dynamic>{};
|
||||
for (Match m in metricExpression.allMatches(compileLog)) {
|
||||
metrics[_sdkNameToMetricName(m.group(1))] = int.parse(m.group(2));
|
||||
@@ -233,7 +233,7 @@ class CompileTest {
|
||||
|
||||
static Future<Map<String, dynamic>> _compileApp({ bool reportPackageContentSizes = false }) async {
|
||||
await flutter('clean');
|
||||
final Stopwatch watch = new Stopwatch();
|
||||
final Stopwatch watch = Stopwatch();
|
||||
int releaseSizeInBytes;
|
||||
final List<String> options = <String>['--release'];
|
||||
setLocalEngineOptionIfNecessary(options);
|
||||
@@ -281,7 +281,7 @@ class CompileTest {
|
||||
|
||||
static Future<Map<String, dynamic>> _compileDebug() async {
|
||||
await flutter('clean');
|
||||
final Stopwatch watch = new Stopwatch();
|
||||
final Stopwatch watch = Stopwatch();
|
||||
final List<String> options = <String>['--debug'];
|
||||
setLocalEngineOptionIfNecessary(options);
|
||||
switch (deviceOperatingSystem) {
|
||||
@@ -327,8 +327,8 @@ class CompileTest {
|
||||
'TARGET_BUILD_DIR': path.dirname(appPath),
|
||||
});
|
||||
|
||||
final File appFramework = new File(path.join(appPath, 'Frameworks', 'App.framework', 'App'));
|
||||
final File flutterFramework = new File(path.join(appPath, 'Frameworks', 'Flutter.framework', 'Flutter'));
|
||||
final File appFramework = File(path.join(appPath, 'Frameworks', 'App.framework', 'App'));
|
||||
final File flutterFramework = File(path.join(appPath, 'Frameworks', 'Flutter.framework', 'Flutter'));
|
||||
|
||||
return <String, dynamic>{
|
||||
'app_framework_uncompressed_bytes': await appFramework.length(),
|
||||
@@ -344,7 +344,7 @@ class CompileTest {
|
||||
|
||||
// First three lines are header, last two lines are footer.
|
||||
for (int i = 3; i < lines.length - 2; i++) {
|
||||
final _UnzipListEntry entry = new _UnzipListEntry.fromLine(lines[i]);
|
||||
final _UnzipListEntry entry = _UnzipListEntry.fromLine(lines[i]);
|
||||
fileToMetadata[entry.path] = entry;
|
||||
}
|
||||
|
||||
@@ -390,7 +390,7 @@ class MemoryTest {
|
||||
/// when `adb logcat` sees a log line with the given `message`.
|
||||
void prepareForNextMessage(String message) {
|
||||
_nextMessage = message;
|
||||
_receivedNextMessage = new Completer<void>();
|
||||
_receivedNextMessage = Completer<void>();
|
||||
}
|
||||
|
||||
int get iterationCount => 15;
|
||||
@@ -427,14 +427,14 @@ class MemoryTest {
|
||||
assert(_diffMemory.length == iteration + 1);
|
||||
print('terminating...');
|
||||
await device.stop(package);
|
||||
await new Future<void>.delayed(const Duration(milliseconds: 10));
|
||||
await Future<void>.delayed(const Duration(milliseconds: 10));
|
||||
}
|
||||
|
||||
await adb.cancel();
|
||||
|
||||
final ListStatistics startMemoryStatistics = new ListStatistics(_startMemory);
|
||||
final ListStatistics endMemoryStatistics = new ListStatistics(_endMemory);
|
||||
final ListStatistics diffMemoryStatistics = new ListStatistics(_diffMemory);
|
||||
final ListStatistics startMemoryStatistics = ListStatistics(_startMemory);
|
||||
final ListStatistics endMemoryStatistics = ListStatistics(_endMemory);
|
||||
final ListStatistics diffMemoryStatistics = ListStatistics(_diffMemory);
|
||||
|
||||
final Map<String, dynamic> memoryUsage = <String, dynamic>{};
|
||||
memoryUsage.addAll(startMemoryStatistics.asMap('start'));
|
||||
@@ -446,7 +446,7 @@ class MemoryTest {
|
||||
_endMemory.clear();
|
||||
_diffMemory.clear();
|
||||
|
||||
return new TaskResult.success(memoryUsage, benchmarkScoreKeys: memoryUsage.keys.toList());
|
||||
return TaskResult.success(memoryUsage, benchmarkScoreKeys: memoryUsage.keys.toList());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -516,7 +516,7 @@ class ListStatistics {
|
||||
assert(data.isNotEmpty);
|
||||
assert(data.length % 2 == 1);
|
||||
final List<int> sortedData = data.toList()..sort();
|
||||
return new ListStatistics._(
|
||||
return ListStatistics._(
|
||||
sortedData.first,
|
||||
sortedData.last,
|
||||
sortedData[(sortedData.length - 1) ~/ 2],
|
||||
@@ -540,9 +540,9 @@ class ListStatistics {
|
||||
|
||||
class _UnzipListEntry {
|
||||
factory _UnzipListEntry.fromLine(String line) {
|
||||
final List<String> data = line.trim().split(new RegExp('\\s+'));
|
||||
final List<String> data = line.trim().split(RegExp('\\s+'));
|
||||
assert(data.length == 8);
|
||||
return new _UnzipListEntry._(
|
||||
return _UnzipListEntry._(
|
||||
uncompressedSize: int.parse(data[0]),
|
||||
compressedSize: int.parse(data[2]),
|
||||
path: data[7],
|
||||
|
||||
@@ -19,7 +19,7 @@ TaskFunction combine(List<TaskFunction> tasks) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return new TaskResult.success(null);
|
||||
return TaskResult.success(null);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -46,9 +46,9 @@ class PluginTest {
|
||||
} finally {
|
||||
await project.delete();
|
||||
}
|
||||
return new TaskResult.success(null);
|
||||
return TaskResult.success(null);
|
||||
} catch (e) {
|
||||
return new TaskResult.failure(e.toString());
|
||||
return TaskResult.failure(e.toString());
|
||||
} finally {
|
||||
rmTree(tempDir);
|
||||
}
|
||||
@@ -68,13 +68,13 @@ class FlutterProject {
|
||||
options: <String>['--org', 'io.flutter.devicelab']..addAll(options)..add('plugintest')
|
||||
);
|
||||
});
|
||||
return new FlutterProject(directory, 'plugintest');
|
||||
return FlutterProject(directory, 'plugintest');
|
||||
}
|
||||
|
||||
String get rootPath => path.join(parent.path, name);
|
||||
|
||||
Future<Null> addPlugin(String plugin) async {
|
||||
final File pubspec = new File(path.join(rootPath, 'pubspec.yaml'));
|
||||
final File pubspec = File(path.join(rootPath, 'pubspec.yaml'));
|
||||
String content = await pubspec.readAsString();
|
||||
content = content.replaceFirst(
|
||||
'\ndependencies:\n',
|
||||
@@ -84,7 +84,7 @@ class FlutterProject {
|
||||
}
|
||||
|
||||
Future<Null> build(String target) async {
|
||||
await inDirectory(new Directory(rootPath), () async {
|
||||
await inDirectory(Directory(rootPath), () async {
|
||||
await flutter('build', options: <String>[target]);
|
||||
});
|
||||
}
|
||||
@@ -99,7 +99,7 @@ class FlutterProject {
|
||||
canFail: true,
|
||||
);
|
||||
// TODO(ianh): Investigating if flakiness is timing dependent.
|
||||
await new Future<Null>.delayed(const Duration(seconds: 10));
|
||||
await Future<Null>.delayed(const Duration(seconds: 10));
|
||||
}
|
||||
rmTree(parent);
|
||||
}
|
||||
|
||||
@@ -44,5 +44,5 @@ Future<TaskResult> samplePageCatalogGenerator(String authorizationToken) async {
|
||||
);
|
||||
});
|
||||
|
||||
return new TaskResult.success(null);
|
||||
return TaskResult.success(null);
|
||||
}
|
||||
|
||||
@@ -42,19 +42,19 @@ class Upload {
|
||||
Duration get timeLimit {
|
||||
if (retryCount == 0)
|
||||
return const Duration(milliseconds: 1000);
|
||||
random ??= new math.Random();
|
||||
return new Duration(milliseconds: random.nextInt(1000) + math.pow(2, retryCount) * 1000);
|
||||
random ??= math.Random();
|
||||
return Duration(milliseconds: random.nextInt(1000) + math.pow(2, retryCount) * 1000);
|
||||
}
|
||||
|
||||
Future<bool> save(HttpClient client, String name, List<int> content) async {
|
||||
try {
|
||||
final Uri uri = new Uri.https(uriAuthority, uriPath, <String, String>{
|
||||
final Uri uri = Uri.https(uriAuthority, uriPath, <String, String>{
|
||||
'uploadType': 'media',
|
||||
'name': name,
|
||||
});
|
||||
final HttpClientRequest request = await client.postUrl(uri);
|
||||
request
|
||||
..headers.contentType = new ContentType('image', 'png')
|
||||
..headers.contentType = ContentType('image', 'png')
|
||||
..headers.add('Authorization', 'Bearer $authorizationToken')
|
||||
..add(content);
|
||||
|
||||
@@ -77,9 +77,9 @@ class Upload {
|
||||
Future<bool> run(HttpClient client) async {
|
||||
assert(!isComplete);
|
||||
if (retryCount > 2)
|
||||
throw new UploadError('upload of "$fromPath" to "$largeName" and "$smallName" failed after 2 retries');
|
||||
throw UploadError('upload of "$fromPath" to "$largeName" and "$smallName" failed after 2 retries');
|
||||
|
||||
largeImage ??= await new File(fromPath).readAsBytes();
|
||||
largeImage ??= await File(fromPath).readAsBytes();
|
||||
smallImage ??= encodePng(copyResize(decodePng(largeImage), 300));
|
||||
|
||||
if (!largeImageSaved)
|
||||
@@ -97,12 +97,12 @@ Future<Null> saveScreenshots(List<String> fromPaths, List<String> largeNames, Li
|
||||
assert(fromPaths.length == largeNames.length);
|
||||
assert(fromPaths.length == smallNames.length);
|
||||
|
||||
List<Upload> uploads = new List<Upload>(fromPaths.length);
|
||||
List<Upload> uploads = List<Upload>(fromPaths.length);
|
||||
for (int index = 0; index < uploads.length; index += 1)
|
||||
uploads[index] = new Upload(fromPaths[index], largeNames[index], smallNames[index]);
|
||||
uploads[index] = Upload(fromPaths[index], largeNames[index], smallNames[index]);
|
||||
|
||||
while (uploads.any(Upload.isNotComplete)) {
|
||||
final HttpClient client = new HttpClient();
|
||||
final HttpClient client = HttpClient();
|
||||
uploads = uploads.where(Upload.isNotComplete).toList();
|
||||
await Future.wait(uploads.map((Upload upload) => upload.run(client)));
|
||||
client.close(force: true);
|
||||
|
||||
@@ -17,7 +17,7 @@ void main() {
|
||||
setUp(() {
|
||||
FakeDevice.resetLog();
|
||||
device = null;
|
||||
device = new FakeDevice();
|
||||
device = FakeDevice();
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
@@ -115,7 +115,7 @@ CommandArgs cmd({
|
||||
List<String> arguments,
|
||||
Map<String, String> environment,
|
||||
}) {
|
||||
return new CommandArgs(
|
||||
return CommandArgs(
|
||||
command: command,
|
||||
arguments: arguments,
|
||||
environment: environment,
|
||||
@@ -183,7 +183,7 @@ class FakeDevice extends AndroidDevice {
|
||||
|
||||
@override
|
||||
Future<String> shellEval(String command, List<String> arguments, { Map<String, String> environment }) async {
|
||||
commandLog.add(new CommandArgs(
|
||||
commandLog.add(CommandArgs(
|
||||
command: command,
|
||||
arguments: arguments,
|
||||
environment: environment,
|
||||
@@ -193,7 +193,7 @@ class FakeDevice extends AndroidDevice {
|
||||
|
||||
@override
|
||||
Future<Null> shellExec(String command, List<String> arguments, { Map<String, String> environment }) async {
|
||||
commandLog.add(new CommandArgs(
|
||||
commandLog.add(CommandArgs(
|
||||
command: command,
|
||||
arguments: arguments,
|
||||
environment: environment,
|
||||
|
||||
@@ -11,4 +11,4 @@ export 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
|
||||
// TODO(ianh): Remove this file once https://github.com/dart-lang/matcher/issues/98 is fixed
|
||||
|
||||
/// A matcher that compares the type of the actual value to the type argument T.
|
||||
Matcher isInstanceOf<T>() => new test_package.TypeMatcher<T>(); // ignore: prefer_const_constructors, https://github.com/dart-lang/sdk/issues/32544
|
||||
Matcher isInstanceOf<T>() => test_package.TypeMatcher<T>(); // ignore: prefer_const_constructors, https://github.com/dart-lang/sdk/issues/32544
|
||||
|
||||
@@ -20,7 +20,7 @@ void main() {
|
||||
expect(task.requiredAgentCapabilities, <String>['linux/android']);
|
||||
|
||||
for (ManifestTask task in manifest.tasks) {
|
||||
final File taskFile = new File('bin/tasks/${task.name}.dart');
|
||||
final File taskFile = File('bin/tasks/${task.name}.dart');
|
||||
expect(taskFile.existsSync(), true,
|
||||
reason: 'File ${taskFile.path} corresponding to manifest task "${task.name}" not found');
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('understands RegExp', () {
|
||||
expect(grep(new RegExp('^b'), from: 'ab\nba'), <String>['ba']);
|
||||
expect(grep(RegExp('^b'), from: 'ab\nba'), <String>['ba']);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user