Unverified Commit 50da3bd0 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

check if libimobiledevice executables exist (#43767)

parent 28a214ba
......@@ -1103,6 +1103,17 @@ class IosUsbArtifacts extends CachedArtifact {
'libzip',
];
// For unknown reasons, users are getting into bad states where libimobiledevice is
// downloaded but some executables are missing from the zip. The names here are
// used for additional download checks below, so we can redownload if they are
// missing.
static const Map<String, List<String>> _kExecutables = <String, List<String>>{
'libimobiledevice': <String>[
'idevice_id',
'ideviceinfo',
],
};
@override
Map<String, String> get environment {
return <String, String>{
......@@ -1110,11 +1121,28 @@ class IosUsbArtifacts extends CachedArtifact {
};
}
@override
bool isUpToDateInner() {
final List<String> executables =_kExecutables[name];
if (executables == null) {
return true;
}
for (String executable in executables) {
if (!location.childFile(executable).existsSync()) {
return false;
}
}
return true;
}
@override
Future<void> updateInner() {
if (!platform.isMacOS && !cache.includeAllPlatforms) {
return Future<void>.value();
}
if (location.existsSync()) {
location.deleteSync(recursive: true);
}
return _downloadZipArchive('Downloading $name...', archiveUri, location);
}
......
......@@ -330,13 +330,45 @@ void main() {
});
});
group('Unsigned mac artifacts', () {
group('macOS artifacts', () {
MockCache mockCache;
setUp(() {
mockCache = MockCache();
});
testUsingContext('verifies executables for libimobiledevice in isUpToDateInner', () async {
final IosUsbArtifacts iosUsbArtifacts = IosUsbArtifacts('libimobiledevice', mockCache);
when(mockCache.getArtifactDirectory(any)).thenReturn(fs.currentDirectory);
iosUsbArtifacts.location.createSync();
final File ideviceIdFile = iosUsbArtifacts.location.childFile('idevice_id')
..createSync();
iosUsbArtifacts.location.childFile('ideviceinfo')
..createSync();
expect(iosUsbArtifacts.isUpToDateInner(), true);
ideviceIdFile.deleteSync();
expect(iosUsbArtifacts.isUpToDateInner(), false);
}, overrides: <Type, Generator>{
Cache: () => mockCache,
FileSystem: () => MemoryFileSystem(),
ProcessManager: () => FakeProcessManager.any(),
});
testUsingContext('Does not verify executables for openssl in isUpToDateInner', () async {
final IosUsbArtifacts iosUsbArtifacts = IosUsbArtifacts('openssl', mockCache);
when(mockCache.getArtifactDirectory(any)).thenReturn(fs.currentDirectory);
iosUsbArtifacts.location.createSync();
expect(iosUsbArtifacts.isUpToDateInner(), true);
}, overrides: <Type, Generator>{
Cache: () => mockCache,
FileSystem: () => MemoryFileSystem(),
ProcessManager: () => FakeProcessManager.any(),
});
testUsingContext('use unsigned when specified', () async {
when(mockCache.useUnsignedMacBinaries).thenReturn(true);
......
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