Revert elimination of Dart 1 (#18460)

fuchsia_tester.dart still assumes Dart 1. Previously, it ran tests directly
from source, flutter_platform.dart automatically runs a kernel compile when
operating in Dart 2 mode, but this assumes a functional Dart SDK is available
in the artifacts directly, and fuchsia_tester.dart mocks out the artifacts
directory with an empty temp dir.

Remaining work is:
1. Get the frontend server building as a dependency on Fuchsia.
2. Patch fuchsia_tester.dart to use a valid Dart SDK and frontend server.

This also reverts migration to Dart 2 typedef syntax.

This reverts commit 6c56bb2. (#18362)
This reverts commit 3daebd0. (#18316)
This commit is contained in:
Chris Bracken
2018-06-13 12:46:39 -07:00
committed by GitHub
parent 210e2fa333
commit 2ae48845a8
171 changed files with 1247 additions and 439 deletions

View File

@@ -175,7 +175,7 @@ class ProcessRunner {
}
}
typedef HttpReader = Future<Uint8List> Function(Uri url, {Map<String, String> headers});
typedef Future<Uint8List> HttpReader(Uri url, {Map<String, String> headers});
/// Creates a pre-populated Flutter archive from a git repo.
class ArchiveCreator {

View File

@@ -8,7 +8,7 @@ import 'dart:io';
import 'package:path/path.dart' as path;
typedef ShardRunner = Future<Null> Function();
typedef Future<Null> ShardRunner();
final String flutterRoot = path.dirname(path.dirname(path.dirname(path.fromUri(Platform.script))));
final String flutter = path.join(flutterRoot, 'bin', Platform.isWindows ? 'flutter.bat' : 'flutter');
@@ -71,8 +71,12 @@ Future<Null> _generateDocs() async {
}
Future<Null> _verifyInternationalizations() async {
final EvalResult genResult = await _evalCommand(dart,
<String>[ '--preview-dart-2', path.join('dev', 'tools', 'gen_localizations.dart'), ],
final EvalResult genResult = await _evalCommand(
dart,
<String>[
'--preview-dart-2',
path.join('dev', 'tools', 'gen_localizations.dart'),
],
workingDirectory: flutterRoot,
);

View File

@@ -150,7 +150,7 @@ class FakeProcess extends Mock implements Process {
}
/// Callback used to receive stdin input when it occurs.
typedef StringReceivedCallback = void Function(String received);
typedef void StringReceivedCallback(String received);
/// A stream consumer class that consumes UTF8 strings as lists of ints.
class StringStreamConsumer implements StreamConsumer<List<int>> {

View File

@@ -32,6 +32,14 @@ void main() async {
return new TaskResult.failure(errorMessage);
}
section('gradlew assembleDebug no-preview-dart-2');
await project.runGradleTask('assembleDebug', options: <String>['-Ppreview-dart-2=false']);
errorMessage = _validateSnapshotDependency(project,
'${project.rootPath}/build/app/intermediates/flutter/debug/snapshot_blob.bin');
if (errorMessage != null) {
return new TaskResult.failure(errorMessage);
}
section('gradlew assembleProfile');
await project.runGradleTask('assembleProfile');

View File

@@ -0,0 +1,12 @@
// Copyright (c) 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:flutter_devicelab/tasks/hot_mode_tests.dart';
import 'package:flutter_devicelab/framework/framework.dart';
Future<Null> main() async {
await task(createHotModeTest(isPreviewDart2: false));
}

View File

@@ -0,0 +1,14 @@
// Copyright (c) 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:flutter_devicelab/tasks/hot_mode_tests.dart';
import 'package:flutter_devicelab/framework/framework.dart';
import 'package:flutter_devicelab/framework/adb.dart';
Future<Null> main() async {
deviceOperatingSystem = DeviceOperatingSystem.ios;
await task(createHotModeTest(isPreviewDart2: false));
}

View File

@@ -20,7 +20,7 @@ const Duration _kDefaultTaskTimeout = const Duration(minutes: 15);
/// Represents a unit of work performed in the CI environment that can
/// succeed, fail and be retried independently of others.
typedef TaskFunction = Future<TaskResult> Function();
typedef Future<TaskResult> TaskFunction();
bool _isTaskRegistered = false;

View File

@@ -15,7 +15,7 @@ const int _kRunsPerBenchmark = 3;
/// Runs a benchmark once and reports the result as a lower-is-better numeric
/// value.
typedef _Benchmark = Future<double> Function();
typedef Future<double> _Benchmark();
/// Path to the generated "mega gallery" app.
Directory get _megaGalleryDirectory => dir(path.join(Directory.systemTemp.path, 'mega_gallery'));

View File

@@ -16,7 +16,7 @@ import '../framework/utils.dart';
final Directory _editedFlutterGalleryDir = dir(path.join(Directory.systemTemp.path, 'edited_flutter_gallery'));
final Directory flutterGalleryDir = dir(path.join(flutterDirectory.path, 'examples/flutter_gallery'));
TaskFunction createHotModeTest() {
TaskFunction createHotModeTest({ bool isPreviewDart2 = true }) {
return () async {
final Device device = await devices.workingDevice;
await device.unlock();
@@ -25,6 +25,10 @@ TaskFunction createHotModeTest() {
final List<String> options = <String>[
'--hot', '-d', device.deviceId, '--benchmark', '--verbose', '--resident'
];
if (isPreviewDart2)
options.add('--preview-dart-2');
else
options.add('--no-preview-dart-2');
setLocalEngineOptionIfNecessary(options);
int hotReloadCount = 0;
Map<String, dynamic> twoReloadsData;
@@ -88,8 +92,8 @@ TaskFunction createHotModeTest() {
}
benchmarkFile.deleteSync();
// start `flutter run` again to make sure it loads from the previous
// state; frontend loads up from previously generated kernel files.
// start `flutter run` again to make sure it loads from the previous state
// (in case of --preview-dart-2 frontend loads up from previously generated kernel files).
{
final Process process = await startProcess(
path.join(flutterDirectory.path, 'bin', 'flutter'),

View File

@@ -23,7 +23,7 @@ TaskFunction createMicrobenchmarkTask() {
final Device device = await devices.workingDevice;
await device.unlock();
Future<Map<String, double>> _runMicrobench(String benchmarkPath) async {
Future<Map<String, double>> _runMicrobench(String benchmarkPath, {bool previewDart2 = true}) async {
Future<Map<String, double>> _run() async {
print('Running $benchmarkPath');
final Directory appDir = dir(
@@ -38,6 +38,10 @@ TaskFunction createMicrobenchmarkTask() {
'-d',
device.deviceId,
];
if (previewDart2)
options.add('--preview-dart-2');
else
options.add('--no-preview-dart-2');
setLocalEngineOptionIfNecessary(options);
options.add(benchmarkPath);
return await _startFlutter(
@@ -57,6 +61,26 @@ TaskFunction createMicrobenchmarkTask() {
allResults.addAll(await _runMicrobench('lib/gestures/velocity_tracker_bench.dart'));
allResults.addAll(await _runMicrobench('lib/stocks/animation_bench.dart'));
// Run micro-benchmarks once again in --no-preview-dart-2 mode.
// Append "_dart1" suffix to the result keys to distinguish them from
// the original results.
void addDart1Results(Map<String, double> benchmarkResults) {
benchmarkResults.forEach((String key, double result) {
allResults[key + '_dart1'] = result;
});
}
addDart1Results(await _runMicrobench(
'lib/stocks/layout_bench.dart', previewDart2: false));
addDart1Results(await _runMicrobench(
'lib/stocks/layout_bench.dart', previewDart2: false));
addDart1Results(await _runMicrobench(
'lib/stocks/build_bench.dart', previewDart2: false));
addDart1Results(await _runMicrobench(
'lib/gestures/velocity_tracker_bench.dart', previewDart2: false));
addDart1Results(await _runMicrobench(
'lib/stocks/animation_bench.dart', previewDart2: false));
return new TaskResult.success(allResults, benchmarkScoreKeys: allResults.keys.toList());
};
}

View File

@@ -205,13 +205,23 @@ class CompileTest {
final Map<String, dynamic> metrics = <String, dynamic>{}
..addAll(await _compileAot())
..addAll(await _compileApp())
..addAll(await _compileDebug());
..addAll(await _compileDebug())
..addAll(_suffix(await _compileAot(previewDart2: false), '__dart1'))
..addAll(_suffix(await _compileApp(previewDart2: false), '__dart1'))
..addAll(_suffix(await _compileDebug(previewDart2: false), '__dart1'));
return new TaskResult.success(metrics, benchmarkScoreKeys: metrics.keys.toList());
});
}
static Future<Map<String, dynamic>> _compileAot() async {
static Map<String, dynamic> _suffix(Map<String, dynamic> map, String suffix) {
return new Map<String, dynamic>.fromIterables(
map.keys.map<String>((String key) => '$key$suffix'),
map.values,
);
}
static Future<Map<String, dynamic>> _compileAot({ bool previewDart2 = true }) async {
// Generate blobs instead of assembly.
await flutter('clean');
final Stopwatch watch = new Stopwatch()..start();
@@ -230,6 +240,10 @@ class CompileTest {
options.add('android-arm');
break;
}
if (previewDart2)
options.add('--preview-dart-2');
else
options.add('--no-preview-dart-2');
setLocalEngineOptionIfNecessary(options);
final String compileLog = await evalFlutter('build', options: options);
watch.stop();
@@ -244,11 +258,15 @@ class CompileTest {
return metrics;
}
static Future<Map<String, dynamic>> _compileApp() async {
static Future<Map<String, dynamic>> _compileApp({ bool previewDart2 = true }) async {
await flutter('clean');
final Stopwatch watch = new Stopwatch();
int releaseSizeInBytes;
final List<String> options = <String>['--release'];
if (previewDart2)
options.add('--preview-dart-2');
else
options.add('--no-preview-dart-2');
setLocalEngineOptionIfNecessary(options);
switch (deviceOperatingSystem) {
case DeviceOperatingSystem.ios:
@@ -281,10 +299,14 @@ class CompileTest {
};
}
static Future<Map<String, dynamic>> _compileDebug() async {
static Future<Map<String, dynamic>> _compileDebug({ bool previewDart2 = true }) async {
await flutter('clean');
final Stopwatch watch = new Stopwatch();
final List<String> options = <String>['--debug'];
if (previewDart2)
options.add('--preview-dart-2');
else
options.add('--no-preview-dart-2');
setLocalEngineOptionIfNecessary(options);
switch (deviceOperatingSystem) {
case DeviceOperatingSystem.ios:

View File

@@ -154,6 +154,21 @@ tasks:
stage: devicelab
required_agent_capabilities: ["mac/android"]
hot_mode_dev_cycle__benchmark_dart1:
description: >
Measures the performance of Dart VM hot patching feature under
--no-preview-dart-2 option, that disables Dart 2.0 frontend.
stage: devicelab
required_agent_capabilities: ["mac/android"]
hot_mode_dev_cycle_ios__benchmark_dart1:
description: >
Measures the performance of Dart VM hot patching feature under
--no-preview-dart-2 option, that disables Dart 2.0 frontend.
stage: devicelab_ios
required_agent_capabilities: ["mac/ios"]
flaky: true
complex_layout_scroll_perf__memory:
description: >
Measures memory usage of the scroll performance test.

View File

@@ -112,7 +112,7 @@ CommandArgs cmd({
);
}
typedef ExitErrorFactory = dynamic Function();
typedef dynamic ExitErrorFactory();
class CommandArgs {
CommandArgs({ this.command, this.arguments, this.environment });

View File

@@ -11,7 +11,7 @@ import 'pair.dart';
enum TestStatus { ok, pending, failed, complete }
typedef TestStep = Future<TestStepResult> Function();
typedef Future<TestStepResult> TestStep();
const String nothing = '-';

View File

@@ -8,7 +8,7 @@ import 'package:flutter/material.dart';
enum TestStatus { ok, pending, failed, complete }
typedef TestStep = Future<TestStepResult> Function();
typedef Future<TestStepResult> TestStep();
const String nothing = '-';

View File

@@ -396,7 +396,7 @@ class _RectangleDemoState extends State<_RectangleDemo> {
}
}
typedef _DemoBuilder = Widget Function(_ArcDemo demo);
typedef Widget _DemoBuilder(_ArcDemo demo);
class _ArcDemo {
_ArcDemo(this.title, this.builder, TickerProvider vsync)

View File

@@ -92,7 +92,7 @@ class OverlayGeometryApp extends StatefulWidget {
OverlayGeometryAppState createState() => new OverlayGeometryAppState();
}
typedef CardTapCallback = void Function(GlobalKey targetKey, Offset globalPosition);
typedef void CardTapCallback(GlobalKey targetKey, Offset globalPosition);
class CardBuilder extends SliverChildDelegate {
CardBuilder({ this.cardModels, this.onTapUp });