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(),
|
||||
|
||||
Reference in New Issue
Block a user