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.
This commit is contained in:
Stanislav Baranov
2018-12-18 10:39:27 -08:00
committed by GitHub
parent a3dd2eee98
commit f6c1476fbb
2 changed files with 12 additions and 15 deletions

View File

@@ -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'));

View File

@@ -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 {