Revert "It's time to #deleteDart1 (#18293)" (#18313)

Several benchmarks started failing during kernel compile:
1. Timeouts:
   * commands_test
   * hot_mode_dev_cycle__benchmark
   * run_machine_concurrent_hot_reload
   * service_extensions_test

2. Kernel compiler crash:
   * hot_mode_dev_cycle_linux__benchmark
   * routing_test

3. Unexpected termination:
   * hot_mode_dev_cycle_win__benchmark

This reverts commit ed63e7082a.
This commit is contained in:
Chris Bracken
2018-06-08 12:43:11 -07:00
committed by GitHub
parent ed63e7082a
commit 9495df4bc3
45 changed files with 873 additions and 220 deletions

View File

@@ -3,6 +3,7 @@
// found in the LICENSE file.
import 'dart:async';
import 'dart:convert' show json;
import 'package:file/memory.dart';
import 'package:flutter_tools/src/android/android_sdk.dart';
@@ -84,6 +85,199 @@ void main() {
});
});
group('Snapshotter - Script Snapshots', () {
const String kVersion = '123456abcdef';
const String kIsolateSnapshotData = 'isolate_snapshot.bin';
const String kVmSnapshotData = 'vm_isolate_snapshot.bin';
_FakeGenSnapshot genSnapshot;
MemoryFileSystem fs;
MockFlutterVersion mockVersion;
ScriptSnapshotter snapshotter;
MockArtifacts mockArtifacts;
setUp(() {
fs = new MemoryFileSystem();
fs.file(kIsolateSnapshotData).writeAsStringSync('snapshot data');
fs.file(kVmSnapshotData).writeAsStringSync('vm data');
genSnapshot = new _FakeGenSnapshot();
genSnapshot.outputs = <String, String>{
'output.snapshot': '',
'output.snapshot.d': 'output.snapshot.d : main.dart',
};
mockVersion = new MockFlutterVersion();
when(mockVersion.frameworkRevision).thenReturn(kVersion);
snapshotter = new ScriptSnapshotter();
mockArtifacts = new MockArtifacts();
when(mockArtifacts.getArtifactPath(Artifact.isolateSnapshotData)).thenReturn(kIsolateSnapshotData);
when(mockArtifacts.getArtifactPath(Artifact.vmSnapshotData)).thenReturn(kVmSnapshotData);
});
final Map<Type, Generator> contextOverrides = <Type, Generator>{
Artifacts: () => mockArtifacts,
FileSystem: () => fs,
FlutterVersion: () => mockVersion,
GenSnapshot: () => genSnapshot,
};
Future<void> writeFingerprint({ Map<String, String> files = const <String, String>{} }) {
return fs.file('output.snapshot.d.fingerprint').writeAsString(json.encode(<String, dynamic>{
'version': kVersion,
'properties': <String, String>{
'buildMode': BuildMode.debug.toString(),
'targetPlatform': '',
'entryPoint': 'main.dart',
},
'files': <String, dynamic>{
kVmSnapshotData: '2ec34912477a46c03ddef07e8b909b46',
kIsolateSnapshotData: '621b3844bb7d4d17d2cfc5edf9a91c4c',
}..addAll(files),
}));
}
void expectFingerprintHas({
String entryPoint = 'main.dart',
Map<String, String> checksums = const <String, String>{},
}) {
final Map<String, dynamic> jsonObject = json.decode(fs.file('output.snapshot.d.fingerprint').readAsStringSync());
expect(jsonObject['properties']['entryPoint'], entryPoint);
expect(jsonObject['files'], hasLength(checksums.length + 2));
checksums.forEach((String filePath, String checksum) {
expect(jsonObject['files'][filePath], checksum);
});
expect(jsonObject['files'][kVmSnapshotData], '2ec34912477a46c03ddef07e8b909b46');
expect(jsonObject['files'][kIsolateSnapshotData], '621b3844bb7d4d17d2cfc5edf9a91c4c');
}
testUsingContext('builds snapshot and fingerprint when no fingerprint is present', () async {
await fs.file('main.dart').writeAsString('void main() {}');
await fs.file('output.snapshot').create();
await fs.file('output.snapshot.d').writeAsString('snapshot : main.dart');
await snapshotter.build(
mainPath: 'main.dart',
snapshotPath: 'output.snapshot',
depfilePath: 'output.snapshot.d',
packagesPath: '.packages',
);
expect(genSnapshot.callCount, 1);
expect(genSnapshot.snapshotType.platform, isNull);
expect(genSnapshot.snapshotType.mode, BuildMode.debug);
expect(genSnapshot.packagesPath, '.packages');
expect(genSnapshot.depfilePath, 'output.snapshot.d');
expect(genSnapshot.additionalArgs, <String>[
'--snapshot_kind=script',
'--script_snapshot=output.snapshot',
'--vm_snapshot_data=vm_isolate_snapshot.bin',
'--isolate_snapshot_data=isolate_snapshot.bin',
'--enable-mirrors=false',
'main.dart',
]);
expectFingerprintHas(checksums: <String, String>{
'main.dart': '27f5ebf0f8c559b2af9419d190299a5e',
'output.snapshot': 'd41d8cd98f00b204e9800998ecf8427e',
});
}, overrides: contextOverrides);
testUsingContext('builds snapshot and fingerprint when fingerprints differ', () async {
await fs.file('main.dart').writeAsString('void main() {}');
await fs.file('output.snapshot').create();
await fs.file('output.snapshot.d').writeAsString('output.snapshot : main.dart');
await writeFingerprint(files: <String, String>{
'main.dart': '27f5ebf0f8c559b2af9419d190299a5e',
'output.snapshot': 'deadbeef000b204e9800998ecaaaaa',
});
await snapshotter.build(
mainPath: 'main.dart',
snapshotPath: 'output.snapshot',
depfilePath: 'output.snapshot.d',
packagesPath: '.packages',
);
expect(genSnapshot.callCount, 1);
expectFingerprintHas(checksums: <String, String>{
'main.dart': '27f5ebf0f8c559b2af9419d190299a5e',
'output.snapshot': 'd41d8cd98f00b204e9800998ecf8427e',
});
}, overrides: contextOverrides);
testUsingContext('builds snapshot and fingerprint when fingerprints match but previous snapshot not present', () async {
await fs.file('main.dart').writeAsString('void main() {}');
await fs.file('output.snapshot.d').writeAsString('output.snapshot : main.dart');
await writeFingerprint(files: <String, String>{
'main.dart': '27f5ebf0f8c559b2af9419d190299a5e',
'output.snapshot': 'd41d8cd98f00b204e9800998ecf8427e',
});
await snapshotter.build(
mainPath: 'main.dart',
snapshotPath: 'output.snapshot',
depfilePath: 'output.snapshot.d',
packagesPath: '.packages',
);
expect(genSnapshot.callCount, 1);
expectFingerprintHas(checksums: <String, String>{
'main.dart': '27f5ebf0f8c559b2af9419d190299a5e',
'output.snapshot': 'd41d8cd98f00b204e9800998ecf8427e',
});
}, overrides: contextOverrides);
testUsingContext('builds snapshot and fingerprint when main entry point changes to other dependency', () async {
await fs.file('main.dart').writeAsString('import "other.dart";\nvoid main() {}');
await fs.file('other.dart').writeAsString('import "main.dart";\nvoid main() {}');
await fs.file('output.snapshot').create();
await fs.file('output.snapshot.d').writeAsString('output.snapshot : main.dart');
await writeFingerprint(files: <String, String>{
'main.dart': 'bc096b33f14dde5e0ffaf93a1d03395c',
'other.dart': 'e0c35f083f0ad76b2d87100ec678b516',
'output.snapshot': 'd41d8cd98f00b204e9800998ecf8427e',
});
genSnapshot.outputs = <String, String>{
'output.snapshot': '',
'output.snapshot.d': 'output.snapshot : main.dart other.dart',
};
await snapshotter.build(
mainPath: 'other.dart',
snapshotPath: 'output.snapshot',
depfilePath: 'output.snapshot.d',
packagesPath: '.packages',
);
expect(genSnapshot.callCount, 1);
expectFingerprintHas(
entryPoint: 'other.dart',
checksums: <String, String>{
'main.dart': 'bc096b33f14dde5e0ffaf93a1d03395c',
'other.dart': 'e0c35f083f0ad76b2d87100ec678b516',
'output.snapshot': 'd41d8cd98f00b204e9800998ecf8427e',
},
);
}, overrides: contextOverrides);
testUsingContext('skips snapshot when fingerprints match and previous snapshot is present', () async {
await fs.file('main.dart').writeAsString('void main() {}');
await fs.file('output.snapshot').create();
await fs.file('output.snapshot.d').writeAsString('output.snapshot : main.dart');
await writeFingerprint(files: <String, String>{
'main.dart': '27f5ebf0f8c559b2af9419d190299a5e',
'output.snapshot': 'd41d8cd98f00b204e9800998ecf8427e',
});
await snapshotter.build(
mainPath: 'main.dart',
snapshotPath: 'output.snapshot',
depfilePath: 'output.snapshot.d',
packagesPath: '.packages',
);
expect(genSnapshot.callCount, 0);
expectFingerprintHas(checksums: <String, String>{
'main.dart': '27f5ebf0f8c559b2af9419d190299a5e',
'output.snapshot': 'd41d8cd98f00b204e9800998ecf8427e',
});
}, overrides: contextOverrides);
});
group('Snapshotter - iOS AOT', () {
const String kVmEntrypoints = 'dart_vm_entry_points.txt';
const String kIoEntries = 'dart_io_entries.txt';
@@ -146,6 +340,7 @@ void main() {
packagesPath: '.packages',
outputPath: outputPath,
buildSharedLibrary: false,
previewDart2: true,
), isNot(equals(0)));
}, overrides: contextOverrides);
@@ -158,6 +353,7 @@ void main() {
packagesPath: '.packages',
outputPath: outputPath,
buildSharedLibrary: false,
previewDart2: true,
), isNot(0));
}, overrides: contextOverrides);
@@ -170,6 +366,7 @@ void main() {
packagesPath: '.packages',
outputPath: outputPath,
buildSharedLibrary: false,
previewDart2: true,
), isNot(0));
}, overrides: contextOverrides);
@@ -195,6 +392,7 @@ void main() {
packagesPath: '.packages',
outputPath: outputPath,
buildSharedLibrary: false,
previewDart2: true,
iosArch: IOSArch.armv7,
);
@@ -241,6 +439,7 @@ void main() {
packagesPath: '.packages',
outputPath: outputPath,
buildSharedLibrary: false,
previewDart2: true,
iosArch: IOSArch.arm64,
);
@@ -288,6 +487,7 @@ void main() {
packagesPath: '.packages',
outputPath: outputPath,
buildSharedLibrary: false,
previewDart2: true,
);
expect(genSnapshotExitCode, 0);
@@ -339,6 +539,7 @@ void main() {
packagesPath: '.packages',
outputPath: outputPath,
buildSharedLibrary: false,
previewDart2: true,
);
expect(genSnapshotExitCode, 0);
@@ -385,6 +586,7 @@ void main() {
packagesPath: '.packages',
outputPath: outputPath,
buildSharedLibrary: false,
previewDart2: true,
iosArch: IOSArch.armv7,
);
@@ -431,6 +633,7 @@ void main() {
packagesPath: '.packages',
outputPath: outputPath,
buildSharedLibrary: false,
previewDart2: true,
iosArch: IOSArch.arm64,
);
@@ -465,6 +668,7 @@ void main() {
packagesPath: '.packages',
outputPath: outputPath,
buildSharedLibrary: true,
previewDart2: true,
);
expect(genSnapshotExitCode, isNot(0));
@@ -496,6 +700,7 @@ void main() {
packagesPath: '.packages',
outputPath: outputPath,
buildSharedLibrary: false,
previewDart2: true,
);
expect(genSnapshotExitCode, 0);
@@ -547,6 +752,7 @@ void main() {
packagesPath: '.packages',
outputPath: outputPath,
buildSharedLibrary: false,
previewDart2: true,
);
expect(genSnapshotExitCode, 0);

