Unverified Commit f6c1476f authored by Stanislav Baranov's avatar Stanislav Baranov Committed by GitHub

Fix gradle local.properties tests that were never excersized. (#25484)

These tests were actually failing, but were silently ignored due overly broad exception catching logic.
parent a3dd2eee
...@@ -203,6 +203,7 @@ class SettingsFile { ...@@ -203,6 +203,7 @@ class SettingsFile {
final Map<String, String> values = <String, String>{}; final Map<String, String> values = <String, String>{};
void writeContents(File file) { void writeContents(File file) {
file.parent.createSync(recursive: true);
file.writeAsStringSync(values.keys.map<String>((String key) { file.writeAsStringSync(values.keys.map<String>((String key) {
return '$key=${values[key]}'; return '$key=${values[key]}';
}).join('\n')); }).join('\n'));
......
...@@ -167,11 +167,10 @@ someOtherTask ...@@ -167,11 +167,10 @@ someOtherTask
} }
String propertyFor(String key, File file) { String propertyFor(String key, File file) {
return file final Iterable<String> result = file.readAsLinesSync()
.readAsLinesSync()
.where((String line) => line.startsWith('$key=')) .where((String line) => line.startsWith('$key='))
.map((String line) => line.split('=')[1]) .map((String line) => line.split('=')[1]);
.first; return result.isEmpty ? null : result.first;
} }
Future<void> checkBuildVersion({ Future<void> checkBuildVersion({
...@@ -190,18 +189,15 @@ someOtherTask ...@@ -190,18 +189,15 @@ someOtherTask
// write schemaData otherwise pubspec.yaml file can't be loaded // write schemaData otherwise pubspec.yaml file can't be loaded
writeEmptySchemaFile(fs); writeEmptySchemaFile(fs);
try {
updateLocalProperties( updateLocalProperties(
project: await FlutterProject.fromPath('path/to/project'), project: await FlutterProject.fromPath('path/to/project'),
buildInfo: buildInfo, buildInfo: buildInfo,
requireAndroidSdk: false,
); );
final File localPropertiesFile = fs.file('path/to/project/android/local.properties'); final File localPropertiesFile = fs.file('path/to/project/android/local.properties');
expect(propertyFor('flutter.versionName', localPropertiesFile), expectedBuildName); expect(propertyFor('flutter.versionName', localPropertiesFile), expectedBuildName);
expect(propertyFor('flutter.versionCode', localPropertiesFile), expectedBuildNumber); expect(propertyFor('flutter.versionCode', localPropertiesFile), expectedBuildNumber);
} on Exception {
// Android SDK not found, skip test
}
} }
testUsingAndroidContext('extract build name and number from pubspec.yaml', () async { testUsingAndroidContext('extract build name and number from pubspec.yaml', () async {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment