Skip to content

Commit 20e5931

Browse files
authoredJul 19, 2019
Cherry-picks (#36507)
flutter/engine#9935 Fix backspace crash on Chinese devices #36105 Catch a yaml parse failure during project creation
1 parent 0d4d598 commit 20e5931

File tree

3 files changed

+33
-5
lines changed

3 files changed

+33
-5
lines changed
 

‎bin/internal/engine.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
bb08b06d137a329ed1fa63471d7209c313ebd196
1+
fee001c93f25a1e7258e762781a7361f122d29f5

‎packages/flutter_tools/lib/src/project.dart

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import 'bundle.dart' as bundle;
1515
import 'cache.dart';
1616
import 'desktop.dart';
1717
import 'flutter_manifest.dart';
18+
import 'globals.dart';
1819
import 'ios/ios_workflow.dart';
1920
import 'ios/plist_utils.dart' as plist;
2021
import 'ios/xcodeproj.dart' as xcode;
@@ -164,9 +165,16 @@ class FlutterProject {
164165
/// Completes with an empty [FlutterManifest], if the file does not exist.
165166
/// Completes with a ToolExit on validation error.
166167
static FlutterManifest _readManifest(String path) {
167-
final FlutterManifest manifest = FlutterManifest.createFromPath(path);
168-
if (manifest == null)
168+
FlutterManifest manifest;
169+
try {
170+
manifest = FlutterManifest.createFromPath(path);
171+
} on YamlException catch (e) {
172+
printStatus('Error detected in pubspec.yaml:', emphasis: true);
173+
printError('$e');
174+
}
175+
if (manifest == null) {
169176
throwToolExit('Please correct the pubspec.yaml file at $path');
177+
}
170178
return manifest;
171179
}
172180

‎packages/flutter_tools/test/project_test.dart

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,19 @@ void main() {
4040

4141
expect(
4242
() => FlutterProject.fromDirectory(directory),
43-
throwsA(isInstanceOf<Exception>()),
43+
throwsA(isInstanceOf<ToolExit>()),
44+
);
45+
});
46+
47+
testInMemory('fails on pubspec.yaml parse failure', () async {
48+
final Directory directory = fs.directory('myproject');
49+
directory.childFile('pubspec.yaml')
50+
..createSync(recursive: true)
51+
..writeAsStringSync(parseErrorPubspec);
52+
53+
expect(
54+
() => FlutterProject.fromDirectory(directory),
55+
throwsA(isInstanceOf<ToolExit>()),
4456
);
4557
});
4658

@@ -52,7 +64,7 @@ void main() {
5264

5365
expect(
5466
() => FlutterProject.fromDirectory(directory),
55-
throwsA(isInstanceOf<Exception>()),
67+
throwsA(isInstanceOf<ToolExit>()),
5668
);
5769
});
5870

@@ -575,6 +587,14 @@ flutter:
575587
invalid:
576588
''';
577589

590+
String get parseErrorPubspec => '''
591+
name: hello
592+
# Whitespace is important.
593+
flutter:
594+
something:
595+
something_else:
596+
''';
597+
578598
String projectFileWithBundleId(String id, {String qualifier}) {
579599
return '''
580600
97C147061CF9000F007C117D /* Debug */ = {

0 commit comments

Comments
 (0)
Please sign in to comment.