[flutter_tools] ensure build fails if asset files are missing (#54233)

Ensure build fails if asset files are missing and that stderr messages are forwarded through Gradle
This commit is contained in:
Jonah Williams
2020-04-07 19:42:57 -07:00
committed by GitHub
parent 0a25309fb1
commit 981afe39ae
5 changed files with 54 additions and 1 deletions

View File

@@ -190,6 +190,19 @@ Future<void> main() async {
result);
});
await runProjectTest((FlutterProject project) async {
section('gradlew assembleDebug forwards stderr');
await project.introducePubspecError();
final ProcessResult result =
await project.resultOfGradleTask('assembleRelease');
if (result.exitCode == 0)
throw failure(
'Gradle did not exit with error as expected', result);
final String output = '${result.stdout}\n${result.stderr}';
if (!output.contains('No file or variants found for asset: lib/gallery/example_code.dart.'))
throw failure(output, result);
});
await runProjectTest((FlutterProject project) async {
section('flutter build apk on build script with error');
await project.introduceError();

View File

@@ -299,6 +299,20 @@ android {
await buildScript.writeAsString((await buildScript.readAsString()).replaceAll('buildTypes', 'builTypes'));
}
Future<void> introducePubspecError() async {
final File pubspec = File(
path.join(parent.path, 'hello', 'pubspec.yaml')
);
final String contents = pubspec.readAsStringSync();
final String newContents = contents.replaceFirst('# The following section is specific to Flutter.\nflutter:\n', '''
flutter:
assets:
- lib/gallery/example_code.dart
''');
pubspec.writeAsStringSync(newContents);
}
Future<void> runGradleTask(String task, {List<String> options}) async {
return _runGradleTask(workingDirectory: androidPath, task: task, options: options);
}