handle exceptions raised while searching for configured android studio (#133180)
Fixes #133055
This commit is contained in:
@@ -11,6 +11,7 @@ import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:flutter_tools/src/base/version.dart';
|
||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
import 'package:flutter_tools/src/ios/plist_parser.dart';
|
||||
import 'package:path/path.dart' show Context; // flutter_ignore: package_path_import -- We only use Context as an interface.
|
||||
import 'package:test/fake.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
@@ -1287,6 +1288,20 @@ void main() {
|
||||
Platform: () => platform,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
});
|
||||
|
||||
testUsingContext('handles file system exception when checking for explicitly configured Android Studio install', () {
|
||||
const String androidStudioDir = '/Users/Dash/Desktop/android-studio';
|
||||
config.setValue('android-studio-dir', androidStudioDir);
|
||||
|
||||
expect(() => AndroidStudio.latestValid(),
|
||||
throwsToolExit(message: RegExp(r'[.\s\S]*Could not find[.\s\S]*FileSystemException[.\s\S]*')));
|
||||
}, overrides: <Type, Generator>{
|
||||
Config: () => config,
|
||||
Platform: () => platform,
|
||||
FileSystem: () => _FakeFileSystem(),
|
||||
FileSystemUtils: () => _FakeFsUtils(),
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1298,3 +1313,33 @@ class FakePlistUtils extends Fake implements PlistParser {
|
||||
return fileContents[plistFilePath]!;
|
||||
}
|
||||
}
|
||||
|
||||
class _FakeFileSystem extends Fake implements FileSystem {
|
||||
@override
|
||||
Directory directory(dynamic path) {
|
||||
return _NonExistentDirectory();
|
||||
}
|
||||
|
||||
@override
|
||||
Context get path {
|
||||
return MemoryFileSystem.test().path;
|
||||
}
|
||||
}
|
||||
|
||||
class _NonExistentDirectory extends Fake implements Directory {
|
||||
@override
|
||||
bool existsSync() {
|
||||
throw const FileSystemException('OS Error: Filename, directory name, or volume label syntax is incorrect.');
|
||||
}
|
||||
|
||||
@override
|
||||
String get path => '';
|
||||
|
||||
@override
|
||||
Directory get parent => _NonExistentDirectory();
|
||||
}
|
||||
|
||||
class _FakeFsUtils extends Fake implements FileSystemUtils {
|
||||
@override
|
||||
String get homeDirPath => '/home/';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user