View File

@@ -70,10 +70,10 @@ void main() {
OperatingSystemUtils: () => os
});
testUsingContext('Returns no errors when source is error-free', () async {
testUsingContext('--preview-dart-2', () async {
const String contents = "StringBuffer bar = StringBuffer('baz');";
tempDir.childFile('main.dart').writeAsStringSync(contents);
server = new AnalysisServer(dartSdkPath, <String>[tempDir.path]);
server = new AnalysisServer(dartSdkPath, <String>[tempDir.path], previewDart2: true);
int errorCount = 0;
final Future<bool> onDone = server.onAnalyzing.where((bool analyzing) => analyzing == false).first;
@@ -88,6 +88,25 @@ void main() {
}, overrides: <Type, Generator>{
OperatingSystemUtils: () => os
});
testUsingContext('no --preview-dart-2 shows errors', () async {
const String contents = "StringBuffer bar = StringBuffer('baz');";
tempDir.childFile('main.dart').writeAsStringSync(contents);
server = new AnalysisServer(dartSdkPath, <String>[tempDir.path], previewDart2: false);
int errorCount = 0;
final Future<bool> onDone = server.onAnalyzing.where((bool analyzing) => analyzing == false).first;
server.onErrors.listen((FileAnalysisErrors errors) {
errorCount += errors.errors.length;
});
await server.start();
await onDone;
expect(errorCount, 1);
}, overrides: <Type, Generator>{
OperatingSystemUtils: () => os
});
}
void _createSampleProject(Directory directory, { bool brokenCode = false }) {

View File

@@ -168,7 +168,7 @@ void bar() {
}
});
testUsingContext('returns no issues when source is error-free', () async {
testUsingContext('--preview-dart-2', () async {
const String contents = '''
StringBuffer bar = StringBuffer('baz');
''';
@@ -179,13 +179,33 @@ StringBuffer bar = StringBuffer('baz');
try {
await runCommand(
command: new AnalyzeCommand(workingDirectory: fs.directory(tempDir)),
arguments: <String>['analyze'],
arguments: <String>['analyze', '--preview-dart-2'],
statusTextContains: <String>['No issues found!'],
);
} finally {
tempDir.deleteSync(recursive: true);
}
});
testUsingContext('no --preview-dart-2 shows errors', () async {
const String contents = '''
StringBuffer bar = StringBuffer('baz');
''';
final Directory tempDir = fs.systemTempDirectory.createTempSync();
tempDir.childFile('main.dart').writeAsStringSync(contents);
try {
await runCommand(
command: new AnalyzeCommand(workingDirectory: fs.directory(tempDir)),
arguments: <String>['analyze', '--no-preview-dart-2'],
statusTextContains: <String>['1 issue found.'],
toolExit: true,
);
} finally {
tempDir.deleteSync(recursive: true);
}
});
});
}

View File

@@ -54,7 +54,7 @@ void main() {
appStarter = (DriveCommand command) {
throw 'Unexpected call to appStarter';
};
testRunner = (List<String> testArgs, String observatoryUri) {
testRunner = (List<String> testArgs, String observatoryUri, bool previewDart2) {
throw 'Unexpected call to testRunner';
};
appStopper = (DriveCommand command) {
@@ -169,7 +169,7 @@ void main() {
appStarter = expectAsync1((DriveCommand command) async {
return new LaunchResult.succeeded();
});
testRunner = expectAsync2((List<String> testArgs, String observatoryUri) async {
testRunner = expectAsync3((List<String> testArgs, String observatoryUri, bool previewDart2) async {
expect(testArgs, <String>[testFile]);
return null;
});
@@ -200,7 +200,7 @@ void main() {
appStarter = expectAsync1((DriveCommand command) async {
return new LaunchResult.succeeded();
});
testRunner = (List<String> testArgs, String observatoryUri) async {
testRunner = (List<String> testArgs, String observatoryUri, bool previewDart2) async {
throwToolExit(null, exitCode: 123);
};
appStopper = expectAsync1((DriveCommand command) async {

View File

@@ -11,7 +11,6 @@ import 'package:flutter_tools/src/asset.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/compile.dart';
import 'package:flutter_tools/src/devfs.dart';
import 'package:flutter_tools/src/vmservice.dart';
import 'package:json_rpc_2/json_rpc_2.dart' as rpc;
@@ -68,7 +67,6 @@ void main() {
group('devfs local', () {
final MockDevFSOperations devFSOperations = new MockDevFSOperations();
final MockResidentCompiler residentCompiler = new MockResidentCompiler();
setUpAll(() {
tempDir = _newTempDir(fs);
@@ -91,13 +89,22 @@ void main() {
devFSOperations.expectMessages(<String>['create test']);
expect(devFS.assetPathsToEvict, isEmpty);
final int bytes = await devFS.update(mainPath: 'lib/foo.txt', generator: residentCompiler);
final int bytes = await devFS.update();
devFSOperations.expectMessages(<String>[
'writeFile test lib/foo.txt.dill',
'writeFile test .packages',
'writeFile test lib/foo.txt',
'writeFile test packages/somepkg/somefile.txt',
]);
expect(devFS.assetPathsToEvict, isEmpty);
expect(bytes, 22);
final List<String> packageSpecOnDevice = LineSplitter.split(utf8.decode(
await devFSOperations.devicePathToContent[fs.path.toUri('.packages')].contentsAsBytes()
)).toList();
expect(packageSpecOnDevice,
unorderedEquals(<String>['my_project:lib/', 'somepkg:packages/somepkg/'])
);
expect(bytes, 48);
}, overrides: <Type, Generator>{
FileSystem: () => fs,
});
@@ -106,33 +113,48 @@ void main() {
final File file = fs.file(fs.path.join(basePath, filePath2));
await file.parent.create(recursive: true);
file.writeAsBytesSync(<int>[1, 2, 3, 4, 5, 6, 7]);
final int bytes = await devFS.update(mainPath: 'lib/foo.txt', generator: residentCompiler);
final int bytes = await devFS.update();
devFSOperations.expectMessages(<String>[
'writeFile test lib/foo.txt.dill',
'writeFile test foo/bar.txt',
]);
expect(devFS.assetPathsToEvict, isEmpty);
expect(bytes, 22);
expect(bytes, 7);
}, overrides: <Type, Generator>{
FileSystem: () => fs,
});
testUsingContext('add new file to local file system and preserve unusual file name casing', () async {
final String filePathWithUnusualCasing = fs.path.join('FooBar', 'TEST.txt');
final File file = fs.file(fs.path.join(basePath, filePathWithUnusualCasing));
await file.parent.create(recursive: true);
file.writeAsBytesSync(<int>[1, 2, 3, 4, 5, 6, 7]);
final int bytes = await devFS.update();
devFSOperations.expectMessages(<String>[
'writeFile test FooBar/TEST.txt',
]);
expect(devFS.assetPathsToEvict, isEmpty);
expect(bytes, 7);
}, overrides: <Type, Generator>{
FileSystem: () => fs,
});
testUsingContext('modify existing file on local file system', () async {
await devFS.update(mainPath: 'lib/foo.txt', generator: residentCompiler);
await devFS.update();
final File file = fs.file(fs.path.join(basePath, filePath));
// Set the last modified time to 5 seconds in the past.
updateFileModificationTime(file.path, new DateTime.now(), -5);
int bytes = await devFS.update(mainPath: 'lib/foo.txt', generator: residentCompiler);
int bytes = await devFS.update();
devFSOperations.expectMessages(<String>[]);
expect(devFS.assetPathsToEvict, isEmpty);
expect(bytes, 0);
await file.writeAsBytes(<int>[1, 2, 3, 4, 5, 6]);
bytes = await devFS.update(mainPath: 'lib/foo.txt', generator: residentCompiler);
bytes = await devFS.update();
devFSOperations.expectMessages(<String>[
'writeFile test lib/foo.txt.dill',
'writeFile test lib/foo.txt',
]);
expect(devFS.assetPathsToEvict, isEmpty);
expect(bytes, 22);
expect(bytes, 6);
}, overrides: <Type, Generator>{
FileSystem: () => fs,
});
@@ -140,7 +162,7 @@ void main() {
testUsingContext('delete a file from the local file system', () async {
final File file = fs.file(fs.path.join(basePath, filePath));
await file.delete();
final int bytes = await devFS.update(mainPath: 'lib/foo.txt', generator: residentCompiler);
final int bytes = await devFS.update();
devFSOperations.expectMessages(<String>[
'deleteFile test lib/foo.txt',
]);
@@ -152,12 +174,13 @@ void main() {
testUsingContext('add new package', () async {
await _createPackage(fs, 'newpkg', 'anotherfile.txt');
final int bytes = await devFS.update(mainPath: 'lib/foo.txt', generator: residentCompiler);
final int bytes = await devFS.update();
devFSOperations.expectMessages(<String>[
'writeFile test lib/foo.txt.dill',
'writeFile test .packages',
'writeFile test packages/newpkg/anotherfile.txt',
]);
expect(devFS.assetPathsToEvict, isEmpty);
expect(bytes, 22);
expect(bytes, 69);
}, overrides: <Type, Generator>{
FileSystem: () => fs,
});
@@ -178,65 +201,63 @@ void main() {
.map((FileSystemEntity file) => canonicalizePath(file.path))
.toList());
}
final int bytes = await devFS.update(mainPath: 'lib/foo.txt', fileFilter: fileFilter, generator: residentCompiler);
final int bytes = await devFS.update(fileFilter: fileFilter);
devFSOperations.expectMessages(<String>[
'writeFile test lib/foo.txt.dill',
'writeFile test .packages',
'writeFile test packages/doubleslashpkg/somefile.txt',
]);
expect(devFS.assetPathsToEvict, isEmpty);
expect(bytes, 22);
expect(bytes, 109);
}, overrides: <Type, Generator>{
FileSystem: () => fs,
});
testUsingContext('add an asset bundle', () async {
assetBundle.entries['a.txt'] = new DevFSStringContent('abc');
final int bytes = await devFS.update(mainPath: 'lib/foo.txt', bundle: assetBundle, bundleDirty: true, generator: residentCompiler);
final int bytes = await devFS.update(bundle: assetBundle, bundleDirty: true);
devFSOperations.expectMessages(<String>[
'writeFile test lib/foo.txt.dill',
'writeFile test ${_inAssetBuildDirectory(fs, 'a.txt')}',
]);
expect(devFS.assetPathsToEvict, unorderedMatches(<String>['a.txt']));
devFS.assetPathsToEvict.clear();
expect(bytes, 22 + 3);
expect(bytes, 3);
}, overrides: <Type, Generator>{
FileSystem: () => fs,
});
testUsingContext('add a file to the asset bundle - bundleDirty', () async {
assetBundle.entries['b.txt'] = new DevFSStringContent('abcd');
final int bytes = await devFS.update(mainPath: 'lib/foo.txt', bundle: assetBundle, bundleDirty: true, generator: residentCompiler);
final int bytes = await devFS.update(bundle: assetBundle, bundleDirty: true);
// Expect entire asset bundle written because bundleDirty is true
devFSOperations.expectMessages(<String>[
'writeFile test lib/foo.txt.dill',
'writeFile test ${_inAssetBuildDirectory(fs, 'a.txt')}',
'writeFile test ${_inAssetBuildDirectory(fs, 'b.txt')}',
]);
expect(devFS.assetPathsToEvict, unorderedMatches(<String>[
'a.txt', 'b.txt']));
devFS.assetPathsToEvict.clear();
expect(bytes, 22 + 7);
expect(bytes, 7);
}, overrides: <Type, Generator>{
FileSystem: () => fs,
});
testUsingContext('add a file to the asset bundle', () async {
assetBundle.entries['c.txt'] = new DevFSStringContent('12');
final int bytes = await devFS.update(mainPath: 'lib/foo.txt', bundle: assetBundle, generator: residentCompiler);
final int bytes = await devFS.update(bundle: assetBundle);
devFSOperations.expectMessages(<String>[
'writeFile test lib/foo.txt.dill',
'writeFile test ${_inAssetBuildDirectory(fs, 'c.txt')}',
]);
expect(devFS.assetPathsToEvict, unorderedMatches(<String>[
'c.txt']));
devFS.assetPathsToEvict.clear();
expect(bytes, 22 + 2);
expect(bytes, 2);
}, overrides: <Type, Generator>{
FileSystem: () => fs,
});
testUsingContext('delete a file from the asset bundle', () async {
assetBundle.entries.remove('c.txt');
final int bytes = await devFS.update(mainPath: 'lib/foo.txt', bundle: assetBundle, generator: residentCompiler);
final int bytes = await devFS.update(bundle: assetBundle);
devFSOperations.expectMessages(<String>[
'deleteFile test ${_inAssetBuildDirectory(fs, 'c.txt')}',
]);
@@ -249,7 +270,7 @@ void main() {
testUsingContext('delete all files from the asset bundle', () async {
assetBundle.entries.clear();
final int bytes = await devFS.update(mainPath: 'lib/foo.txt', bundle: assetBundle, bundleDirty: true, generator: residentCompiler);
final int bytes = await devFS.update(bundle: assetBundle, bundleDirty: true);
devFSOperations.expectMessages(<String>[
'deleteFile test ${_inAssetBuildDirectory(fs, 'a.txt')}',
'deleteFile test ${_inAssetBuildDirectory(fs, 'b.txt')}',
@@ -274,7 +295,6 @@ void main() {
group('devfs remote', () {
MockVMService vmService;
final MockResidentCompiler residentCompiler = new MockResidentCompiler();
setUpAll(() async {
tempDir = _newTempDir(fs);
@@ -301,12 +321,14 @@ void main() {
vmService.expectMessages(<String>['create test']);
expect(devFS.assetPathsToEvict, isEmpty);
final int bytes = await devFS.update(mainPath: 'lib/foo.txt', generator: residentCompiler);
final int bytes = await devFS.update();
vmService.expectMessages(<String>[
'writeFile test lib/foo.txt.dill',
'writeFile test .packages',
'writeFile test lib/foo.txt',
'writeFile test packages/somepkg/somefile.txt',
]);
expect(devFS.assetPathsToEvict, isEmpty);
expect(bytes, 22);
expect(bytes, 48);
}, overrides: <Type, Generator>{
FileSystem: () => fs,
});
@@ -349,38 +371,6 @@ void main() {
});
}
class MockResidentCompiler extends BasicMock implements ResidentCompiler {
@override
void accept() {}
@override
void reject() {}
@override
void reset() {}
@override
Future<dynamic> shutdown() async {}
@override
Future<CompilerOutput> compileExpression(
String expression,
List<String> definitions,
List<String> typeDefinitions,
String libraryUri,
String klass,
bool isStatic
) async {
return null;
}
@override
Future<CompilerOutput> recompile(String mainPath, List<String> invalidatedFiles, {String outputPath, String packagesFilePath}) async {
fs.file(outputPath).createSync(recursive: true);
fs.file(outputPath).writeAsStringSync('compiled_kernel_output');
return new CompilerOutput(outputPath, 0);
}
}
class MockVMService extends BasicMock implements VMService {
Uri _httpAddress;
HttpServer _server;

View File

@@ -284,10 +284,14 @@ Information about project "Runner":
testUsingOsxContext('sets ARCHS=armv7 when armv7 local engine is set', () async {
when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, typed(any))).thenReturn('engine');
when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile_arm'));
const BuildInfo buildInfo = const BuildInfo(BuildMode.debug, null, targetPlatform: TargetPlatform.ios);
const BuildInfo buildInfo = const BuildInfo(BuildMode.debug, null,
previewDart2: true,
targetPlatform: TargetPlatform.ios,
);
await updateGeneratedXcodeProperties(
projectPath: 'path/to/project',
buildInfo: buildInfo,
previewDart2: true,
);
final File config = fs.file('path/to/project/ios/Flutter/Generated.xcconfig');
@@ -301,12 +305,14 @@ Information about project "Runner":
when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, typed(any))).thenReturn('engine');
when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile_arm'));
const BuildInfo buildInfo = const BuildInfo(BuildMode.debug, null,
previewDart2: true,
trackWidgetCreation: true,
targetPlatform: TargetPlatform.ios,
);
await updateGeneratedXcodeProperties(
projectPath: 'path/to/project',
buildInfo: buildInfo,
previewDart2: true,
);
final File config = fs.file('path/to/project/ios/Flutter/Generated.xcconfig');
@@ -319,10 +325,14 @@ Information about project "Runner":
testUsingOsxContext('does not set TRACK_WIDGET_CREATION when trackWidgetCreation is false', () async {
when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, typed(any))).thenReturn('engine');
when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile_arm'));
const BuildInfo buildInfo = const BuildInfo(BuildMode.debug, null, targetPlatform: TargetPlatform.ios);
const BuildInfo buildInfo = const BuildInfo(BuildMode.debug, null,
previewDart2: true,
targetPlatform: TargetPlatform.ios,
);
await updateGeneratedXcodeProperties(
projectPath: 'path/to/project',
buildInfo: buildInfo,
previewDart2: true,
);
final File config = fs.file('path/to/project/ios/Flutter/Generated.xcconfig');
@@ -335,10 +345,14 @@ Information about project "Runner":
testUsingOsxContext('sets ARCHS=armv7 when armv7 local engine is set', () async {
when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, typed(any))).thenReturn('engine');
when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile'));
const BuildInfo buildInfo = const BuildInfo(BuildMode.debug, null, targetPlatform: TargetPlatform.ios);
const BuildInfo buildInfo = const BuildInfo(BuildMode.debug, null,
previewDart2: true,
targetPlatform: TargetPlatform.ios,
);
await updateGeneratedXcodeProperties(
projectPath: 'path/to/project',
buildInfo: buildInfo,
previewDart2: true,
);
final File config = fs.file('path/to/project/ios/Flutter/Generated.xcconfig');
@@ -391,6 +405,7 @@ Information about project "Runner":
projectPath: projectPath,
buildInfo: buildInfo,
targetOverride: bundle.defaultMainPath,
previewDart2: false,
);
final String propertiesPath = fs.path.join(projectPath, 'ios', 'Flutter', 'Generated.xcconfig');

View File

@@ -44,11 +44,14 @@ class TestRunner extends ResidentRunner {
void main() {
TestRunner createTestRunner() {
// TODO(jacobr): make these tests run with `trackWidgetCreation: true` as
// well as the default flags.
// TODO(jacobr): make these tests run with `previewDart2: true` and
// `trackWidgetCreation: true` as well as the default flags.
// Currently the TestRunner is not properly configured to be able to run
// with `previewDart2: true` due to missing resources.
return new TestRunner(
<FlutterDevice>[new FlutterDevice(
new MockDevice(),
previewDart2: false,
trackWidgetCreation: false,
)],
);

View File

@@ -6,14 +6,11 @@ import 'dart:async';
import 'package:file/file.dart';
import 'package:file/memory.dart';
import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/compile.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/tester/flutter_tester.dart';
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
import 'package:test/test.dart';
@@ -100,8 +97,6 @@ void main() {
String projectPath;
String mainPath;
MockArtifacts mockArtifacts;
MockKernelCompiler mockKernelCompiler;
MockProcessManager mockProcessManager;
MockProcess mockProcess;
@@ -110,8 +105,6 @@ void main() {
FileSystem: () => fs,
Cache: () => new Cache(rootOverride: fs.directory(flutterRoot)),
ProcessManager: () => mockProcessManager,
KernelCompiler: () => mockKernelCompiler,
Artifacts: () => mockArtifacts,
};
setUp(() {
@@ -129,13 +122,6 @@ void main() {
mockProcessManager = new MockProcessManager();
mockProcessManager.processFactory =
(List<String> commands) => mockProcess;
mockArtifacts = new MockArtifacts();
final String artifactPath = fs.path.join(flutterRoot, 'artifact');
fs.file(artifactPath).createSync(recursive: true);
when(mockArtifacts.getArtifactPath(any)).thenReturn(artifactPath);
mockKernelCompiler = new MockKernelCompiler();
});
testUsingContext('not debug', () async {
@@ -167,22 +153,6 @@ Hello!
.codeUnits
]));
when(mockKernelCompiler.compile(
sdkRoot: any,
incrementalCompilerByteStorePath: any,
mainPath: any,
outputFilePath: any,
depFilePath: any,
trackWidgetCreation: any,
extraFrontEndOptions: any,
fileSystemRoots: any,
fileSystemScheme: any,
packagesPath: any,
)).thenAnswer((_) async {
fs.file('$mainPath.dill').createSync(recursive: true);
return new CompilerOutput('$mainPath.dill', 0);
});
final LaunchResult result = await device.startApp(null,
mainPath: mainPath,
debuggingOptions: new DebuggingOptions.enabled(
@@ -195,6 +165,3 @@ Hello!
});
});
}
class MockArtifacts extends Mock implements Artifacts {}
class MockKernelCompiler extends Mock implements KernelCompiler {}