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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user