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 {
final Map<String, String> values = <String, String>{};
void writeContents(File file) {
file.parent.createSync(recursive: true);
file.writeAsStringSync(values.keys.map<String>((String key) {
return '$key=${values[key]}';
}).join('\n'));
......
......@@ -167,11 +167,10 @@ someOtherTask
}
String propertyFor(String key, File file) {
return file
.readAsLinesSync()
final Iterable<String> result = file.readAsLinesSync()
.where((String line) => line.startsWith('$key='))
.map((String line) => line.split('=')[1])
.first;
.map((String line) => line.split('=')[1]);
return result.isEmpty ? null : result.first;
}
Future<void> checkBuildVersion({
......@@ -190,18 +189,15 @@ someOtherTask
// write schemaData otherwise pubspec.yaml file can't be loaded
writeEmptySchemaFile(fs);
try {
updateLocalProperties(
project: await FlutterProject.fromPath('path/to/project'),
buildInfo: buildInfo,
);
updateLocalProperties(
project: await FlutterProject.fromPath('path/to/project'),
buildInfo: buildInfo,
requireAndroidSdk: false,
);
final File localPropertiesFile = fs.file('path/to/project/android/local.properties');
expect(propertyFor('flutter.versionName', localPropertiesFile), expectedBuildName);
expect(propertyFor('flutter.versionCode', localPropertiesFile), expectedBuildNumber);
} on Exception {
// Android SDK not found, skip test
}
final File localPropertiesFile = fs.file('path/to/project/android/local.properties');
expect(propertyFor('flutter.versionName', localPropertiesFile), expectedBuildName);
expect(propertyFor('flutter.versionCode', localPropertiesFile), expectedBuildNumber);
}
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