Unverified Commit b5e7fb07 authored by Phil Quitslund's avatar Phil Quitslund Committed by GitHub

[flutter_tools] rename local functions with `_`s (#102688)

parent a03f59cd
...@@ -249,7 +249,7 @@ class AndroidStudio implements Comparable<AndroidStudio> { ...@@ -249,7 +249,7 @@ class AndroidStudio implements Comparable<AndroidStudio> {
static List<AndroidStudio> _allMacOS() { static List<AndroidStudio> _allMacOS() {
final List<FileSystemEntity> candidatePaths = <FileSystemEntity>[]; final List<FileSystemEntity> candidatePaths = <FileSystemEntity>[];
void _checkForStudio(String path) { void checkForStudio(String path) {
if (!globals.fs.isDirectorySync(path)) { if (!globals.fs.isDirectorySync(path)) {
return; return;
} }
...@@ -264,7 +264,7 @@ class AndroidStudio implements Comparable<AndroidStudio> { ...@@ -264,7 +264,7 @@ class AndroidStudio implements Comparable<AndroidStudio> {
if (name.startsWith('Android Studio') && name.endsWith('.app')) { if (name.startsWith('Android Studio') && name.endsWith('.app')) {
candidatePaths.add(directory); candidatePaths.add(directory);
} else if (!directory.path.endsWith('.app')) { } else if (!directory.path.endsWith('.app')) {
_checkForStudio(directory.path); checkForStudio(directory.path);
} }
} }
} on Exception catch (e) { } on Exception catch (e) {
...@@ -272,10 +272,10 @@ class AndroidStudio implements Comparable<AndroidStudio> { ...@@ -272,10 +272,10 @@ class AndroidStudio implements Comparable<AndroidStudio> {
} }
} }
_checkForStudio('/Applications'); checkForStudio('/Applications');
final String? homeDirPath = globals.fsUtils.homeDirPath; final String? homeDirPath = globals.fsUtils.homeDirPath;
if (homeDirPath != null) { if (homeDirPath != null) {
_checkForStudio(globals.fs.path.join( checkForStudio(globals.fs.path.join(
homeDirPath, homeDirPath,
'Applications', 'Applications',
)); ));
...@@ -321,7 +321,7 @@ class AndroidStudio implements Comparable<AndroidStudio> { ...@@ -321,7 +321,7 @@ class AndroidStudio implements Comparable<AndroidStudio> {
static List<AndroidStudio> _allLinuxOrWindows() { static List<AndroidStudio> _allLinuxOrWindows() {
final List<AndroidStudio> studios = <AndroidStudio>[]; final List<AndroidStudio> studios = <AndroidStudio>[];
bool _hasStudioAt(String path, { Version? newerThan }) { bool hasStudioAt(String path, { Version? newerThan }) {
return studios.any((AndroidStudio studio) { return studios.any((AndroidStudio studio) {
if (studio.directory != path) { if (studio.directory != path) {
return false; return false;
...@@ -363,7 +363,7 @@ class AndroidStudio implements Comparable<AndroidStudio> { ...@@ -363,7 +363,7 @@ class AndroidStudio implements Comparable<AndroidStudio> {
for (final Directory entity in entities) { for (final Directory entity in entities) {
final AndroidStudio? studio = AndroidStudio.fromHomeDot(entity); final AndroidStudio? studio = AndroidStudio.fromHomeDot(entity);
if (studio != null && !_hasStudioAt(studio.directory, newerThan: studio.version)) { if (studio != null && !hasStudioAt(studio.directory, newerThan: studio.version)) {
studios.removeWhere((AndroidStudio other) => other.directory == studio.directory); studios.removeWhere((AndroidStudio other) => other.directory == studio.directory);
studios.add(studio); studios.add(studio);
} }
...@@ -394,7 +394,7 @@ class AndroidStudio implements Comparable<AndroidStudio> { ...@@ -394,7 +394,7 @@ class AndroidStudio implements Comparable<AndroidStudio> {
version: Version.parse(version), version: Version.parse(version),
studioAppName: title, studioAppName: title,
); );
if (studio != null && !_hasStudioAt(studio.directory, newerThan: studio.version)) { if (studio != null && !hasStudioAt(studio.directory, newerThan: studio.version)) {
studios.removeWhere((AndroidStudio other) => other.directory == studio.directory); studios.removeWhere((AndroidStudio other) => other.directory == studio.directory);
studios.add(studio); studios.add(studio);
} }
...@@ -405,21 +405,21 @@ class AndroidStudio implements Comparable<AndroidStudio> { ...@@ -405,21 +405,21 @@ class AndroidStudio implements Comparable<AndroidStudio> {
} }
final String? configuredStudioDir = globals.config.getValue('android-studio-dir') as String?; final String? configuredStudioDir = globals.config.getValue('android-studio-dir') as String?;
if (configuredStudioDir != null && !_hasStudioAt(configuredStudioDir)) { if (configuredStudioDir != null && !hasStudioAt(configuredStudioDir)) {
studios.add(AndroidStudio(configuredStudioDir, studios.add(AndroidStudio(configuredStudioDir,
configured: configuredStudioDir)); configured: configuredStudioDir));
} }
if (globals.platform.isLinux) { if (globals.platform.isLinux) {
void _checkWellKnownPath(String path) { void checkWellKnownPath(String path) {
if (globals.fs.isDirectorySync(path) && !_hasStudioAt(path)) { if (globals.fs.isDirectorySync(path) && !hasStudioAt(path)) {
studios.add(AndroidStudio(path)); studios.add(AndroidStudio(path));
} }
} }
// Add /opt/android-studio and $HOME/android-studio, if they exist. // Add /opt/android-studio and $HOME/android-studio, if they exist.
_checkWellKnownPath('/opt/android-studio'); checkWellKnownPath('/opt/android-studio');
_checkWellKnownPath('${globals.fsUtils.homeDirPath}/android-studio'); checkWellKnownPath('${globals.fsUtils.homeDirPath}/android-studio');
} }
return studios; return studios;
} }
......
...@@ -366,7 +366,7 @@ class AndroidLicenseValidator extends DoctorValidator { ...@@ -366,7 +366,7 @@ class AndroidLicenseValidator extends DoctorValidator {
Future<LicensesAccepted> get licensesAccepted async { Future<LicensesAccepted> get licensesAccepted async {
LicensesAccepted? status; LicensesAccepted? status;
void _handleLine(String line) { void handleLine(String line) {
if (licenseCounts.hasMatch(line)) { if (licenseCounts.hasMatch(line)) {
final Match? match = licenseCounts.firstMatch(line); final Match? match = licenseCounts.firstMatch(line);
if (match?.group(1) != match?.group(2)) { if (match?.group(1) != match?.group(2)) {
...@@ -399,12 +399,12 @@ class AndroidLicenseValidator extends DoctorValidator { ...@@ -399,12 +399,12 @@ class AndroidLicenseValidator extends DoctorValidator {
final Future<void> output = process.stdout final Future<void> output = process.stdout
.transform<String>(const Utf8Decoder(reportErrors: false)) .transform<String>(const Utf8Decoder(reportErrors: false))
.transform<String>(const LineSplitter()) .transform<String>(const LineSplitter())
.listen(_handleLine) .listen(handleLine)
.asFuture<void>(null); .asFuture<void>(null);
final Future<void> errors = process.stderr final Future<void> errors = process.stderr
.transform<String>(const Utf8Decoder(reportErrors: false)) .transform<String>(const Utf8Decoder(reportErrors: false))
.transform<String>(const LineSplitter()) .transform<String>(const LineSplitter())
.listen(_handleLine) .listen(handleLine)
.asFuture<void>(null); .asFuture<void>(null);
await Future.wait<void>(<Future<void>>[output, errors]); await Future.wait<void>(<Future<void>>[output, errors]);
return status ?? LicensesAccepted.unknown; return status ?? LicensesAccepted.unknown;
......
...@@ -46,21 +46,21 @@ Future<void> validateBitcode(BuildMode buildMode, TargetPlatform targetPlatform, ...@@ -46,21 +46,21 @@ Future<void> validateBitcode(BuildMode buildMode, TargetPlatform targetPlatform,
Version _parseVersionFromClang(String? clangVersion) { Version _parseVersionFromClang(String? clangVersion) {
final RegExp pattern = RegExp(r'Apple (LLVM|clang) version (\d+\.\d+\.\d+) '); final RegExp pattern = RegExp(r'Apple (LLVM|clang) version (\d+\.\d+\.\d+) ');
Never _invalid() { Never invalid() {
throwToolExit('Unable to parse Clang version from "$clangVersion". ' throwToolExit('Unable to parse Clang version from "$clangVersion". '
'Expected a string like "Apple (LLVM|clang) #.#.# (clang-####.#.##.#)".'); 'Expected a string like "Apple (LLVM|clang) #.#.# (clang-####.#.##.#)".');
} }
if (clangVersion == null || clangVersion.isEmpty) { if (clangVersion == null || clangVersion.isEmpty) {
_invalid(); invalid();
} }
final RegExpMatch? match = pattern.firstMatch(clangVersion); final RegExpMatch? match = pattern.firstMatch(clangVersion);
if (match == null || match.groupCount != 2) { if (match == null || match.groupCount != 2) {
_invalid(); invalid();
} }
final Version? version = Version.parse(match.group(2)); final Version? version = Version.parse(match.group(2));
if (version == null) { if (version == null) {
_invalid(); invalid();
} }
return version; return version;
} }
...@@ -301,7 +301,7 @@ class XcodeProjectInterpreter { ...@@ -301,7 +301,7 @@ class XcodeProjectInterpreter {
const int missingProjectExitCode = 66; const int missingProjectExitCode = 66;
// The exit code returned by 'xcodebuild -list' when the project is corrupted. // The exit code returned by 'xcodebuild -list' when the project is corrupted.
const int corruptedProjectExitCode = 74; const int corruptedProjectExitCode = 74;
bool _allowedFailures(int c) => c == missingProjectExitCode || c == corruptedProjectExitCode; bool allowedFailures(int c) => c == missingProjectExitCode || c == corruptedProjectExitCode;
final RunResult result = await _processUtils.run( final RunResult result = await _processUtils.run(
<String>[ <String>[
...xcrunCommand(), ...xcrunCommand(),
...@@ -310,10 +310,10 @@ class XcodeProjectInterpreter { ...@@ -310,10 +310,10 @@ class XcodeProjectInterpreter {
if (projectFilename != null) ...<String>['-project', projectFilename], if (projectFilename != null) ...<String>['-project', projectFilename],
], ],
throwOnError: true, throwOnError: true,
allowedFailures: _allowedFailures, allowedFailures: allowedFailures,
workingDirectory: projectPath, workingDirectory: projectPath,
); );
if (_allowedFailures(result.exitCode)) { if (allowedFailures(result.exitCode)) {
// User configuration error, tool exit instead of crashing. // User configuration error, tool exit instead of crashing.
throwToolExit('Unable to get Xcode project information:\n ${result.stderr}'); throwToolExit('Unable to get Xcode project information:\n ${result.stderr}');
} }
......
...@@ -254,7 +254,7 @@ class WebAssetServer implements AssetReader { ...@@ -254,7 +254,7 @@ class WebAssetServer implements AssetReader {
// Return a version string for all active modules. This is populated // Return a version string for all active modules. This is populated
// along with the `moduleProvider` update logic. // along with the `moduleProvider` update logic.
Future<Map<String, String>> _digestProvider() async => digests; Future<Map<String, String>> digestProvider() async => digests;
// Ensure dwds is present and provide middleware to avoid trying to // Ensure dwds is present and provide middleware to avoid trying to
// load the through the isolate APIs. // load the through the isolate APIs.
...@@ -295,7 +295,7 @@ class WebAssetServer implements AssetReader { ...@@ -295,7 +295,7 @@ class WebAssetServer implements AssetReader {
loadStrategy: FrontendServerRequireStrategyProvider( loadStrategy: FrontendServerRequireStrategyProvider(
ReloadConfiguration.none, ReloadConfiguration.none,
server, server,
_digestProvider, digestProvider,
).strategy, ).strategy,
expressionCompiler: expressionCompiler, expressionCompiler: expressionCompiler,
spawnDds: enableDds, spawnDds: enableDds,
......
...@@ -358,7 +358,7 @@ class Message { ...@@ -358,7 +358,7 @@ class Message {
if (attributes == null) { if (attributes == null) {
void _throwEmptyAttributes(final RegExp regExp, final String type) { void throwEmptyAttributes(final RegExp regExp, final String type) {
final RegExpMatch? match = regExp.firstMatch(_value(bundle, resourceId)); final RegExpMatch? match = regExp.firstMatch(_value(bundle, resourceId));
final bool isMatch = match != null && match.groupCount == 1; final bool isMatch = match != null && match.groupCount == 1;
if (isMatch) { if (isMatch) {
...@@ -369,8 +369,8 @@ class Message { ...@@ -369,8 +369,8 @@ class Message {
} }
} }
_throwEmptyAttributes(_pluralRE, 'plural'); throwEmptyAttributes(_pluralRE, 'plural');
_throwEmptyAttributes(_selectRE, 'select'); throwEmptyAttributes(_selectRE, 'select');
} }
return attributes as Map<String, Object?>?; return attributes as Map<String, Object?>?;
......
...@@ -55,7 +55,7 @@ void main() { ...@@ -55,7 +55,7 @@ void main() {
}); });
void _createSampleProject(Directory directory, { bool brokenCode = false }) { void createSampleProject(Directory directory, { bool brokenCode = false }) {
final File pubspecFile = fileSystem.file(fileSystem.path.join(directory.path, 'pubspec.yaml')); final File pubspecFile = fileSystem.file(fileSystem.path.join(directory.path, 'pubspec.yaml'));
pubspecFile.writeAsStringSync(''' pubspecFile.writeAsStringSync('''
name: foo_project name: foo_project
...@@ -75,7 +75,7 @@ void main() { ...@@ -75,7 +75,7 @@ void main() {
group('analyze --watch', () { group('analyze --watch', () {
testUsingContext('AnalysisServer success', () async { testUsingContext('AnalysisServer success', () async {
_createSampleProject(tempDir); createSampleProject(tempDir);
final Pub pub = Pub( final Pub pub = Pub(
fileSystem: fileSystem, fileSystem: fileSystem,
...@@ -113,7 +113,7 @@ void main() { ...@@ -113,7 +113,7 @@ void main() {
}); });
testUsingContext('AnalysisServer errors', () async { testUsingContext('AnalysisServer errors', () async {
_createSampleProject(tempDir, brokenCode: true); createSampleProject(tempDir, brokenCode: true);
final Pub pub = Pub( final Pub pub = Pub(
fileSystem: fileSystem, fileSystem: fileSystem,
......
...@@ -72,25 +72,25 @@ void main() { ...@@ -72,25 +72,25 @@ void main() {
}); });
// Sets up the minimal mock project files necessary to look like a Flutter project. // Sets up the minimal mock project files necessary to look like a Flutter project.
void _createCoreMockProjectFiles() { void createCoreMockProjectFiles() {
fileSystem.file('pubspec.yaml').createSync(); fileSystem.file('pubspec.yaml').createSync();
fileSystem.file('.packages').createSync(); fileSystem.file('.packages').createSync();
fileSystem.file(fileSystem.path.join('lib', 'main.dart')).createSync(recursive: true); fileSystem.file(fileSystem.path.join('lib', 'main.dart')).createSync(recursive: true);
} }
// Sets up the minimal mock project files necessary for iOS builds to succeed. // Sets up the minimal mock project files necessary for iOS builds to succeed.
void _createMinimalMockProjectFiles() { void createMinimalMockProjectFiles() {
fileSystem.directory(fileSystem.path.join('ios', 'Runner.xcodeproj')).createSync(recursive: true); fileSystem.directory(fileSystem.path.join('ios', 'Runner.xcodeproj')).createSync(recursive: true);
fileSystem.directory(fileSystem.path.join('ios', 'Runner.xcworkspace')).createSync(recursive: true); fileSystem.directory(fileSystem.path.join('ios', 'Runner.xcworkspace')).createSync(recursive: true);
fileSystem.file(fileSystem.path.join('ios', 'Runner.xcodeproj', 'project.pbxproj')).createSync(); fileSystem.file(fileSystem.path.join('ios', 'Runner.xcodeproj', 'project.pbxproj')).createSync();
_createCoreMockProjectFiles(); createCoreMockProjectFiles();
} }
const FakeCommand xattrCommand = FakeCommand(command: <String>[ const FakeCommand xattrCommand = FakeCommand(command: <String>[
'xattr', '-r', '-d', 'com.apple.FinderInfo', '/', 'xattr', '-r', '-d', 'com.apple.FinderInfo', '/',
]); ]);
FakeCommand _setUpRsyncCommand({void Function() onRun}) { FakeCommand setUpRsyncCommand({void Function() onRun}) {
return FakeCommand( return FakeCommand(
command: const <String>[ command: const <String>[
'rsync', 'rsync',
...@@ -104,7 +104,7 @@ void main() { ...@@ -104,7 +104,7 @@ void main() {
); );
} }
FakeCommand _setUpXCResultCommand({String stdout = '', void Function() onRun}) { FakeCommand setUpXCResultCommand({String stdout = '', void Function() onRun}) {
return FakeCommand( return FakeCommand(
command: const <String>[ command: const <String>[
'xcrun', 'xcrun',
...@@ -122,7 +122,7 @@ void main() { ...@@ -122,7 +122,7 @@ void main() {
// Creates a FakeCommand for the xcodebuild call to build the app // Creates a FakeCommand for the xcodebuild call to build the app
// in the given configuration. // in the given configuration.
FakeCommand _setUpFakeXcodeBuildHandler({ FakeCommand setUpFakeXcodeBuildHandler({
bool verbose = false, bool verbose = false,
bool simulator = false, bool simulator = false,
String deviceId, String deviceId,
...@@ -179,7 +179,7 @@ void main() { ...@@ -179,7 +179,7 @@ void main() {
testUsingContext('ios build fails when there is no ios project', () async { testUsingContext('ios build fails when there is no ios project', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
_createCoreMockProjectFiles(); createCoreMockProjectFiles();
expect(createTestCommandRunner(command).run( expect(createTestCommandRunner(command).run(
const <String>['build', 'ios', '--no-pub'] const <String>['build', 'ios', '--no-pub']
...@@ -193,7 +193,7 @@ void main() { ...@@ -193,7 +193,7 @@ void main() {
testUsingContext('ios build fails in debug with code analysis', () async { testUsingContext('ios build fails in debug with code analysis', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
_createCoreMockProjectFiles(); createCoreMockProjectFiles();
expect(createTestCommandRunner(command).run( expect(createTestCommandRunner(command).run(
const <String>['build', 'ios', '--no-pub', '--debug', '--analyze-size'] const <String>['build', 'ios', '--no-pub', '--debug', '--analyze-size']
...@@ -225,7 +225,7 @@ void main() { ...@@ -225,7 +225,7 @@ void main() {
testUsingContext('ios build invokes xcode build', () async { testUsingContext('ios build invokes xcode build', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await createTestCommandRunner(command).run( await createTestCommandRunner(command).run(
const <String>['build', 'ios', '--no-pub'] const <String>['build', 'ios', '--no-pub']
...@@ -235,10 +235,10 @@ void main() { ...@@ -235,10 +235,10 @@ void main() {
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[ ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
xattrCommand, xattrCommand,
_setUpFakeXcodeBuildHandler(onRun: () { setUpFakeXcodeBuildHandler(onRun: () {
fileSystem.directory('build/ios/Release-iphoneos/Runner.app').createSync(recursive: true); fileSystem.directory('build/ios/Release-iphoneos/Runner.app').createSync(recursive: true);
}), }),
_setUpRsyncCommand(), setUpRsyncCommand(),
]), ]),
Platform: () => macosPlatform, Platform: () => macosPlatform,
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(), XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
...@@ -246,7 +246,7 @@ void main() { ...@@ -246,7 +246,7 @@ void main() {
testUsingContext('ios build invokes xcode build with device ID', () async { testUsingContext('ios build invokes xcode build with device ID', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await createTestCommandRunner(command).run( await createTestCommandRunner(command).run(
const <String>['build', 'ios', '--no-pub', '--device-id', '1234'] const <String>['build', 'ios', '--no-pub', '--device-id', '1234']
...@@ -256,10 +256,10 @@ void main() { ...@@ -256,10 +256,10 @@ void main() {
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[ ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
xattrCommand, xattrCommand,
_setUpFakeXcodeBuildHandler(deviceId: '1234', onRun: () { setUpFakeXcodeBuildHandler(deviceId: '1234', onRun: () {
fileSystem.directory('build/ios/Release-iphoneos/Runner.app').createSync(recursive: true); fileSystem.directory('build/ios/Release-iphoneos/Runner.app').createSync(recursive: true);
}), }),
_setUpRsyncCommand(), setUpRsyncCommand(),
]), ]),
Platform: () => macosPlatform, Platform: () => macosPlatform,
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(), XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
...@@ -267,7 +267,7 @@ void main() { ...@@ -267,7 +267,7 @@ void main() {
testUsingContext('ios simulator build invokes xcode build', () async { testUsingContext('ios simulator build invokes xcode build', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await createTestCommandRunner(command).run( await createTestCommandRunner(command).run(
const <String>['build', 'ios', '--simulator', '--no-pub'] const <String>['build', 'ios', '--simulator', '--no-pub']
...@@ -276,10 +276,10 @@ void main() { ...@@ -276,10 +276,10 @@ void main() {
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[ ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
xattrCommand, xattrCommand,
_setUpFakeXcodeBuildHandler(simulator: true, onRun: () { setUpFakeXcodeBuildHandler(simulator: true, onRun: () {
fileSystem.directory('build/ios/Debug-iphonesimulator/Runner.app').createSync(recursive: true); fileSystem.directory('build/ios/Debug-iphonesimulator/Runner.app').createSync(recursive: true);
}), }),
_setUpRsyncCommand(), setUpRsyncCommand(),
]), ]),
Platform: () => macosPlatform, Platform: () => macosPlatform,
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(), XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
...@@ -287,7 +287,7 @@ void main() { ...@@ -287,7 +287,7 @@ void main() {
testUsingContext('ios build invokes xcode build with verbosity', () async { testUsingContext('ios build invokes xcode build with verbosity', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await createTestCommandRunner(command).run( await createTestCommandRunner(command).run(
const <String>['build', 'ios', '--no-pub', '-v'] const <String>['build', 'ios', '--no-pub', '-v']
...@@ -296,10 +296,10 @@ void main() { ...@@ -296,10 +296,10 @@ void main() {
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[ ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
xattrCommand, xattrCommand,
_setUpFakeXcodeBuildHandler(verbose: true, onRun: () { setUpFakeXcodeBuildHandler(verbose: true, onRun: () {
fileSystem.directory('build/ios/Release-iphoneos/Runner.app').createSync(recursive: true); fileSystem.directory('build/ios/Release-iphoneos/Runner.app').createSync(recursive: true);
}), }),
_setUpRsyncCommand(), setUpRsyncCommand(),
]), ]),
Platform: () => macosPlatform, Platform: () => macosPlatform,
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(), XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
...@@ -307,7 +307,7 @@ void main() { ...@@ -307,7 +307,7 @@ void main() {
testUsingContext('Performs code size analysis and sends analytics', () async { testUsingContext('Performs code size analysis and sends analytics', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await createTestCommandRunner(command).run( await createTestCommandRunner(command).run(
const <String>['build', 'ios', '--no-pub', '--analyze-size'] const <String>['build', 'ios', '--no-pub', '--analyze-size']
...@@ -322,7 +322,7 @@ void main() { ...@@ -322,7 +322,7 @@ void main() {
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[ ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
xattrCommand, xattrCommand,
_setUpFakeXcodeBuildHandler(onRun: () { setUpFakeXcodeBuildHandler(onRun: () {
fileSystem.directory('build/ios/Release-iphoneos/Runner.app').createSync(recursive: true); fileSystem.directory('build/ios/Release-iphoneos/Runner.app').createSync(recursive: true);
fileSystem.file('build/flutter_size_01/snapshot.arm64.json') fileSystem.file('build/flutter_size_01/snapshot.arm64.json')
..createSync(recursive: true) ..createSync(recursive: true)
...@@ -339,7 +339,7 @@ void main() { ...@@ -339,7 +339,7 @@ void main() {
..createSync(recursive: true) ..createSync(recursive: true)
..writeAsStringSync('{}'); ..writeAsStringSync('{}');
}), }),
_setUpRsyncCommand(onRun: () => fileSystem.file('build/ios/iphoneos/Runner.app/Frameworks/App.framework/App') setUpRsyncCommand(onRun: () => fileSystem.file('build/ios/iphoneos/Runner.app/Frameworks/App.framework/App')
..createSync(recursive: true) ..createSync(recursive: true)
..writeAsBytesSync(List<int>.generate(10000, (int index) => 0))), ..writeAsBytesSync(List<int>.generate(10000, (int index) => 0))),
]), ]),
...@@ -352,7 +352,7 @@ void main() { ...@@ -352,7 +352,7 @@ void main() {
testUsingContext('Trace error if xcresult is empty.', () async { testUsingContext('Trace error if xcresult is empty.', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await expectLater( await expectLater(
createTestCommandRunner(command).run(const <String>['build', 'ios', '--no-pub']), createTestCommandRunner(command).run(const <String>['build', 'ios', '--no-pub']),
...@@ -364,11 +364,11 @@ void main() { ...@@ -364,11 +364,11 @@ void main() {
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[ ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
xattrCommand, xattrCommand,
_setUpFakeXcodeBuildHandler(exitCode: 1, onRun: () { setUpFakeXcodeBuildHandler(exitCode: 1, onRun: () {
fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync(); fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync();
}), }),
_setUpXCResultCommand(), setUpXCResultCommand(),
_setUpRsyncCommand(), setUpRsyncCommand(),
]), ]),
Platform: () => macosPlatform, Platform: () => macosPlatform,
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(), XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
...@@ -377,7 +377,7 @@ void main() { ...@@ -377,7 +377,7 @@ void main() {
testUsingContext('Display xcresult issues on console if parsed.', () async { testUsingContext('Display xcresult issues on console if parsed.', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await expectLater( await expectLater(
createTestCommandRunner(command).run(const <String>['build', 'ios', '--no-pub']), createTestCommandRunner(command).run(const <String>['build', 'ios', '--no-pub']),
...@@ -390,11 +390,11 @@ void main() { ...@@ -390,11 +390,11 @@ void main() {
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[ ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
xattrCommand, xattrCommand,
_setUpFakeXcodeBuildHandler(exitCode: 1, onRun: () { setUpFakeXcodeBuildHandler(exitCode: 1, onRun: () {
fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync(); fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync();
}), }),
_setUpXCResultCommand(stdout: kSampleResultJsonWithIssues), setUpXCResultCommand(stdout: kSampleResultJsonWithIssues),
_setUpRsyncCommand(), setUpRsyncCommand(),
]), ]),
Platform: () => macosPlatform, Platform: () => macosPlatform,
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(), XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
...@@ -403,7 +403,7 @@ void main() { ...@@ -403,7 +403,7 @@ void main() {
testUsingContext('Do not display xcresult issues that needs to be discarded.', () async { testUsingContext('Do not display xcresult issues that needs to be discarded.', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await expectLater( await expectLater(
createTestCommandRunner(command).run(const <String>['build', 'ios', '--no-pub']), createTestCommandRunner(command).run(const <String>['build', 'ios', '--no-pub']),
...@@ -418,11 +418,11 @@ void main() { ...@@ -418,11 +418,11 @@ void main() {
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[ ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
xattrCommand, xattrCommand,
_setUpFakeXcodeBuildHandler(exitCode: 1, onRun: () { setUpFakeXcodeBuildHandler(exitCode: 1, onRun: () {
fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync(); fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync();
}), }),
_setUpXCResultCommand(stdout: kSampleResultJsonWithIssuesToBeDiscarded), setUpXCResultCommand(stdout: kSampleResultJsonWithIssuesToBeDiscarded),
_setUpRsyncCommand(), setUpRsyncCommand(),
]), ]),
Platform: () => macosPlatform, Platform: () => macosPlatform,
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(), XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
...@@ -431,7 +431,7 @@ void main() { ...@@ -431,7 +431,7 @@ void main() {
testUsingContext('Trace if xcresult bundle does not exist.', () async { testUsingContext('Trace if xcresult bundle does not exist.', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await expectLater( await expectLater(
createTestCommandRunner(command).run(const <String>['build', 'ios', '--no-pub']), createTestCommandRunner(command).run(const <String>['build', 'ios', '--no-pub']),
...@@ -443,9 +443,9 @@ void main() { ...@@ -443,9 +443,9 @@ void main() {
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[ ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
xattrCommand, xattrCommand,
_setUpFakeXcodeBuildHandler(exitCode: 1), setUpFakeXcodeBuildHandler(exitCode: 1),
_setUpXCResultCommand(stdout: kSampleResultJsonWithIssues), setUpXCResultCommand(stdout: kSampleResultJsonWithIssues),
_setUpRsyncCommand(), setUpRsyncCommand(),
]), ]),
Platform: () => macosPlatform, Platform: () => macosPlatform,
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(), XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
...@@ -454,7 +454,7 @@ void main() { ...@@ -454,7 +454,7 @@ void main() {
testUsingContext('Extra error message for provision profile issue in xcresult bundle.', () async { testUsingContext('Extra error message for provision profile issue in xcresult bundle.', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await expectLater( await expectLater(
createTestCommandRunner(command).run(const <String>['build', 'ios', '--no-pub']), createTestCommandRunner(command).run(const <String>['build', 'ios', '--no-pub']),
...@@ -470,11 +470,11 @@ void main() { ...@@ -470,11 +470,11 @@ void main() {
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[ ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
xattrCommand, xattrCommand,
_setUpFakeXcodeBuildHandler(exitCode: 1, onRun: () { setUpFakeXcodeBuildHandler(exitCode: 1, onRun: () {
fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync(); fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync();
}), }),
_setUpXCResultCommand(stdout: kSampleResultJsonWithProvisionIssue), setUpXCResultCommand(stdout: kSampleResultJsonWithProvisionIssue),
_setUpRsyncCommand(), setUpRsyncCommand(),
]), ]),
Platform: () => macosPlatform, Platform: () => macosPlatform,
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(), XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
...@@ -483,7 +483,7 @@ void main() { ...@@ -483,7 +483,7 @@ void main() {
testUsingContext('Default bundle identifier error should be hidden if there is another xcresult issue.', () async { testUsingContext('Default bundle identifier error should be hidden if there is another xcresult issue.', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await expectLater( await expectLater(
createTestCommandRunner(command).run(const <String>['build', 'ios', '--no-pub']), createTestCommandRunner(command).run(const <String>['build', 'ios', '--no-pub']),
...@@ -497,11 +497,11 @@ void main() { ...@@ -497,11 +497,11 @@ void main() {
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[ ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
xattrCommand, xattrCommand,
_setUpFakeXcodeBuildHandler(exitCode: 1, onRun: () { setUpFakeXcodeBuildHandler(exitCode: 1, onRun: () {
fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync(); fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync();
}), }),
_setUpXCResultCommand(stdout: kSampleResultJsonWithIssues), setUpXCResultCommand(stdout: kSampleResultJsonWithIssues),
_setUpRsyncCommand(), setUpRsyncCommand(),
]), ]),
Platform: () => macosPlatform, Platform: () => macosPlatform,
EnvironmentType: () => EnvironmentType.physical, EnvironmentType: () => EnvironmentType.physical,
...@@ -511,7 +511,7 @@ void main() { ...@@ -511,7 +511,7 @@ void main() {
testUsingContext('Show default bundle identifier error if there are no other errors.', () async { testUsingContext('Show default bundle identifier error if there are no other errors.', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await expectLater( await expectLater(
createTestCommandRunner(command).run(const <String>['build', 'ios', '--no-pub']), createTestCommandRunner(command).run(const <String>['build', 'ios', '--no-pub']),
...@@ -523,11 +523,11 @@ void main() { ...@@ -523,11 +523,11 @@ void main() {
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[ ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
xattrCommand, xattrCommand,
_setUpFakeXcodeBuildHandler(exitCode: 1, onRun: () { setUpFakeXcodeBuildHandler(exitCode: 1, onRun: () {
fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync(); fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync();
}), }),
_setUpXCResultCommand(stdout: kSampleResultJsonNoIssues), setUpXCResultCommand(stdout: kSampleResultJsonNoIssues),
_setUpRsyncCommand(), setUpRsyncCommand(),
]), ]),
Platform: () => macosPlatform, Platform: () => macosPlatform,
EnvironmentType: () => EnvironmentType.physical, EnvironmentType: () => EnvironmentType.physical,
...@@ -538,7 +538,7 @@ void main() { ...@@ -538,7 +538,7 @@ void main() {
testUsingContext('Display xcresult issues with no provisioning profile.', () async { testUsingContext('Display xcresult issues with no provisioning profile.', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await expectLater( await expectLater(
createTestCommandRunner(command).run(const <String>['build', 'ios', '--no-pub']), createTestCommandRunner(command).run(const <String>['build', 'ios', '--no-pub']),
...@@ -551,14 +551,14 @@ void main() { ...@@ -551,14 +551,14 @@ void main() {
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[ ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
xattrCommand, xattrCommand,
_setUpFakeXcodeBuildHandler( setUpFakeXcodeBuildHandler(
exitCode: 1, exitCode: 1,
onRun: () { onRun: () {
fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync(); fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync();
} }
), ),
_setUpXCResultCommand(stdout: kSampleResultJsonWithNoProvisioningProfileIssue), setUpXCResultCommand(stdout: kSampleResultJsonWithNoProvisioningProfileIssue),
_setUpRsyncCommand(), setUpRsyncCommand(),
]), ]),
Platform: () => macosPlatform, Platform: () => macosPlatform,
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(), XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
...@@ -567,7 +567,7 @@ void main() { ...@@ -567,7 +567,7 @@ void main() {
testUsingContext('Failed to parse xcresult but display missing provisioning profile issue from stdout.', () async { testUsingContext('Failed to parse xcresult but display missing provisioning profile issue from stdout.', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await expectLater( await expectLater(
createTestCommandRunner(command).run(const <String>['build', 'ios', '--no-pub']), createTestCommandRunner(command).run(const <String>['build', 'ios', '--no-pub']),
...@@ -579,7 +579,7 @@ void main() { ...@@ -579,7 +579,7 @@ void main() {
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[ ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
xattrCommand, xattrCommand,
_setUpFakeXcodeBuildHandler( setUpFakeXcodeBuildHandler(
exitCode: 1, exitCode: 1,
stdout: ''' stdout: '''
Runner requires a provisioning profile. Select a provisioning profile in the Signing & Capabilities editor Runner requires a provisioning profile. Select a provisioning profile in the Signing & Capabilities editor
...@@ -588,8 +588,8 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig ...@@ -588,8 +588,8 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig
fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync(); fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync();
} }
), ),
_setUpXCResultCommand(stdout: kSampleResultJsonInvalidIssuesMap), setUpXCResultCommand(stdout: kSampleResultJsonInvalidIssuesMap),
_setUpRsyncCommand(), setUpRsyncCommand(),
]), ]),
Platform: () => macosPlatform, Platform: () => macosPlatform,
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(), XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
...@@ -598,7 +598,7 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig ...@@ -598,7 +598,7 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig
testUsingContext('Failed to parse xcresult but detected no development team issue.', () async { testUsingContext('Failed to parse xcresult but detected no development team issue.', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await expectLater( await expectLater(
createTestCommandRunner(command).run(const <String>['build', 'ios', '--no-pub']), createTestCommandRunner(command).run(const <String>['build', 'ios', '--no-pub']),
...@@ -610,14 +610,14 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig ...@@ -610,14 +610,14 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[ ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
xattrCommand, xattrCommand,
_setUpFakeXcodeBuildHandler( setUpFakeXcodeBuildHandler(
exitCode: 1, exitCode: 1,
onRun: () { onRun: () {
fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync(); fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync();
} }
), ),
_setUpXCResultCommand(stdout: kSampleResultJsonInvalidIssuesMap), setUpXCResultCommand(stdout: kSampleResultJsonInvalidIssuesMap),
_setUpRsyncCommand(), setUpRsyncCommand(),
]), ]),
Platform: () => macosPlatform, Platform: () => macosPlatform,
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(developmentTeam: null), XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(developmentTeam: null),
...@@ -627,7 +627,7 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig ...@@ -627,7 +627,7 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig
testUsingContext('xcresult did not detect issue but detected by stdout.', () async { testUsingContext('xcresult did not detect issue but detected by stdout.', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await expectLater( await expectLater(
createTestCommandRunner(command).run(const <String>['build', 'ios', '--no-pub']), createTestCommandRunner(command).run(const <String>['build', 'ios', '--no-pub']),
...@@ -639,7 +639,7 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig ...@@ -639,7 +639,7 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[ ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
xattrCommand, xattrCommand,
_setUpFakeXcodeBuildHandler( setUpFakeXcodeBuildHandler(
exitCode: 1, exitCode: 1,
stdout: ''' stdout: '''
Runner requires a provisioning profile. Select a provisioning profile in the Signing & Capabilities editor Runner requires a provisioning profile. Select a provisioning profile in the Signing & Capabilities editor
...@@ -648,8 +648,8 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig ...@@ -648,8 +648,8 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig
fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync(); fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync();
} }
), ),
_setUpXCResultCommand(stdout: kSampleResultJsonNoIssues), setUpXCResultCommand(stdout: kSampleResultJsonNoIssues),
_setUpRsyncCommand(), setUpRsyncCommand(),
]), ]),
EnvironmentType: () => EnvironmentType.physical, EnvironmentType: () => EnvironmentType.physical,
Platform: () => macosPlatform, Platform: () => macosPlatform,
...@@ -659,7 +659,7 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig ...@@ -659,7 +659,7 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig
testUsingContext('xcresult did not detect issue, no development team is detected from build setting.', () async { testUsingContext('xcresult did not detect issue, no development team is detected from build setting.', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await expectLater( await expectLater(
createTestCommandRunner(command).run(const <String>['build', 'ios', '--no-pub']), createTestCommandRunner(command).run(const <String>['build', 'ios', '--no-pub']),
...@@ -671,14 +671,14 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig ...@@ -671,14 +671,14 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[ ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
xattrCommand, xattrCommand,
_setUpFakeXcodeBuildHandler( setUpFakeXcodeBuildHandler(
exitCode: 1, exitCode: 1,
onRun: () { onRun: () {
fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync(); fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync();
} }
), ),
_setUpXCResultCommand(stdout: kSampleResultJsonInvalidIssuesMap), setUpXCResultCommand(stdout: kSampleResultJsonInvalidIssuesMap),
_setUpRsyncCommand(), setUpRsyncCommand(),
]), ]),
Platform: () => macosPlatform, Platform: () => macosPlatform,
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(developmentTeam: null), XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(developmentTeam: null),
...@@ -687,7 +687,7 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig ...@@ -687,7 +687,7 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig
testUsingContext('No development team issue error message is not displayed if no provisioning profile issue is detected from xcresult first.', () async { testUsingContext('No development team issue error message is not displayed if no provisioning profile issue is detected from xcresult first.', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await expectLater( await expectLater(
createTestCommandRunner(command).run(const <String>['build', 'ios', '--no-pub']), createTestCommandRunner(command).run(const <String>['build', 'ios', '--no-pub']),
...@@ -700,14 +700,14 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig ...@@ -700,14 +700,14 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[ ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
xattrCommand, xattrCommand,
_setUpFakeXcodeBuildHandler( setUpFakeXcodeBuildHandler(
exitCode: 1, exitCode: 1,
onRun: () { onRun: () {
fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync(); fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync();
} }
), ),
_setUpXCResultCommand(stdout: kSampleResultJsonWithNoProvisioningProfileIssue), setUpXCResultCommand(stdout: kSampleResultJsonWithNoProvisioningProfileIssue),
_setUpRsyncCommand(), setUpRsyncCommand(),
]), ]),
Platform: () => macosPlatform, Platform: () => macosPlatform,
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(developmentTeam: null), XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(developmentTeam: null),
...@@ -716,7 +716,7 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig ...@@ -716,7 +716,7 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig
testUsingContext('General provisioning profile issue error message is not displayed if no development team issue is detected first.', () async { testUsingContext('General provisioning profile issue error message is not displayed if no development team issue is detected first.', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await expectLater( await expectLater(
createTestCommandRunner(command).run(const <String>['build', 'ios', '--no-pub']), createTestCommandRunner(command).run(const <String>['build', 'ios', '--no-pub']),
...@@ -729,14 +729,14 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig ...@@ -729,14 +729,14 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[ ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
xattrCommand, xattrCommand,
_setUpFakeXcodeBuildHandler( setUpFakeXcodeBuildHandler(
exitCode: 1, exitCode: 1,
onRun: () { onRun: () {
fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync(); fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync();
} }
), ),
_setUpXCResultCommand(stdout: kSampleResultJsonWithProvisionIssue), setUpXCResultCommand(stdout: kSampleResultJsonWithProvisionIssue),
_setUpRsyncCommand(), setUpRsyncCommand(),
]), ]),
Platform: () => macosPlatform, Platform: () => macosPlatform,
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(developmentTeam: null), XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(developmentTeam: null),
...@@ -747,7 +747,7 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig ...@@ -747,7 +747,7 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig
testUsingContext('Trace error if xcresult is empty.', () async { testUsingContext('Trace error if xcresult is empty.', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await expectLater( await expectLater(
createTestCommandRunner(command).run(const <String>['build', 'ios', '--simulator', '--no-pub']), createTestCommandRunner(command).run(const <String>['build', 'ios', '--simulator', '--no-pub']),
...@@ -759,15 +759,15 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig ...@@ -759,15 +759,15 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[ ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
xattrCommand, xattrCommand,
_setUpFakeXcodeBuildHandler( setUpFakeXcodeBuildHandler(
simulator: true, simulator: true,
exitCode: 1, exitCode: 1,
onRun: () { onRun: () {
fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync(); fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync();
}, },
), ),
_setUpXCResultCommand(), setUpXCResultCommand(),
_setUpRsyncCommand(), setUpRsyncCommand(),
]), ]),
Platform: () => macosPlatform, Platform: () => macosPlatform,
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(), XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
...@@ -776,7 +776,7 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig ...@@ -776,7 +776,7 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig
testUsingContext('Display xcresult issues on console if parsed.', () async { testUsingContext('Display xcresult issues on console if parsed.', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await expectLater( await expectLater(
createTestCommandRunner(command).run(const <String>['build', 'ios', '--simulator', '--no-pub']), createTestCommandRunner(command).run(const <String>['build', 'ios', '--simulator', '--no-pub']),
...@@ -789,15 +789,15 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig ...@@ -789,15 +789,15 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[ ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
xattrCommand, xattrCommand,
_setUpFakeXcodeBuildHandler( setUpFakeXcodeBuildHandler(
simulator: true, simulator: true,
exitCode: 1, exitCode: 1,
onRun: () { onRun: () {
fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync(); fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync();
}, },
), ),
_setUpXCResultCommand(stdout: kSampleResultJsonWithIssues), setUpXCResultCommand(stdout: kSampleResultJsonWithIssues),
_setUpRsyncCommand(), setUpRsyncCommand(),
]), ]),
Platform: () => macosPlatform, Platform: () => macosPlatform,
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(), XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
...@@ -806,7 +806,7 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig ...@@ -806,7 +806,7 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig
testUsingContext('Do not display xcresult issues that needs to be discarded.', () async { testUsingContext('Do not display xcresult issues that needs to be discarded.', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await expectLater( await expectLater(
createTestCommandRunner(command).run(const <String>['build', 'ios', '--simulator', '--no-pub']), createTestCommandRunner(command).run(const <String>['build', 'ios', '--simulator', '--no-pub']),
...@@ -821,15 +821,15 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig ...@@ -821,15 +821,15 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[ ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
xattrCommand, xattrCommand,
_setUpFakeXcodeBuildHandler( setUpFakeXcodeBuildHandler(
simulator: true, simulator: true,
exitCode: 1, exitCode: 1,
onRun: () { onRun: () {
fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync(); fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync();
}, },
), ),
_setUpXCResultCommand(stdout: kSampleResultJsonWithIssuesToBeDiscarded), setUpXCResultCommand(stdout: kSampleResultJsonWithIssuesToBeDiscarded),
_setUpRsyncCommand(), setUpRsyncCommand(),
]), ]),
Platform: () => macosPlatform, Platform: () => macosPlatform,
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(), XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
...@@ -838,7 +838,7 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig ...@@ -838,7 +838,7 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig
testUsingContext('Trace if xcresult bundle does not exist.', () async { testUsingContext('Trace if xcresult bundle does not exist.', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await expectLater( await expectLater(
createTestCommandRunner(command).run(const <String>['build', 'ios', '--simulator', '--no-pub']), createTestCommandRunner(command).run(const <String>['build', 'ios', '--simulator', '--no-pub']),
...@@ -850,12 +850,12 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig ...@@ -850,12 +850,12 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[ ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
xattrCommand, xattrCommand,
_setUpFakeXcodeBuildHandler( setUpFakeXcodeBuildHandler(
simulator: true, simulator: true,
exitCode: 1, exitCode: 1,
), ),
_setUpXCResultCommand(stdout: kSampleResultJsonWithIssues), setUpXCResultCommand(stdout: kSampleResultJsonWithIssues),
_setUpRsyncCommand(), setUpRsyncCommand(),
]), ]),
Platform: () => macosPlatform, Platform: () => macosPlatform,
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(), XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
......
...@@ -68,25 +68,25 @@ void main() { ...@@ -68,25 +68,25 @@ void main() {
}); });
// Sets up the minimal mock project files necessary to look like a Flutter project. // Sets up the minimal mock project files necessary to look like a Flutter project.
void _createCoreMockProjectFiles() { void createCoreMockProjectFiles() {
fileSystem.file('pubspec.yaml').createSync(); fileSystem.file('pubspec.yaml').createSync();
fileSystem.file('.packages').createSync(); fileSystem.file('.packages').createSync();
fileSystem.file(fileSystem.path.join('lib', 'main.dart')).createSync(recursive: true); fileSystem.file(fileSystem.path.join('lib', 'main.dart')).createSync(recursive: true);
} }
// Sets up the minimal mock project files necessary for iOS builds to succeed. // Sets up the minimal mock project files necessary for iOS builds to succeed.
void _createMinimalMockProjectFiles() { void createMinimalMockProjectFiles() {
fileSystem.directory(fileSystem.path.join('ios', 'Runner.xcodeproj')).createSync(recursive: true); fileSystem.directory(fileSystem.path.join('ios', 'Runner.xcodeproj')).createSync(recursive: true);
fileSystem.directory(fileSystem.path.join('ios', 'Runner.xcworkspace')).createSync(recursive: true); fileSystem.directory(fileSystem.path.join('ios', 'Runner.xcworkspace')).createSync(recursive: true);
fileSystem.file(fileSystem.path.join('ios', 'Runner.xcodeproj', 'project.pbxproj')).createSync(); fileSystem.file(fileSystem.path.join('ios', 'Runner.xcodeproj', 'project.pbxproj')).createSync();
_createCoreMockProjectFiles(); createCoreMockProjectFiles();
} }
const FakeCommand xattrCommand = FakeCommand(command: <String>[ const FakeCommand xattrCommand = FakeCommand(command: <String>[
'xattr', '-r', '-d', 'com.apple.FinderInfo', '/', 'xattr', '-r', '-d', 'com.apple.FinderInfo', '/',
]); ]);
FakeCommand _setUpXCResultCommand({String stdout = '', void Function() onRun}) { FakeCommand setUpXCResultCommand({String stdout = '', void Function() onRun}) {
return FakeCommand( return FakeCommand(
command: const <String>[ command: const <String>[
'xcrun', 'xcrun',
...@@ -104,7 +104,7 @@ void main() { ...@@ -104,7 +104,7 @@ void main() {
// Creates a FakeCommand for the xcodebuild call to build the app // Creates a FakeCommand for the xcodebuild call to build the app
// in the given configuration. // in the given configuration.
FakeCommand _setUpFakeXcodeBuildHandler({ bool verbose = false, int exitCode = 0, void Function() onRun }) { FakeCommand setUpFakeXcodeBuildHandler({ bool verbose = false, int exitCode = 0, void Function() onRun }) {
return FakeCommand( return FakeCommand(
command: <String>[ command: <String>[
'xcrun', 'xcrun',
...@@ -132,7 +132,7 @@ void main() { ...@@ -132,7 +132,7 @@ void main() {
); );
} }
FakeCommand _exportArchiveCommand({ FakeCommand exportArchiveCommand({
String exportOptionsPlist = '/ExportOptions.plist', String exportOptionsPlist = '/ExportOptions.plist',
File cachePlist, File cachePlist,
}) { }) {
...@@ -162,7 +162,7 @@ void main() { ...@@ -162,7 +162,7 @@ void main() {
testUsingContext('ipa build fails when there is no ios project', () async { testUsingContext('ipa build fails when there is no ios project', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
_createCoreMockProjectFiles(); createCoreMockProjectFiles();
expect(createTestCommandRunner(command).run( expect(createTestCommandRunner(command).run(
const <String>['build', 'ipa', '--no-pub'] const <String>['build', 'ipa', '--no-pub']
...@@ -176,7 +176,7 @@ void main() { ...@@ -176,7 +176,7 @@ void main() {
testUsingContext('ipa build fails in debug with code analysis', () async { testUsingContext('ipa build fails in debug with code analysis', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
_createCoreMockProjectFiles(); createCoreMockProjectFiles();
expect(createTestCommandRunner(command).run( expect(createTestCommandRunner(command).run(
const <String>['build', 'ipa', '--no-pub', '--debug', '--analyze-size'] const <String>['build', 'ipa', '--no-pub', '--debug', '--analyze-size']
...@@ -209,7 +209,7 @@ void main() { ...@@ -209,7 +209,7 @@ void main() {
testUsingContext('ipa build fails when export plist does not exist', testUsingContext('ipa build fails when export plist does not exist',
() async { () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await expectToolExitLater( await expectToolExitLater(
createTestCommandRunner(command).run(<String>[ createTestCommandRunner(command).run(<String>[
...@@ -232,7 +232,7 @@ void main() { ...@@ -232,7 +232,7 @@ void main() {
testUsingContext('ipa build fails when export plist is not a file', () async { testUsingContext('ipa build fails when export plist is not a file', () async {
final Directory bogus = fileSystem.directory('bogus')..createSync(); final Directory bogus = fileSystem.directory('bogus')..createSync();
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await expectToolExitLater( await expectToolExitLater(
createTestCommandRunner(command).run(<String>[ createTestCommandRunner(command).run(<String>[
...@@ -254,7 +254,7 @@ void main() { ...@@ -254,7 +254,7 @@ void main() {
testUsingContext('ipa build fails when --export-options-plist and --export-method are used together', () async { testUsingContext('ipa build fails when --export-options-plist and --export-method are used together', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await expectToolExitLater( await expectToolExitLater(
createTestCommandRunner(command).run(<String>[ createTestCommandRunner(command).run(<String>[
...@@ -280,7 +280,7 @@ void main() { ...@@ -280,7 +280,7 @@ void main() {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
fakeProcessManager.addCommands(<FakeCommand>[ fakeProcessManager.addCommands(<FakeCommand>[
xattrCommand, xattrCommand,
_setUpFakeXcodeBuildHandler(), setUpFakeXcodeBuildHandler(),
const FakeCommand( const FakeCommand(
command: <String>[ command: <String>[
'xcrun', 'xcrun',
...@@ -299,7 +299,7 @@ void main() { ...@@ -299,7 +299,7 @@ void main() {
stderr: 'error: exportArchive: "Runner.app" requires a provisioning profile.', stderr: 'error: exportArchive: "Runner.app" requires a provisioning profile.',
), ),
]); ]);
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await createTestCommandRunner(command).run( await createTestCommandRunner(command).run(
const <String>['build', 'ipa', '--no-pub'] const <String>['build', 'ipa', '--no-pub']
...@@ -322,10 +322,10 @@ void main() { ...@@ -322,10 +322,10 @@ void main() {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
fakeProcessManager.addCommands(<FakeCommand>[ fakeProcessManager.addCommands(<FakeCommand>[
xattrCommand, xattrCommand,
_setUpFakeXcodeBuildHandler(), setUpFakeXcodeBuildHandler(),
_exportArchiveCommand(exportOptionsPlist: _exportOptionsPlist, cachePlist: cachedExportOptionsPlist), exportArchiveCommand(exportOptionsPlist: _exportOptionsPlist, cachePlist: cachedExportOptionsPlist),
]); ]);
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await createTestCommandRunner(command).run( await createTestCommandRunner(command).run(
const <String>['build', 'ipa', '--no-pub'] const <String>['build', 'ipa', '--no-pub']
...@@ -364,10 +364,10 @@ void main() { ...@@ -364,10 +364,10 @@ void main() {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
fakeProcessManager.addCommands(<FakeCommand>[ fakeProcessManager.addCommands(<FakeCommand>[
xattrCommand, xattrCommand,
_setUpFakeXcodeBuildHandler(), setUpFakeXcodeBuildHandler(),
_exportArchiveCommand(exportOptionsPlist: _exportOptionsPlist, cachePlist: cachedExportOptionsPlist), exportArchiveCommand(exportOptionsPlist: _exportOptionsPlist, cachePlist: cachedExportOptionsPlist),
]); ]);
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await createTestCommandRunner(command).run( await createTestCommandRunner(command).run(
const <String>['build', 'ipa', '--no-pub', '--export-method', 'ad-hoc'] const <String>['build', 'ipa', '--no-pub', '--export-method', 'ad-hoc']
...@@ -407,10 +407,10 @@ void main() { ...@@ -407,10 +407,10 @@ void main() {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
fakeProcessManager.addCommands(<FakeCommand>[ fakeProcessManager.addCommands(<FakeCommand>[
xattrCommand, xattrCommand,
_setUpFakeXcodeBuildHandler(), setUpFakeXcodeBuildHandler(),
_exportArchiveCommand(exportOptionsPlist: _exportOptionsPlist, cachePlist: cachedExportOptionsPlist), exportArchiveCommand(exportOptionsPlist: _exportOptionsPlist, cachePlist: cachedExportOptionsPlist),
]); ]);
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await createTestCommandRunner(command).run( await createTestCommandRunner(command).run(
const <String>['build', 'ipa', '--no-pub', '--export-method', 'enterprise'] const <String>['build', 'ipa', '--no-pub', '--export-method', 'enterprise']
...@@ -450,10 +450,10 @@ void main() { ...@@ -450,10 +450,10 @@ void main() {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
fakeProcessManager.addCommands(<FakeCommand>[ fakeProcessManager.addCommands(<FakeCommand>[
xattrCommand, xattrCommand,
_setUpFakeXcodeBuildHandler(), setUpFakeXcodeBuildHandler(),
_exportArchiveCommand(exportOptionsPlist: _exportOptionsPlist, cachePlist: cachedExportOptionsPlist), exportArchiveCommand(exportOptionsPlist: _exportOptionsPlist, cachePlist: cachedExportOptionsPlist),
]); ]);
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await createTestCommandRunner(command).run( await createTestCommandRunner(command).run(
const <String>['build', 'ipa', '--no-pub',] const <String>['build', 'ipa', '--no-pub',]
...@@ -485,10 +485,10 @@ void main() { ...@@ -485,10 +485,10 @@ void main() {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
fakeProcessManager.addCommands(<FakeCommand>[ fakeProcessManager.addCommands(<FakeCommand>[
xattrCommand, xattrCommand,
_setUpFakeXcodeBuildHandler(verbose: true), setUpFakeXcodeBuildHandler(verbose: true),
_exportArchiveCommand(exportOptionsPlist: _exportOptionsPlist), exportArchiveCommand(exportOptionsPlist: _exportOptionsPlist),
]); ]);
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await createTestCommandRunner(command).run( await createTestCommandRunner(command).run(
const <String>['build', 'ipa', '--no-pub', '-v'] const <String>['build', 'ipa', '--no-pub', '-v']
...@@ -530,7 +530,7 @@ void main() { ...@@ -530,7 +530,7 @@ void main() {
], ],
), ),
]); ]);
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await createTestCommandRunner(command).run( await createTestCommandRunner(command).run(
const <String>['build', 'ipa', '--no-pub', '--no-codesign'] const <String>['build', 'ipa', '--no-pub', '--no-codesign']
...@@ -546,7 +546,7 @@ void main() { ...@@ -546,7 +546,7 @@ void main() {
testUsingContext('code size analysis fails when app not found', () async { testUsingContext('code size analysis fails when app not found', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await expectToolExitLater( await expectToolExitLater(
createTestCommandRunner(command).run( createTestCommandRunner(command).run(
...@@ -564,14 +564,14 @@ void main() { ...@@ -564,14 +564,14 @@ void main() {
testUsingContext('Performs code size analysis and sends analytics', () async { testUsingContext('Performs code size analysis and sends analytics', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
fileSystem.file('build/ios/archive/Runner.xcarchive/Products/Applications/Runner.app/Frameworks/App.framework/App') fileSystem.file('build/ios/archive/Runner.xcarchive/Products/Applications/Runner.app/Frameworks/App.framework/App')
..createSync(recursive: true) ..createSync(recursive: true)
..writeAsBytesSync(List<int>.generate(10000, (int index) => 0)); ..writeAsBytesSync(List<int>.generate(10000, (int index) => 0));
fakeProcessManager.addCommands(<FakeCommand>[ fakeProcessManager.addCommands(<FakeCommand>[
xattrCommand, xattrCommand,
_setUpFakeXcodeBuildHandler(onRun: () { setUpFakeXcodeBuildHandler(onRun: () {
fileSystem.file('build/flutter_size_01/snapshot.arm64.json') fileSystem.file('build/flutter_size_01/snapshot.arm64.json')
..createSync(recursive: true) ..createSync(recursive: true)
..writeAsStringSync(''' ..writeAsStringSync('''
...@@ -587,7 +587,7 @@ void main() { ...@@ -587,7 +587,7 @@ void main() {
..createSync(recursive: true) ..createSync(recursive: true)
..writeAsStringSync('{}'); ..writeAsStringSync('{}');
}), }),
_exportArchiveCommand(exportOptionsPlist: _exportOptionsPlist), exportArchiveCommand(exportOptionsPlist: _exportOptionsPlist),
]); ]);
await createTestCommandRunner(command).run( await createTestCommandRunner(command).run(
...@@ -617,10 +617,10 @@ void main() { ...@@ -617,10 +617,10 @@ void main() {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
fakeProcessManager.addCommands(<FakeCommand>[ fakeProcessManager.addCommands(<FakeCommand>[
xattrCommand, xattrCommand,
_setUpFakeXcodeBuildHandler(), setUpFakeXcodeBuildHandler(),
_exportArchiveCommand(), exportArchiveCommand(),
]); ]);
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await createTestCommandRunner(command).run( await createTestCommandRunner(command).run(
<String>[ <String>[
...@@ -646,12 +646,12 @@ void main() { ...@@ -646,12 +646,12 @@ void main() {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
fakeProcessManager.addCommands(<FakeCommand>[ fakeProcessManager.addCommands(<FakeCommand>[
xattrCommand, xattrCommand,
_setUpFakeXcodeBuildHandler(exitCode: 1, onRun: () { setUpFakeXcodeBuildHandler(exitCode: 1, onRun: () {
fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync(); fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync();
}), }),
_setUpXCResultCommand(), setUpXCResultCommand(),
]); ]);
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await expectLater( await expectLater(
createTestCommandRunner(command).run(const <String>['build', 'ipa', '--no-pub']), createTestCommandRunner(command).run(const <String>['build', 'ipa', '--no-pub']),
...@@ -671,12 +671,12 @@ void main() { ...@@ -671,12 +671,12 @@ void main() {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
fakeProcessManager.addCommands(<FakeCommand>[ fakeProcessManager.addCommands(<FakeCommand>[
xattrCommand, xattrCommand,
_setUpFakeXcodeBuildHandler(exitCode: 1, onRun: () { setUpFakeXcodeBuildHandler(exitCode: 1, onRun: () {
fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync(); fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync();
}), }),
_setUpXCResultCommand(stdout: kSampleResultJsonWithIssues), setUpXCResultCommand(stdout: kSampleResultJsonWithIssues),
]); ]);
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await expectLater( await expectLater(
createTestCommandRunner(command).run(const <String>['build', 'ipa', '--no-pub']), createTestCommandRunner(command).run(const <String>['build', 'ipa', '--no-pub']),
...@@ -697,12 +697,12 @@ void main() { ...@@ -697,12 +697,12 @@ void main() {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
fakeProcessManager.addCommands(<FakeCommand>[ fakeProcessManager.addCommands(<FakeCommand>[
xattrCommand, xattrCommand,
_setUpFakeXcodeBuildHandler(exitCode: 1, onRun: () { setUpFakeXcodeBuildHandler(exitCode: 1, onRun: () {
fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync(); fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync();
}), }),
_setUpXCResultCommand(stdout: kSampleResultJsonWithIssuesToBeDiscarded), setUpXCResultCommand(stdout: kSampleResultJsonWithIssuesToBeDiscarded),
]); ]);
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await expectLater( await expectLater(
createTestCommandRunner(command).run(const <String>['build', 'ipa', '--no-pub']), createTestCommandRunner(command).run(const <String>['build', 'ipa', '--no-pub']),
...@@ -725,9 +725,9 @@ void main() { ...@@ -725,9 +725,9 @@ void main() {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
fakeProcessManager.addCommands(<FakeCommand>[ fakeProcessManager.addCommands(<FakeCommand>[
xattrCommand, xattrCommand,
_setUpFakeXcodeBuildHandler(exitCode: 1), setUpFakeXcodeBuildHandler(exitCode: 1),
]); ]);
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await expectLater( await expectLater(
createTestCommandRunner(command).run(const <String>['build', 'ipa', '--no-pub']), createTestCommandRunner(command).run(const <String>['build', 'ipa', '--no-pub']),
...@@ -748,12 +748,12 @@ void main() { ...@@ -748,12 +748,12 @@ void main() {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
fakeProcessManager.addCommands(<FakeCommand>[ fakeProcessManager.addCommands(<FakeCommand>[
xattrCommand, xattrCommand,
_setUpFakeXcodeBuildHandler(exitCode: 1, onRun: () { setUpFakeXcodeBuildHandler(exitCode: 1, onRun: () {
fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync(); fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync();
}), }),
_setUpXCResultCommand(stdout: kSampleResultJsonWithProvisionIssue), setUpXCResultCommand(stdout: kSampleResultJsonWithProvisionIssue),
]); ]);
_createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
await expectLater( await expectLater(
createTestCommandRunner(command).run(const <String>['build', 'ipa', '--no-pub']), createTestCommandRunner(command).run(const <String>['build', 'ipa', '--no-pub']),
......
...@@ -22,7 +22,7 @@ void main() { ...@@ -22,7 +22,7 @@ void main() {
Directory intellijDir; Directory intellijDir;
Directory toolsDir; Directory toolsDir;
Map<String, String> _getFilesystemContents([ Directory root ]) { Map<String, String> getFilesystemContents([ Directory root ]) {
final String tempPath = tempDir.absolute.path; final String tempPath = tempDir.absolute.path;
final List<String> paths = final List<String> paths =
(root ?? tempDir).listSync(recursive: true).map((FileSystemEntity entity) { (root ?? tempDir).listSync(recursive: true).map((FileSystemEntity entity) {
...@@ -41,7 +41,7 @@ void main() { ...@@ -41,7 +41,7 @@ void main() {
return contents; return contents;
} }
Map<String, String> _getManifest(Directory base, String marker, { bool isTemplate = false }) { Map<String, String> getManifest(Directory base, String marker, { bool isTemplate = false }) {
final String basePath = globals.fs.path.relative(base.path, from: tempDir.absolute.path); final String basePath = globals.fs.path.relative(base.path, from: tempDir.absolute.path);
final String suffix = isTemplate ? Template.copyTemplateExtension : ''; final String suffix = isTemplate ? Template.copyTemplateExtension : '';
return <String, String>{ return <String, String>{
...@@ -57,7 +57,7 @@ void main() { ...@@ -57,7 +57,7 @@ void main() {
}; };
} }
void _populateDir(Map<String, String> manifest) { void populateDir(Map<String, String> manifest) {
for (final String key in manifest.keys) { for (final String key in manifest.keys) {
if (manifest[key] == 'dir') { if (manifest[key] == 'dir') {
tempDir.childDirectory(key).createSync(recursive: true); tempDir.childDirectory(key).createSync(recursive: true);
...@@ -72,12 +72,12 @@ void main() { ...@@ -72,12 +72,12 @@ void main() {
} }
} }
bool _fileOrDirectoryExists(String path) { bool fileOrDirectoryExists(String path) {
final String absPath = globals.fs.path.join(tempDir.absolute.path, path); final String absPath = globals.fs.path.join(tempDir.absolute.path, path);
return globals.fs.file(absPath).existsSync() || globals.fs.directory(absPath).existsSync(); return globals.fs.file(absPath).existsSync() || globals.fs.directory(absPath).existsSync();
} }
Future<void> _updateIdeConfig({ Future<void> updateIdeConfig({
Directory dir, Directory dir,
List<String> args = const <String>[], List<String> args = const <String>[],
Map<String, String> expectedContents = const <String, String>{}, Map<String, String> expectedContents = const <String, String>{},
...@@ -94,7 +94,7 @@ void main() { ...@@ -94,7 +94,7 @@ void main() {
for (final String path in expectedContents.keys) { for (final String path in expectedContents.keys) {
final String absPath = globals.fs.path.join(tempDir.absolute.path, path); final String absPath = globals.fs.path.join(tempDir.absolute.path, path);
expect(_fileOrDirectoryExists(globals.fs.path.join(dir.path, path)), true, expect(fileOrDirectoryExists(globals.fs.path.join(dir.path, path)), true,
reason: "$path doesn't exist"); reason: "$path doesn't exist");
if (globals.fs.file(absPath).existsSync()) { if (globals.fs.file(absPath).existsSync()) {
expect(globals.fs.file(absPath).readAsStringSync(), equals(expectedContents[path]), expect(globals.fs.file(absPath).readAsStringSync(), equals(expectedContents[path]),
...@@ -102,7 +102,7 @@ void main() { ...@@ -102,7 +102,7 @@ void main() {
} }
} }
for (final String path in unexpectedPaths) { for (final String path in unexpectedPaths) {
expect(_fileOrDirectoryExists(globals.fs.path.join(dir.path, path)), false, reason: '$path exists'); expect(fileOrDirectoryExists(globals.fs.path.join(dir.path, path)), false, reason: '$path exists');
} }
} }
...@@ -123,56 +123,56 @@ void main() { ...@@ -123,56 +123,56 @@ void main() {
}); });
testUsingContext("doesn't touch existing files without --overwrite", () async { testUsingContext("doesn't touch existing files without --overwrite", () async {
final Map<String, String> templateManifest = _getManifest( final Map<String, String> templateManifest = getManifest(
intellijDir, intellijDir,
'template', 'template',
isTemplate: true, isTemplate: true,
); );
final Map<String, String> flutterManifest = _getManifest( final Map<String, String> flutterManifest = getManifest(
tempDir, tempDir,
'existing', 'existing',
); );
_populateDir(templateManifest); populateDir(templateManifest);
_populateDir(flutterManifest); populateDir(flutterManifest);
final Map<String, String> expectedContents = _getFilesystemContents(); final Map<String, String> expectedContents = getFilesystemContents();
return _updateIdeConfig( return updateIdeConfig(
expectedContents: expectedContents, expectedContents: expectedContents,
); );
}); });
testUsingContext('creates non-existent files', () async { testUsingContext('creates non-existent files', () async {
final Map<String, String> templateManifest = _getManifest( final Map<String, String> templateManifest = getManifest(
intellijDir, intellijDir,
'template', 'template',
isTemplate: true, isTemplate: true,
); );
final Map<String, String> flutterManifest = _getManifest( final Map<String, String> flutterManifest = getManifest(
tempDir, tempDir,
'template', 'template',
); );
_populateDir(templateManifest); populateDir(templateManifest);
final Map<String, String> expectedContents = <String, String>{ final Map<String, String> expectedContents = <String, String>{
...templateManifest, ...templateManifest,
...flutterManifest, ...flutterManifest,
}; };
return _updateIdeConfig( return updateIdeConfig(
expectedContents: expectedContents, expectedContents: expectedContents,
); );
}); });
testUsingContext('overwrites existing files with --overwrite', () async { testUsingContext('overwrites existing files with --overwrite', () async {
final Map<String, String> templateManifest = _getManifest( final Map<String, String> templateManifest = getManifest(
intellijDir, intellijDir,
'template', 'template',
isTemplate: true, isTemplate: true,
); );
final Map<String, String> flutterManifest = _getManifest( final Map<String, String> flutterManifest = getManifest(
tempDir, tempDir,
'existing', 'existing',
); );
_populateDir(templateManifest); populateDir(templateManifest);
_populateDir(flutterManifest); populateDir(flutterManifest);
final Map<String, String> overwrittenManifest = _getManifest( final Map<String, String> overwrittenManifest = getManifest(
tempDir, tempDir,
'template', 'template',
); );
...@@ -180,14 +180,14 @@ void main() { ...@@ -180,14 +180,14 @@ void main() {
...templateManifest, ...templateManifest,
...overwrittenManifest, ...overwrittenManifest,
}; };
return _updateIdeConfig( return updateIdeConfig(
args: <String>['--overwrite'], args: <String>['--overwrite'],
expectedContents: expectedContents, expectedContents: expectedContents,
); );
}); });
testUsingContext('only adds new templates without --overwrite', () async { testUsingContext('only adds new templates without --overwrite', () async {
final Map<String, String> templateManifest = _getManifest( final Map<String, String> templateManifest = getManifest(
intellijDir, intellijDir,
'template', 'template',
isTemplate: true, isTemplate: true,
...@@ -200,36 +200,36 @@ void main() { ...@@ -200,36 +200,36 @@ void main() {
'flutter.iml${Template.copyTemplateExtension}', 'flutter.iml${Template.copyTemplateExtension}',
); );
templateManifest.remove(flutterIml); templateManifest.remove(flutterIml);
_populateDir(templateManifest); populateDir(templateManifest);
templateManifest[flutterIml] = 'flutter existing'; templateManifest[flutterIml] = 'flutter existing';
final Map<String, String> flutterManifest = _getManifest( final Map<String, String> flutterManifest = getManifest(
tempDir, tempDir,
'existing', 'existing',
); );
_populateDir(flutterManifest); populateDir(flutterManifest);
final Map<String, String> expectedContents = <String, String>{ final Map<String, String> expectedContents = <String, String>{
...flutterManifest, ...flutterManifest,
...templateManifest, ...templateManifest,
}; };
return _updateIdeConfig( return updateIdeConfig(
args: <String>['--update-templates'], args: <String>['--update-templates'],
expectedContents: expectedContents, expectedContents: expectedContents,
); );
}); });
testUsingContext('update all templates with --overwrite', () async { testUsingContext('update all templates with --overwrite', () async {
final Map<String, String> templateManifest = _getManifest( final Map<String, String> templateManifest = getManifest(
intellijDir, intellijDir,
'template', 'template',
isTemplate: true, isTemplate: true,
); );
_populateDir(templateManifest); populateDir(templateManifest);
final Map<String, String> flutterManifest = _getManifest( final Map<String, String> flutterManifest = getManifest(
tempDir, tempDir,
'existing', 'existing',
); );
_populateDir(flutterManifest); populateDir(flutterManifest);
final Map<String, String> updatedTemplates = _getManifest( final Map<String, String> updatedTemplates = getManifest(
intellijDir, intellijDir,
'existing', 'existing',
isTemplate: true, isTemplate: true,
...@@ -238,26 +238,26 @@ void main() { ...@@ -238,26 +238,26 @@ void main() {
...flutterManifest, ...flutterManifest,
...updatedTemplates, ...updatedTemplates,
}; };
return _updateIdeConfig( return updateIdeConfig(
args: <String>['--update-templates', '--overwrite'], args: <String>['--update-templates', '--overwrite'],
expectedContents: expectedContents, expectedContents: expectedContents,
); );
}); });
testUsingContext('removes deleted imls with --overwrite', () async { testUsingContext('removes deleted imls with --overwrite', () async {
final Map<String, String> templateManifest = _getManifest( final Map<String, String> templateManifest = getManifest(
intellijDir, intellijDir,
'template', 'template',
isTemplate: true, isTemplate: true,
); );
_populateDir(templateManifest); populateDir(templateManifest);
final Map<String, String> flutterManifest = _getManifest( final Map<String, String> flutterManifest = getManifest(
tempDir, tempDir,
'existing', 'existing',
); );
flutterManifest.remove('flutter.iml'); flutterManifest.remove('flutter.iml');
_populateDir(flutterManifest); populateDir(flutterManifest);
final Map<String, String> updatedTemplates = _getManifest( final Map<String, String> updatedTemplates = getManifest(
intellijDir, intellijDir,
'existing', 'existing',
isTemplate: true, isTemplate: true,
...@@ -274,26 +274,26 @@ void main() { ...@@ -274,26 +274,26 @@ void main() {
...flutterManifest, ...flutterManifest,
...updatedTemplates, ...updatedTemplates,
}; };
return _updateIdeConfig( return updateIdeConfig(
args: <String>['--update-templates', '--overwrite'], args: <String>['--update-templates', '--overwrite'],
expectedContents: expectedContents, expectedContents: expectedContents,
); );
}); });
testUsingContext('removes deleted imls with --overwrite, including empty parent dirs', () async { testUsingContext('removes deleted imls with --overwrite, including empty parent dirs', () async {
final Map<String, String> templateManifest = _getManifest( final Map<String, String> templateManifest = getManifest(
intellijDir, intellijDir,
'template', 'template',
isTemplate: true, isTemplate: true,
); );
_populateDir(templateManifest); populateDir(templateManifest);
final Map<String, String> flutterManifest = _getManifest( final Map<String, String> flutterManifest = getManifest(
tempDir, tempDir,
'existing', 'existing',
); );
flutterManifest.remove(globals.fs.path.join('packages', 'new', 'deep.iml')); flutterManifest.remove(globals.fs.path.join('packages', 'new', 'deep.iml'));
_populateDir(flutterManifest); populateDir(flutterManifest);
final Map<String, String> updatedTemplates = _getManifest( final Map<String, String> updatedTemplates = getManifest(
intellijDir, intellijDir,
'existing', 'existing',
isTemplate: true, isTemplate: true,
...@@ -315,7 +315,7 @@ void main() { ...@@ -315,7 +315,7 @@ void main() {
...flutterManifest, ...flutterManifest,
...updatedTemplates, ...updatedTemplates,
}; };
return _updateIdeConfig( return updateIdeConfig(
args: <String>['--update-templates', '--overwrite'], args: <String>['--update-templates', '--overwrite'],
expectedContents: expectedContents, expectedContents: expectedContents,
); );
......
...@@ -14,7 +14,7 @@ void main() { ...@@ -14,7 +14,7 @@ void main() {
final FakePlatform linuxPlatform = FakePlatform(); final FakePlatform linuxPlatform = FakePlatform();
final FakePlatform windowsPlatform = FakePlatform(operatingSystem: 'windows'); final FakePlatform windowsPlatform = FakePlatform(operatingSystem: 'windows');
void _checkInstallationURL(_InstallationMessage message) { void checkInstallationURL(_InstallationMessage message) {
expect(message(macPlatform), contains('https://flutter.dev/docs/get-started/install/macos#android-setup')); expect(message(macPlatform), contains('https://flutter.dev/docs/get-started/install/macos#android-setup'));
expect(message(linuxPlatform), contains('https://flutter.dev/docs/get-started/install/linux#android-setup')); expect(message(linuxPlatform), contains('https://flutter.dev/docs/get-started/install/linux#android-setup'));
expect(message(windowsPlatform), contains('https://flutter.dev/docs/get-started/install/windows#android-setup')); expect(message(windowsPlatform), contains('https://flutter.dev/docs/get-started/install/windows#android-setup'));
...@@ -23,11 +23,11 @@ void main() { ...@@ -23,11 +23,11 @@ void main() {
testWithoutContext('Android installation instructions', () { testWithoutContext('Android installation instructions', () {
final UserMessages userMessages = UserMessages(); final UserMessages userMessages = UserMessages();
_checkInstallationURL((Platform platform) => userMessages.androidMissingSdkInstructions(platform)); checkInstallationURL((Platform platform) => userMessages.androidMissingSdkInstructions(platform));
_checkInstallationURL((Platform platform) => userMessages.androidSdkInstallHelp(platform)); checkInstallationURL((Platform platform) => userMessages.androidSdkInstallHelp(platform));
_checkInstallationURL((Platform platform) => userMessages.androidMissingSdkManager('/', platform)); checkInstallationURL((Platform platform) => userMessages.androidMissingSdkManager('/', platform));
_checkInstallationURL((Platform platform) => userMessages.androidCannotRunSdkManager('/', '', platform)); checkInstallationURL((Platform platform) => userMessages.androidCannotRunSdkManager('/', '', platform));
_checkInstallationURL((Platform platform) => userMessages.androidSdkBuildToolsOutdated(0, '', platform)); checkInstallationURL((Platform platform) => userMessages.androidSdkBuildToolsOutdated(0, '', platform));
_checkInstallationURL((Platform platform) => userMessages.androidStudioInstallation(platform)); checkInstallationURL((Platform platform) => userMessages.androidStudioInstallation(platform));
}); });
} }
...@@ -35,7 +35,7 @@ void main() { ...@@ -35,7 +35,7 @@ void main() {
late String fontSubsetPath; late String fontSubsetPath;
late List<String> fontSubsetArgs; late List<String> fontSubsetArgs;
List<String> _getConstFinderArgs(String appDillPath) => <String>[ List<String> getConstFinderArgs(String appDillPath) => <String>[
dartPath, dartPath,
'--disable-dart-dev', '--disable-dart-dev',
constFinderPath, constFinderPath,
...@@ -44,21 +44,21 @@ void main() { ...@@ -44,21 +44,21 @@ void main() {
'--class-name', 'IconData', '--class-name', 'IconData',
]; ];
void _addConstFinderInvocation( void addConstFinderInvocation(
String appDillPath, { String appDillPath, {
int exitCode = 0, int exitCode = 0,
String stdout = '', String stdout = '',
String stderr = '', String stderr = '',
}) { }) {
processManager.addCommand(FakeCommand( processManager.addCommand(FakeCommand(
command: _getConstFinderArgs(appDillPath), command: getConstFinderArgs(appDillPath),
exitCode: exitCode, exitCode: exitCode,
stdout: stdout, stdout: stdout,
stderr: stderr, stderr: stderr,
)); ));
} }
void _resetFontSubsetInvocation({ void resetFontSubsetInvocation({
int exitCode = 0, int exitCode = 0,
String stdout = '', String stdout = '',
String stderr = '', String stderr = '',
...@@ -99,7 +99,7 @@ void main() { ...@@ -99,7 +99,7 @@ void main() {
..writeAsBytesSync(_kTtfHeaderBytes); ..writeAsBytesSync(_kTtfHeaderBytes);
}); });
Environment _createEnvironment(Map<String, String> defines) { Environment createEnvironment(Map<String, String> defines) {
return Environment.test( return Environment.test(
fileSystem.directory('/icon_test')..createSync(recursive: true), fileSystem.directory('/icon_test')..createSync(recursive: true),
defines: defines, defines: defines,
...@@ -111,7 +111,7 @@ void main() { ...@@ -111,7 +111,7 @@ void main() {
} }
testWithoutContext('Prints error in debug mode environment', () async { testWithoutContext('Prints error in debug mode environment', () async {
final Environment environment = _createEnvironment(<String, String>{ final Environment environment = createEnvironment(<String, String>{
kIconTreeShakerFlag: 'true', kIconTreeShakerFlag: 'true',
kBuildMode: 'debug', kBuildMode: 'debug',
}); });
...@@ -142,7 +142,7 @@ void main() { ...@@ -142,7 +142,7 @@ void main() {
}); });
testWithoutContext('Does not get enabled without font manifest', () { testWithoutContext('Does not get enabled without font manifest', () {
final Environment environment = _createEnvironment(<String, String>{ final Environment environment = createEnvironment(<String, String>{
kIconTreeShakerFlag: 'true', kIconTreeShakerFlag: 'true',
kBuildMode: 'release', kBuildMode: 'release',
}); });
...@@ -165,7 +165,7 @@ void main() { ...@@ -165,7 +165,7 @@ void main() {
}); });
testWithoutContext('Gets enabled', () { testWithoutContext('Gets enabled', () {
final Environment environment = _createEnvironment(<String, String>{ final Environment environment = createEnvironment(<String, String>{
kIconTreeShakerFlag: 'true', kIconTreeShakerFlag: 'true',
kBuildMode: 'release', kBuildMode: 'release',
}); });
...@@ -188,7 +188,7 @@ void main() { ...@@ -188,7 +188,7 @@ void main() {
}); });
test('No app.dill throws exception', () async { test('No app.dill throws exception', () async {
final Environment environment = _createEnvironment(<String, String>{ final Environment environment = createEnvironment(<String, String>{
kIconTreeShakerFlag: 'true', kIconTreeShakerFlag: 'true',
kBuildMode: 'release', kBuildMode: 'release',
}); });
...@@ -214,7 +214,7 @@ void main() { ...@@ -214,7 +214,7 @@ void main() {
}); });
testWithoutContext('Can subset a font', () async { testWithoutContext('Can subset a font', () async {
final Environment environment = _createEnvironment(<String, String>{ final Environment environment = createEnvironment(<String, String>{
kIconTreeShakerFlag: 'true', kIconTreeShakerFlag: 'true',
kBuildMode: 'release', kBuildMode: 'release',
}); });
...@@ -231,8 +231,8 @@ void main() { ...@@ -231,8 +231,8 @@ void main() {
); );
final CompleterIOSink stdinSink = CompleterIOSink(); final CompleterIOSink stdinSink = CompleterIOSink();
_addConstFinderInvocation(appDill.path, stdout: validConstFinderResult); addConstFinderInvocation(appDill.path, stdout: validConstFinderResult);
_resetFontSubsetInvocation(stdinSink: stdinSink); resetFontSubsetInvocation(stdinSink: stdinSink);
bool subsetted = await iconTreeShaker.subsetFont( bool subsetted = await iconTreeShaker.subsetFont(
input: fileSystem.file(inputPath), input: fileSystem.file(inputPath),
...@@ -240,7 +240,7 @@ void main() { ...@@ -240,7 +240,7 @@ void main() {
relativePath: relativePath, relativePath: relativePath,
); );
expect(stdinSink.getAndClear(), '59470\n'); expect(stdinSink.getAndClear(), '59470\n');
_resetFontSubsetInvocation(stdinSink: stdinSink); resetFontSubsetInvocation(stdinSink: stdinSink);
expect(subsetted, true); expect(subsetted, true);
subsetted = await iconTreeShaker.subsetFont( subsetted = await iconTreeShaker.subsetFont(
...@@ -254,7 +254,7 @@ void main() { ...@@ -254,7 +254,7 @@ void main() {
}); });
testWithoutContext('Does not subset a non-supported font', () async { testWithoutContext('Does not subset a non-supported font', () async {
final Environment environment = _createEnvironment(<String, String>{ final Environment environment = createEnvironment(<String, String>{
kIconTreeShakerFlag: 'true', kIconTreeShakerFlag: 'true',
kBuildMode: 'release', kBuildMode: 'release',
}); });
...@@ -271,8 +271,8 @@ void main() { ...@@ -271,8 +271,8 @@ void main() {
); );
final CompleterIOSink stdinSink = CompleterIOSink(); final CompleterIOSink stdinSink = CompleterIOSink();
_addConstFinderInvocation(appDill.path, stdout: validConstFinderResult); addConstFinderInvocation(appDill.path, stdout: validConstFinderResult);
_resetFontSubsetInvocation(stdinSink: stdinSink); resetFontSubsetInvocation(stdinSink: stdinSink);
final File notAFont = fileSystem.file('input/foo/bar.txt') final File notAFont = fileSystem.file('input/foo/bar.txt')
..createSync(recursive: true) ..createSync(recursive: true)
...@@ -286,7 +286,7 @@ void main() { ...@@ -286,7 +286,7 @@ void main() {
}); });
testWithoutContext('Does not subset an invalid ttf font', () async { testWithoutContext('Does not subset an invalid ttf font', () async {
final Environment environment = _createEnvironment(<String, String>{ final Environment environment = createEnvironment(<String, String>{
kIconTreeShakerFlag: 'true', kIconTreeShakerFlag: 'true',
kBuildMode: 'release', kBuildMode: 'release',
}); });
...@@ -303,8 +303,8 @@ void main() { ...@@ -303,8 +303,8 @@ void main() {
); );
final CompleterIOSink stdinSink = CompleterIOSink(); final CompleterIOSink stdinSink = CompleterIOSink();
_addConstFinderInvocation(appDill.path, stdout: validConstFinderResult); addConstFinderInvocation(appDill.path, stdout: validConstFinderResult);
_resetFontSubsetInvocation(stdinSink: stdinSink); resetFontSubsetInvocation(stdinSink: stdinSink);
final File notAFont = fileSystem.file(inputPath) final File notAFont = fileSystem.file(inputPath)
..writeAsBytesSync(<int>[0, 1, 2]); ..writeAsBytesSync(<int>[0, 1, 2]);
...@@ -318,7 +318,7 @@ void main() { ...@@ -318,7 +318,7 @@ void main() {
}); });
testWithoutContext('Non-constant instances', () async { testWithoutContext('Non-constant instances', () async {
final Environment environment = _createEnvironment(<String, String>{ final Environment environment = createEnvironment(<String, String>{
kIconTreeShakerFlag: 'true', kIconTreeShakerFlag: 'true',
kBuildMode: 'release', kBuildMode: 'release',
}); });
...@@ -334,7 +334,7 @@ void main() { ...@@ -334,7 +334,7 @@ void main() {
artifacts: artifacts, artifacts: artifacts,
); );
_addConstFinderInvocation(appDill.path, stdout: constFinderResultWithInvalid); addConstFinderInvocation(appDill.path, stdout: constFinderResultWithInvalid);
await expectLater( await expectLater(
() => iconTreeShaker.subsetFont( () => iconTreeShaker.subsetFont(
...@@ -352,7 +352,7 @@ void main() { ...@@ -352,7 +352,7 @@ void main() {
}); });
testWithoutContext('Non-zero font-subset exit code', () async { testWithoutContext('Non-zero font-subset exit code', () async {
final Environment environment = _createEnvironment(<String, String>{ final Environment environment = createEnvironment(<String, String>{
kIconTreeShakerFlag: 'true', kIconTreeShakerFlag: 'true',
kBuildMode: 'release', kBuildMode: 'release',
}); });
...@@ -370,8 +370,8 @@ void main() { ...@@ -370,8 +370,8 @@ void main() {
); );
final CompleterIOSink stdinSink = CompleterIOSink(); final CompleterIOSink stdinSink = CompleterIOSink();
_addConstFinderInvocation(appDill.path, stdout: validConstFinderResult); addConstFinderInvocation(appDill.path, stdout: validConstFinderResult);
_resetFontSubsetInvocation(exitCode: -1, stdinSink: stdinSink); resetFontSubsetInvocation(exitCode: -1, stdinSink: stdinSink);
await expectLater( await expectLater(
() => iconTreeShaker.subsetFont( () => iconTreeShaker.subsetFont(
...@@ -385,7 +385,7 @@ void main() { ...@@ -385,7 +385,7 @@ void main() {
}); });
testWithoutContext('font-subset throws on write to sdtin', () async { testWithoutContext('font-subset throws on write to sdtin', () async {
final Environment environment = _createEnvironment(<String, String>{ final Environment environment = createEnvironment(<String, String>{
kIconTreeShakerFlag: 'true', kIconTreeShakerFlag: 'true',
kBuildMode: 'release', kBuildMode: 'release',
}); });
...@@ -402,8 +402,8 @@ void main() { ...@@ -402,8 +402,8 @@ void main() {
); );
final CompleterIOSink stdinSink = CompleterIOSink(throwOnAdd: true); final CompleterIOSink stdinSink = CompleterIOSink(throwOnAdd: true);
_addConstFinderInvocation(appDill.path, stdout: validConstFinderResult); addConstFinderInvocation(appDill.path, stdout: validConstFinderResult);
_resetFontSubsetInvocation(exitCode: -1, stdinSink: stdinSink); resetFontSubsetInvocation(exitCode: -1, stdinSink: stdinSink);
await expectLater( await expectLater(
() => iconTreeShaker.subsetFont( () => iconTreeShaker.subsetFont(
...@@ -417,7 +417,7 @@ void main() { ...@@ -417,7 +417,7 @@ void main() {
}); });
testWithoutContext('Invalid font manifest', () async { testWithoutContext('Invalid font manifest', () async {
final Environment environment = _createEnvironment(<String, String>{ final Environment environment = createEnvironment(<String, String>{
kIconTreeShakerFlag: 'true', kIconTreeShakerFlag: 'true',
kBuildMode: 'release', kBuildMode: 'release',
}); });
...@@ -435,7 +435,7 @@ void main() { ...@@ -435,7 +435,7 @@ void main() {
artifacts: artifacts, artifacts: artifacts,
); );
_addConstFinderInvocation(appDill.path, stdout: validConstFinderResult); addConstFinderInvocation(appDill.path, stdout: validConstFinderResult);
await expectLater( await expectLater(
() => iconTreeShaker.subsetFont( () => iconTreeShaker.subsetFont(
...@@ -449,7 +449,7 @@ void main() { ...@@ -449,7 +449,7 @@ void main() {
}); });
testWithoutContext('ConstFinder non-zero exit', () async { testWithoutContext('ConstFinder non-zero exit', () async {
final Environment environment = _createEnvironment(<String, String>{ final Environment environment = createEnvironment(<String, String>{
kIconTreeShakerFlag: 'true', kIconTreeShakerFlag: 'true',
kBuildMode: 'release', kBuildMode: 'release',
}); });
...@@ -467,7 +467,7 @@ void main() { ...@@ -467,7 +467,7 @@ void main() {
artifacts: artifacts, artifacts: artifacts,
); );
_addConstFinderInvocation(appDill.path, exitCode: -1); addConstFinderInvocation(appDill.path, exitCode: -1);
await expectLater( await expectLater(
() async => iconTreeShaker.subsetFont( () async => iconTreeShaker.subsetFont(
......
...@@ -15,7 +15,7 @@ import 'xcresult_test_data.dart'; ...@@ -15,7 +15,7 @@ import 'xcresult_test_data.dart';
void main() { void main() {
// Creates a FakeCommand for the xcresult get call to build the app // Creates a FakeCommand for the xcresult get call to build the app
// in the given configuration. // in the given configuration.
FakeCommand _setUpFakeXCResultGetCommand({ FakeCommand setUpFakeXCResultGetCommand({
required String stdout, required String stdout,
required String tempResultPath, required String tempResultPath,
required Xcode xcode, required Xcode xcode,
...@@ -54,7 +54,7 @@ void main() { ...@@ -54,7 +54,7 @@ void main() {
exitCode: 1, exitCode: 1,
); );
XCResultGenerator _setupGenerator({ XCResultGenerator setupGenerator({
required String resultJson, required String resultJson,
int exitCode = 0, int exitCode = 0,
String stderr = '', String stderr = '',
...@@ -73,7 +73,7 @@ void main() { ...@@ -73,7 +73,7 @@ void main() {
); );
fakeProcessManager.addCommands( fakeProcessManager.addCommands(
<FakeCommand>[ <FakeCommand>[
_setUpFakeXCResultGetCommand( setUpFakeXCResultGetCommand(
stdout: resultJson, stdout: resultJson,
tempResultPath: _tempResultPath, tempResultPath: _tempResultPath,
xcode: xcode, xcode: xcode,
...@@ -95,7 +95,7 @@ void main() { ...@@ -95,7 +95,7 @@ void main() {
testWithoutContext( testWithoutContext(
'correctly parse sample result json when there are issues.', () async { 'correctly parse sample result json when there are issues.', () async {
final XCResultGenerator generator = _setupGenerator(resultJson: kSampleResultJsonWithIssues); final XCResultGenerator generator = setupGenerator(resultJson: kSampleResultJsonWithIssues);
final XCResult result = await generator.generate(); final XCResult result = await generator.generate();
expect(result.issues.length, 2); expect(result.issues.length, 2);
expect(result.issues.first.type, XCResultIssueType.error); expect(result.issues.first.type, XCResultIssueType.error);
...@@ -112,7 +112,7 @@ void main() { ...@@ -112,7 +112,7 @@ void main() {
testWithoutContext( testWithoutContext(
'correctly parse sample result json when there are issues but invalid url.', () async { 'correctly parse sample result json when there are issues but invalid url.', () async {
final XCResultGenerator generator = _setupGenerator(resultJson: kSampleResultJsonWithIssuesAndInvalidUrl); final XCResultGenerator generator = setupGenerator(resultJson: kSampleResultJsonWithIssuesAndInvalidUrl);
final XCResult result = await generator.generate(); final XCResult result = await generator.generate();
expect(result.issues.length, 2); expect(result.issues.length, 2);
expect(result.issues.first.type, XCResultIssueType.error); expect(result.issues.first.type, XCResultIssueType.error);
...@@ -130,7 +130,7 @@ void main() { ...@@ -130,7 +130,7 @@ void main() {
testWithoutContext( testWithoutContext(
'correctly parse sample result json and discard all warnings', () async { 'correctly parse sample result json and discard all warnings', () async {
final XCResultGenerator generator = _setupGenerator(resultJson: kSampleResultJsonWithIssues); final XCResultGenerator generator = setupGenerator(resultJson: kSampleResultJsonWithIssues);
final XCResultIssueDiscarder discarder = XCResultIssueDiscarder(typeMatcher: XCResultIssueType.warning); final XCResultIssueDiscarder discarder = XCResultIssueDiscarder(typeMatcher: XCResultIssueType.warning);
final XCResult result = await generator.generate(issueDiscarders: <XCResultIssueDiscarder>[discarder]); final XCResult result = await generator.generate(issueDiscarders: <XCResultIssueDiscarder>[discarder]);
expect(result.issues.length, 1); expect(result.issues.length, 1);
...@@ -144,7 +144,7 @@ void main() { ...@@ -144,7 +144,7 @@ void main() {
testWithoutContext( testWithoutContext(
'correctly parse sample result json and discard base on subType', () async { 'correctly parse sample result json and discard base on subType', () async {
final XCResultGenerator generator = _setupGenerator(resultJson: kSampleResultJsonWithIssues); final XCResultGenerator generator = setupGenerator(resultJson: kSampleResultJsonWithIssues);
final XCResultIssueDiscarder discarder = XCResultIssueDiscarder(subTypeMatcher: RegExp(r'^Warning$')); final XCResultIssueDiscarder discarder = XCResultIssueDiscarder(subTypeMatcher: RegExp(r'^Warning$'));
final XCResult result = await generator.generate(issueDiscarders: <XCResultIssueDiscarder>[discarder]); final XCResult result = await generator.generate(issueDiscarders: <XCResultIssueDiscarder>[discarder]);
expect(result.issues.length, 1); expect(result.issues.length, 1);
...@@ -158,7 +158,7 @@ void main() { ...@@ -158,7 +158,7 @@ void main() {
testWithoutContext( testWithoutContext(
'correctly parse sample result json and discard base on message', () async { 'correctly parse sample result json and discard base on message', () async {
final XCResultGenerator generator = _setupGenerator(resultJson: kSampleResultJsonWithIssues); final XCResultGenerator generator = setupGenerator(resultJson: kSampleResultJsonWithIssues);
final XCResultIssueDiscarder discarder = XCResultIssueDiscarder(messageMatcher: RegExp(r"^The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99.$")); final XCResultIssueDiscarder discarder = XCResultIssueDiscarder(messageMatcher: RegExp(r"^The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99.$"));
final XCResult result = await generator.generate(issueDiscarders: <XCResultIssueDiscarder>[discarder]); final XCResult result = await generator.generate(issueDiscarders: <XCResultIssueDiscarder>[discarder]);
expect(result.issues.length, 1); expect(result.issues.length, 1);
...@@ -172,7 +172,7 @@ void main() { ...@@ -172,7 +172,7 @@ void main() {
testWithoutContext( testWithoutContext(
'correctly parse sample result json and discard base on location', () async { 'correctly parse sample result json and discard base on location', () async {
final XCResultGenerator generator = _setupGenerator(resultJson: kSampleResultJsonWithIssues); final XCResultGenerator generator = setupGenerator(resultJson: kSampleResultJsonWithIssues);
final XCResultIssueDiscarder discarder = XCResultIssueDiscarder(locationMatcher: RegExp(r'/Users/m/Projects/test_create/ios/Runner/AppDelegate.m')); final XCResultIssueDiscarder discarder = XCResultIssueDiscarder(locationMatcher: RegExp(r'/Users/m/Projects/test_create/ios/Runner/AppDelegate.m'));
final XCResult result = await generator.generate(issueDiscarders: <XCResultIssueDiscarder>[discarder]); final XCResult result = await generator.generate(issueDiscarders: <XCResultIssueDiscarder>[discarder]);
expect(result.issues.length, 1); expect(result.issues.length, 1);
...@@ -186,7 +186,7 @@ void main() { ...@@ -186,7 +186,7 @@ void main() {
testWithoutContext( testWithoutContext(
'correctly parse sample result json with multiple discarders.', () async { 'correctly parse sample result json with multiple discarders.', () async {
final XCResultGenerator generator = _setupGenerator(resultJson: kSampleResultJsonWithIssues); final XCResultGenerator generator = setupGenerator(resultJson: kSampleResultJsonWithIssues);
final XCResultIssueDiscarder discardWarnings = XCResultIssueDiscarder(typeMatcher: XCResultIssueType.warning); final XCResultIssueDiscarder discardWarnings = XCResultIssueDiscarder(typeMatcher: XCResultIssueType.warning);
final XCResultIssueDiscarder discardSemanticIssues = XCResultIssueDiscarder(subTypeMatcher: RegExp(r'^Semantic Issue$')); final XCResultIssueDiscarder discardSemanticIssues = XCResultIssueDiscarder(subTypeMatcher: RegExp(r'^Semantic Issue$'));
final XCResult result = await generator.generate(issueDiscarders: <XCResultIssueDiscarder>[discardWarnings, discardSemanticIssues]); final XCResult result = await generator.generate(issueDiscarders: <XCResultIssueDiscarder>[discardWarnings, discardSemanticIssues]);
...@@ -197,7 +197,7 @@ void main() { ...@@ -197,7 +197,7 @@ void main() {
testWithoutContext('correctly parse sample result json when no issues.', testWithoutContext('correctly parse sample result json when no issues.',
() async { () async {
final XCResultGenerator generator = _setupGenerator(resultJson: kSampleResultJsonNoIssues); final XCResultGenerator generator = setupGenerator(resultJson: kSampleResultJsonNoIssues);
final XCResult result = await generator.generate(); final XCResult result = await generator.generate();
expect(result.issues.length, 0); expect(result.issues.length, 0);
expect(result.parseSuccess, isTrue); expect(result.parseSuccess, isTrue);
...@@ -208,7 +208,7 @@ void main() { ...@@ -208,7 +208,7 @@ void main() {
'error: `xcresulttool get` process fail should return an `XCResult` with stderr as `parsingErrorMessage`.', 'error: `xcresulttool get` process fail should return an `XCResult` with stderr as `parsingErrorMessage`.',
() async { () async {
const String fakeStderr = 'Fake: fail to parse result json.'; const String fakeStderr = 'Fake: fail to parse result json.';
final XCResultGenerator generator = _setupGenerator( final XCResultGenerator generator = setupGenerator(
resultJson: '', resultJson: '',
exitCode: 1, exitCode: 1,
stderr: fakeStderr, stderr: fakeStderr,
...@@ -221,7 +221,7 @@ void main() { ...@@ -221,7 +221,7 @@ void main() {
}); });
testWithoutContext('error: `xcresulttool get` no stdout', () async { testWithoutContext('error: `xcresulttool get` no stdout', () async {
final XCResultGenerator generator = _setupGenerator(resultJson: ''); final XCResultGenerator generator = setupGenerator(resultJson: '');
final XCResult result = await generator.generate(); final XCResult result = await generator.generate();
expect(result.issues.length, 0); expect(result.issues.length, 0);
...@@ -231,7 +231,7 @@ void main() { ...@@ -231,7 +231,7 @@ void main() {
}); });
testWithoutContext('error: wrong top level json format.', () async { testWithoutContext('error: wrong top level json format.', () async {
final XCResultGenerator generator = _setupGenerator(resultJson: '[]'); final XCResultGenerator generator = setupGenerator(resultJson: '[]');
final XCResult result = await generator.generate(); final XCResult result = await generator.generate();
expect(result.issues.length, 0); expect(result.issues.length, 0);
...@@ -241,7 +241,7 @@ void main() { ...@@ -241,7 +241,7 @@ void main() {
}); });
testWithoutContext('error: fail to parse issue map', () async { testWithoutContext('error: fail to parse issue map', () async {
final XCResultGenerator generator = _setupGenerator(resultJson: '{}'); final XCResultGenerator generator = setupGenerator(resultJson: '{}');
final XCResult result = await generator.generate(); final XCResult result = await generator.generate();
expect(result.issues.length, 0); expect(result.issues.length, 0);
...@@ -251,7 +251,7 @@ void main() { ...@@ -251,7 +251,7 @@ void main() {
}); });
testWithoutContext('error: invalid issue map', () async { testWithoutContext('error: invalid issue map', () async {
final XCResultGenerator generator = _setupGenerator(resultJson: kSampleResultJsonInvalidIssuesMap); final XCResultGenerator generator = setupGenerator(resultJson: kSampleResultJsonInvalidIssuesMap);
final XCResult result = await generator.generate(); final XCResult result = await generator.generate();
expect(result.issues.length, 0); expect(result.issues.length, 0);
......
...@@ -1557,7 +1557,7 @@ flutter: ...@@ -1557,7 +1557,7 @@ flutter:
tryToDelete(tempDir); tryToDelete(tempDir);
}); });
void _createPubspecFile(String yamlString) { void createPubspecFile(String yamlString) {
projectDir.childFile('pubspec.yaml')..createSync(recursive: true)..writeAsStringSync(yamlString); projectDir.childFile('pubspec.yaml')..createSync(recursive: true)..writeAsStringSync(yamlString);
} }
...@@ -1581,7 +1581,7 @@ flutter: ...@@ -1581,7 +1581,7 @@ flutter:
pluginClass: SomePlugin pluginClass: SomePlugin
package: AndroidPackage package: AndroidPackage
'''; ''';
_createPubspecFile(pluginYaml); createPubspecFile(pluginYaml);
validatePubspecForPlugin(projectDir: projectDir.absolute.path, pluginClass: 'SomePlugin', expectedPlatforms: <String>[ validatePubspecForPlugin(projectDir: projectDir.absolute.path, pluginClass: 'SomePlugin', expectedPlatforms: <String>[
'ios', 'macos', 'windows', 'linux', 'android', 'web', 'ios', 'macos', 'windows', 'linux', 'android', 'web',
], androidIdentifier: 'AndroidPackage', webFileName: 'lib/SomeFile.dart'); ], androidIdentifier: 'AndroidPackage', webFileName: 'lib/SomeFile.dart');
......
...@@ -134,7 +134,7 @@ void main() { ...@@ -134,7 +134,7 @@ void main() {
fileSystem.file('.packages').writeAsStringSync('\n'); fileSystem.file('.packages').writeAsStringSync('\n');
}); });
void _setupMocks() { void setupMocks() {
fileSystem.file('pubspec.yaml').createSync(); fileSystem.file('pubspec.yaml').createSync();
fileSystem.file('lib/main.dart').createSync(recursive: true); fileSystem.file('lib/main.dart').createSync(recursive: true);
fileSystem.file('web/index.html').createSync(recursive: true); fileSystem.file('web/index.html').createSync(recursive: true);
...@@ -180,7 +180,7 @@ void main() { ...@@ -180,7 +180,7 @@ void main() {
testUsingContext('runner with web server device supports debugging with --start-paused', () { testUsingContext('runner with web server device supports debugging with --start-paused', () {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]); fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]);
_setupMocks(); setupMocks();
flutterDevice.device = WebServerDevice( flutterDevice.device = WebServerDevice(
logger: BufferLogger.test(), logger: BufferLogger.test(),
); );
...@@ -239,7 +239,7 @@ void main() { ...@@ -239,7 +239,7 @@ void main() {
final BufferLogger logger = BufferLogger.test(); final BufferLogger logger = BufferLogger.test();
final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice, logger: logger); final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice, logger: logger);
fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations.toList()); fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations.toList());
_setupMocks(); setupMocks();
final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>(); final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>();
unawaited(residentWebRunner.run( unawaited(residentWebRunner.run(
...@@ -261,7 +261,7 @@ void main() { ...@@ -261,7 +261,7 @@ void main() {
); );
final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice, debuggingOptions: debuggingOptions); final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice, debuggingOptions: debuggingOptions);
fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations.toList()); fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations.toList());
_setupMocks(); setupMocks();
residentWebRunner.artifactDirectory.childFile('app.dill').writeAsStringSync('ABC'); residentWebRunner.artifactDirectory.childFile('app.dill').writeAsStringSync('ABC');
final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>(); final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>();
...@@ -279,7 +279,7 @@ void main() { ...@@ -279,7 +279,7 @@ void main() {
testUsingContext('WebRunner copies compiled app.dill to cache during startup with track-widget-creation', () async { testUsingContext('WebRunner copies compiled app.dill to cache during startup with track-widget-creation', () async {
final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice); final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice);
fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations.toList()); fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations.toList());
_setupMocks(); setupMocks();
residentWebRunner.artifactDirectory.childFile('app.dill').writeAsStringSync('ABC'); residentWebRunner.artifactDirectory.childFile('app.dill').writeAsStringSync('ABC');
final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>(); final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>();
...@@ -297,7 +297,7 @@ void main() { ...@@ -297,7 +297,7 @@ void main() {
// Regression test for https://github.com/flutter/flutter/issues/60613 // Regression test for https://github.com/flutter/flutter/issues/60613
testUsingContext('ResidentWebRunner calls appFailedToStart if initial compilation fails', () async { testUsingContext('ResidentWebRunner calls appFailedToStart if initial compilation fails', () async {
fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations.toList()); fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations.toList());
_setupMocks(); setupMocks();
final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice); final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice);
fileSystem.file(globals.fs.path.join('lib', 'main.dart')) fileSystem.file(globals.fs.path.join('lib', 'main.dart'))
.createSync(recursive: true); .createSync(recursive: true);
...@@ -314,7 +314,7 @@ void main() { ...@@ -314,7 +314,7 @@ void main() {
testUsingContext('Can successfully run without an index.html including status warning', () async { testUsingContext('Can successfully run without an index.html including status warning', () async {
final BufferLogger logger = BufferLogger.test(); final BufferLogger logger = BufferLogger.test();
fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations.toList()); fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations.toList());
_setupMocks(); setupMocks();
fileSystem.file(fileSystem.path.join('web', 'index.html')) fileSystem.file(fileSystem.path.join('web', 'index.html'))
.deleteSync(); .deleteSync();
final ResidentWebRunner residentWebRunner = ResidentWebRunner( final ResidentWebRunner residentWebRunner = ResidentWebRunner(
...@@ -340,7 +340,7 @@ void main() { ...@@ -340,7 +340,7 @@ void main() {
testUsingContext('Can successfully run and disconnect with --no-resident', () async { testUsingContext('Can successfully run and disconnect with --no-resident', () async {
fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations.toList()); fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations.toList());
_setupMocks(); setupMocks();
final ResidentRunner residentWebRunner = ResidentWebRunner( final ResidentRunner residentWebRunner = ResidentWebRunner(
flutterDevice, flutterDevice,
flutterProject: FlutterProject.fromDirectoryTest(fileSystem.currentDirectory), flutterProject: FlutterProject.fromDirectoryTest(fileSystem.currentDirectory),
...@@ -383,7 +383,7 @@ void main() { ...@@ -383,7 +383,7 @@ void main() {
), ),
...kAttachIsolateExpectations, ...kAttachIsolateExpectations,
]); ]);
_setupMocks(); setupMocks();
final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>(); final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>();
unawaited(residentWebRunner.run( unawaited(residentWebRunner.run(
connectionInfoCompleter: connectionInfoCompleter, connectionInfoCompleter: connectionInfoCompleter,
...@@ -443,7 +443,7 @@ void main() { ...@@ -443,7 +443,7 @@ void main() {
), ),
]); ]);
_setupMocks(); setupMocks();
final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>(); final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>();
unawaited(residentWebRunner.run( unawaited(residentWebRunner.run(
connectionInfoCompleter: connectionInfoCompleter, connectionInfoCompleter: connectionInfoCompleter,
...@@ -471,7 +471,7 @@ void main() { ...@@ -471,7 +471,7 @@ void main() {
systemClock: globals.systemClock, systemClock: globals.systemClock,
); );
fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations.toList()); fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations.toList());
_setupMocks(); setupMocks();
final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>(); final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>();
unawaited(residentWebRunner.run( unawaited(residentWebRunner.run(
...@@ -507,7 +507,7 @@ void main() { ...@@ -507,7 +507,7 @@ void main() {
}, },
), ),
]); ]);
_setupMocks(); setupMocks();
final TestChromiumLauncher chromiumLauncher = TestChromiumLauncher(); final TestChromiumLauncher chromiumLauncher = TestChromiumLauncher();
final Chromium chrome = Chromium(1, chromeConnection, chromiumLauncher: chromiumLauncher); final Chromium chrome = Chromium(1, chromeConnection, chromiumLauncher: chromiumLauncher);
chromiumLauncher.setInstance(chrome); chromiumLauncher.setInstance(chrome);
...@@ -564,7 +564,7 @@ void main() { ...@@ -564,7 +564,7 @@ void main() {
} }
), ),
]); ]);
_setupMocks(); setupMocks();
final TestChromiumLauncher chromiumLauncher = TestChromiumLauncher(); final TestChromiumLauncher chromiumLauncher = TestChromiumLauncher();
final Chromium chrome = Chromium(1, chromeConnection, chromiumLauncher: chromiumLauncher); final Chromium chrome = Chromium(1, chromeConnection, chromiumLauncher: chromiumLauncher);
chromiumLauncher.setInstance(chrome); chromiumLauncher.setInstance(chrome);
...@@ -616,7 +616,7 @@ void main() { ...@@ -616,7 +616,7 @@ void main() {
systemClock: SystemClock.fixed(DateTime(2001)), systemClock: SystemClock.fixed(DateTime(2001)),
); );
fakeVmServiceHost = FakeVmServiceHost(requests :kAttachExpectations); fakeVmServiceHost = FakeVmServiceHost(requests :kAttachExpectations);
_setupMocks(); setupMocks();
flutterDevice.device = webServerDevice; flutterDevice.device = webServerDevice;
webDevFS.report = UpdateFSReport(success: true); webDevFS.report = UpdateFSReport(success: true);
...@@ -652,7 +652,7 @@ void main() { ...@@ -652,7 +652,7 @@ void main() {
testUsingContext('Exits when initial compile fails', () async { testUsingContext('Exits when initial compile fails', () async {
final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice); final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice);
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]); fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]);
_setupMocks(); setupMocks();
webDevFS.report = UpdateFSReport(); webDevFS.report = UpdateFSReport();
final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>(); final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>();
...@@ -686,7 +686,7 @@ void main() { ...@@ -686,7 +686,7 @@ void main() {
), ),
...kAttachIsolateExpectations, ...kAttachIsolateExpectations,
]); ]);
_setupMocks(); setupMocks();
final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>(); final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>();
unawaited(residentWebRunner.run( unawaited(residentWebRunner.run(
connectionInfoCompleter: connectionInfoCompleter, connectionInfoCompleter: connectionInfoCompleter,
...@@ -704,7 +704,7 @@ void main() { ...@@ -704,7 +704,7 @@ void main() {
testUsingContext('Fails on compilation errors in hot restart', () async { testUsingContext('Fails on compilation errors in hot restart', () async {
final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice); final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice);
fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations.toList()); fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations.toList());
_setupMocks(); setupMocks();
final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>(); final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>();
unawaited(residentWebRunner.run( unawaited(residentWebRunner.run(
connectionInfoCompleter: connectionInfoCompleter, connectionInfoCompleter: connectionInfoCompleter,
...@@ -735,7 +735,7 @@ void main() { ...@@ -735,7 +735,7 @@ void main() {
}, },
), ),
]); ]);
_setupMocks(); setupMocks();
final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>(); final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>();
unawaited(residentWebRunner.run( unawaited(residentWebRunner.run(
connectionInfoCompleter: connectionInfoCompleter, connectionInfoCompleter: connectionInfoCompleter,
...@@ -760,7 +760,7 @@ void main() { ...@@ -760,7 +760,7 @@ void main() {
errorCode: RPCErrorCodes.kInternalError, errorCode: RPCErrorCodes.kInternalError,
), ),
]); ]);
_setupMocks(); setupMocks();
final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>(); final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>();
unawaited(residentWebRunner.run( unawaited(residentWebRunner.run(
connectionInfoCompleter: connectionInfoCompleter, connectionInfoCompleter: connectionInfoCompleter,
...@@ -793,7 +793,7 @@ void main() { ...@@ -793,7 +793,7 @@ void main() {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[ fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
...kAttachExpectations, ...kAttachExpectations,
]); ]);
_setupMocks(); setupMocks();
final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>(); final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>();
unawaited(residentWebRunner.run( unawaited(residentWebRunner.run(
connectionInfoCompleter: connectionInfoCompleter, connectionInfoCompleter: connectionInfoCompleter,
...@@ -815,7 +815,7 @@ void main() { ...@@ -815,7 +815,7 @@ void main() {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[ fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
...kAttachExpectations, ...kAttachExpectations,
]); ]);
_setupMocks(); setupMocks();
final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>(); final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>();
final Future<int> result = residentWebRunner.run( final Future<int> result = residentWebRunner.run(
connectionInfoCompleter: connectionInfoCompleter, connectionInfoCompleter: connectionInfoCompleter,
...@@ -836,7 +836,7 @@ void main() { ...@@ -836,7 +836,7 @@ void main() {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[ fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
...kAttachExpectations, ...kAttachExpectations,
]); ]);
_setupMocks(); setupMocks();
mockDevice.name = 'Chromez'; mockDevice.name = 'Chromez';
final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>(); final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>();
unawaited(residentWebRunner.run( unawaited(residentWebRunner.run(
...@@ -860,7 +860,7 @@ void main() { ...@@ -860,7 +860,7 @@ void main() {
...kAttachLogExpectations, ...kAttachLogExpectations,
...kAttachIsolateExpectations, ...kAttachIsolateExpectations,
]); ]);
_setupMocks(); setupMocks();
final FakeChromeConnection chromeConnection = FakeChromeConnection(); final FakeChromeConnection chromeConnection = FakeChromeConnection();
final TestChromiumLauncher chromiumLauncher = TestChromiumLauncher(); final TestChromiumLauncher chromiumLauncher = TestChromiumLauncher();
final Chromium chrome = Chromium(1, chromeConnection, chromiumLauncher: chromiumLauncher); final Chromium chrome = Chromium(1, chromeConnection, chromiumLauncher: chromiumLauncher);
...@@ -915,7 +915,7 @@ void main() { ...@@ -915,7 +915,7 @@ void main() {
testUsingContext('Sends unlaunched app.webLaunchUrl event for Web Server device', () async { testUsingContext('Sends unlaunched app.webLaunchUrl event for Web Server device', () async {
final BufferLogger logger = BufferLogger.test(); final BufferLogger logger = BufferLogger.test();
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]); fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]);
_setupMocks(); setupMocks();
flutterDevice.device = WebServerDevice( flutterDevice.device = WebServerDevice(
logger: logger, logger: logger,
); );
...@@ -1000,7 +1000,7 @@ void main() { ...@@ -1000,7 +1000,7 @@ void main() {
final BufferLogger logger = BufferLogger.test(); final BufferLogger logger = BufferLogger.test();
final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice, logger: logger); final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice, logger: logger);
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]); fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]);
_setupMocks(); setupMocks();
webDevFS.exception = const WebSocketException(); webDevFS.exception = const WebSocketException();
await expectLater(residentWebRunner.run, throwsToolExit()); await expectLater(residentWebRunner.run, throwsToolExit());
...@@ -1014,7 +1014,7 @@ void main() { ...@@ -1014,7 +1014,7 @@ void main() {
testUsingContext('Successfully turns AppConnectionException into ToolExit', () async { testUsingContext('Successfully turns AppConnectionException into ToolExit', () async {
final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice); final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice);
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]); fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]);
_setupMocks(); setupMocks();
webDevFS.exception = AppConnectionException(''); webDevFS.exception = AppConnectionException('');
await expectLater(residentWebRunner.run, throwsToolExit()); await expectLater(residentWebRunner.run, throwsToolExit());
...@@ -1027,7 +1027,7 @@ void main() { ...@@ -1027,7 +1027,7 @@ void main() {
testUsingContext('Successfully turns ChromeDebugError into ToolExit', () async { testUsingContext('Successfully turns ChromeDebugError into ToolExit', () async {
final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice); final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice);
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]); fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]);
_setupMocks(); setupMocks();
webDevFS.exception = ChromeDebugException(<String, dynamic>{}); webDevFS.exception = ChromeDebugException(<String, dynamic>{});
...@@ -1041,7 +1041,7 @@ void main() { ...@@ -1041,7 +1041,7 @@ void main() {
testUsingContext('Rethrows unknown Exception type from dwds', () async { testUsingContext('Rethrows unknown Exception type from dwds', () async {
final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice); final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice);
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]); fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]);
_setupMocks(); setupMocks();
webDevFS.exception = Exception(); webDevFS.exception = Exception();
await expectLater(residentWebRunner.run, throwsException); await expectLater(residentWebRunner.run, throwsException);
...@@ -1055,7 +1055,7 @@ void main() { ...@@ -1055,7 +1055,7 @@ void main() {
final BufferLogger logger = BufferLogger.test(); final BufferLogger logger = BufferLogger.test();
final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice, logger: logger); final ResidentRunner residentWebRunner = setUpResidentRunner(flutterDevice, logger: logger);
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]); fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]);
_setupMocks(); setupMocks();
webDevFS.exception = StateError(''); webDevFS.exception = StateError('');
await expectLater(residentWebRunner.run, throwsStateError); await expectLater(residentWebRunner.run, throwsStateError);
......
...@@ -274,7 +274,7 @@ void main() { ...@@ -274,7 +274,7 @@ void main() {
}); });
group('$VersionCheckStamp for $channel', () { group('$VersionCheckStamp for $channel', () {
void _expectDefault(VersionCheckStamp stamp) { void expectDefault(VersionCheckStamp stamp) {
expect(stamp.lastKnownRemoteVersion, isNull); expect(stamp.lastKnownRemoteVersion, isNull);
expect(stamp.lastTimeVersionWasChecked, isNull); expect(stamp.lastTimeVersionWasChecked, isNull);
expect(stamp.lastTimeWarningWasPrinted, isNull); expect(stamp.lastTimeWarningWasPrinted, isNull);
...@@ -283,19 +283,19 @@ void main() { ...@@ -283,19 +283,19 @@ void main() {
testWithoutContext('loads blank when stamp file missing', () async { testWithoutContext('loads blank when stamp file missing', () async {
cache.versionStamp = null; cache.versionStamp = null;
_expectDefault(await VersionCheckStamp.load(cache, BufferLogger.test())); expectDefault(await VersionCheckStamp.load(cache, BufferLogger.test()));
}); });
testWithoutContext('loads blank when stamp file is malformed JSON', () async { testWithoutContext('loads blank when stamp file is malformed JSON', () async {
cache.versionStamp = '<'; cache.versionStamp = '<';
_expectDefault(await VersionCheckStamp.load(cache, BufferLogger.test())); expectDefault(await VersionCheckStamp.load(cache, BufferLogger.test()));
}); });
testWithoutContext('loads blank when stamp file is well-formed but invalid JSON', () async { testWithoutContext('loads blank when stamp file is well-formed but invalid JSON', () async {
cache.versionStamp = '[]'; cache.versionStamp = '[]';
_expectDefault(await VersionCheckStamp.load(cache, BufferLogger.test())); expectDefault(await VersionCheckStamp.load(cache, BufferLogger.test()));
}); });
testWithoutContext('loads valid JSON', () async { testWithoutContext('loads valid JSON', () async {
......
...@@ -21,7 +21,7 @@ void main() { ...@@ -21,7 +21,7 @@ void main() {
}); });
// Assigns default values for a complete VS installation with necessary components. // Assigns default values for a complete VS installation with necessary components.
void _configureMockVisualStudioAsInstalled() { void configureMockVisualStudioAsInstalled() {
fakeVisualStudio.isPrerelease = false; fakeVisualStudio.isPrerelease = false;
fakeVisualStudio.isRebootRequired = false; fakeVisualStudio.isRebootRequired = false;
fakeVisualStudio.fullVersion = '16.2'; fakeVisualStudio.fullVersion = '16.2';
...@@ -30,7 +30,7 @@ void main() { ...@@ -30,7 +30,7 @@ void main() {
} }
// Assigns default values for a complete VS installation that is too old. // Assigns default values for a complete VS installation that is too old.
void _configureMockVisualStudioAsTooOld() { void configureMockVisualStudioAsTooOld() {
fakeVisualStudio.isAtLeastMinimumVersion = false; fakeVisualStudio.isAtLeastMinimumVersion = false;
fakeVisualStudio.isPrerelease = false; fakeVisualStudio.isPrerelease = false;
fakeVisualStudio.isRebootRequired = false; fakeVisualStudio.isRebootRequired = false;
...@@ -40,7 +40,7 @@ void main() { ...@@ -40,7 +40,7 @@ void main() {
} }
// Assigns default values for a missing VS installation. // Assigns default values for a missing VS installation.
void _configureMockVisualStudioAsNotInstalled() { void configureMockVisualStudioAsNotInstalled() {
fakeVisualStudio.isInstalled = false; fakeVisualStudio.isInstalled = false;
fakeVisualStudio.isAtLeastMinimumVersion = false; fakeVisualStudio.isAtLeastMinimumVersion = false;
fakeVisualStudio.isPrerelease = false; fakeVisualStudio.isPrerelease = false;
...@@ -56,7 +56,7 @@ void main() { ...@@ -56,7 +56,7 @@ void main() {
userMessages: userMessages, userMessages: userMessages,
visualStudio: fakeVisualStudio, visualStudio: fakeVisualStudio,
); );
_configureMockVisualStudioAsInstalled(); configureMockVisualStudioAsInstalled();
fakeVisualStudio.isPrerelease = true; fakeVisualStudio.isPrerelease = true;
final ValidationResult result = await validator.validate(); final ValidationResult result = await validator.validate();
...@@ -70,7 +70,7 @@ void main() { ...@@ -70,7 +70,7 @@ void main() {
userMessages: userMessages, userMessages: userMessages,
visualStudio: fakeVisualStudio, visualStudio: fakeVisualStudio,
); );
_configureMockVisualStudioAsInstalled(); configureMockVisualStudioAsInstalled();
fakeVisualStudio.isComplete = false; fakeVisualStudio.isComplete = false;
final ValidationResult result = await validator.validate(); final ValidationResult result = await validator.validate();
...@@ -85,7 +85,7 @@ void main() { ...@@ -85,7 +85,7 @@ void main() {
userMessages: userMessages, userMessages: userMessages,
visualStudio: fakeVisualStudio, visualStudio: fakeVisualStudio,
); );
_configureMockVisualStudioAsInstalled(); configureMockVisualStudioAsInstalled();
fakeVisualStudio.isRebootRequired = true; fakeVisualStudio.isRebootRequired = true;
final ValidationResult result = await validator.validate(); final ValidationResult result = await validator.validate();
...@@ -100,7 +100,7 @@ void main() { ...@@ -100,7 +100,7 @@ void main() {
userMessages: userMessages, userMessages: userMessages,
visualStudio: fakeVisualStudio, visualStudio: fakeVisualStudio,
); );
_configureMockVisualStudioAsInstalled(); configureMockVisualStudioAsInstalled();
fakeVisualStudio.isLaunchable = false; fakeVisualStudio.isLaunchable = false;
final ValidationResult result = await validator.validate(); final ValidationResult result = await validator.validate();
...@@ -115,7 +115,7 @@ void main() { ...@@ -115,7 +115,7 @@ void main() {
userMessages: userMessages, userMessages: userMessages,
visualStudio: fakeVisualStudio, visualStudio: fakeVisualStudio,
); );
_configureMockVisualStudioAsTooOld(); configureMockVisualStudioAsTooOld();
final ValidationResult result = await validator.validate(); final ValidationResult result = await validator.validate();
final ValidationMessage expectedMessage = ValidationMessage.error( final ValidationMessage expectedMessage = ValidationMessage.error(
...@@ -134,7 +134,7 @@ void main() { ...@@ -134,7 +134,7 @@ void main() {
userMessages: userMessages, userMessages: userMessages,
visualStudio: fakeVisualStudio, visualStudio: fakeVisualStudio,
); );
_configureMockVisualStudioAsInstalled(); configureMockVisualStudioAsInstalled();
fakeVisualStudio.hasNecessaryComponents = false; fakeVisualStudio.hasNecessaryComponents = false;
final ValidationResult result = await validator.validate(); final ValidationResult result = await validator.validate();
...@@ -146,7 +146,7 @@ void main() { ...@@ -146,7 +146,7 @@ void main() {
userMessages: userMessages, userMessages: userMessages,
visualStudio: fakeVisualStudio, visualStudio: fakeVisualStudio,
); );
_configureMockVisualStudioAsInstalled(); configureMockVisualStudioAsInstalled();
fakeVisualStudio.windows10SDKVersion = null; fakeVisualStudio.windows10SDKVersion = null;
final ValidationResult result = await validator.validate(); final ValidationResult result = await validator.validate();
...@@ -158,7 +158,7 @@ void main() { ...@@ -158,7 +158,7 @@ void main() {
userMessages: userMessages, userMessages: userMessages,
visualStudio: fakeVisualStudio, visualStudio: fakeVisualStudio,
); );
_configureMockVisualStudioAsInstalled(); configureMockVisualStudioAsInstalled();
final ValidationResult result = await validator.validate(); final ValidationResult result = await validator.validate();
final ValidationMessage expectedDisplayNameMessage = ValidationMessage( final ValidationMessage expectedDisplayNameMessage = ValidationMessage(
...@@ -173,7 +173,7 @@ void main() { ...@@ -173,7 +173,7 @@ void main() {
userMessages: userMessages, userMessages: userMessages,
visualStudio: fakeVisualStudio, visualStudio: fakeVisualStudio,
); );
_configureMockVisualStudioAsNotInstalled(); configureMockVisualStudioAsNotInstalled();
final ValidationResult result = await validator.validate(); final ValidationResult result = await validator.validate();
final ValidationMessage expectedMessage = ValidationMessage.error( final ValidationMessage expectedMessage = ValidationMessage.error(
......
...@@ -36,7 +36,7 @@ void main() { ...@@ -36,7 +36,7 @@ void main() {
expect(result.stderr, contains(exitMessageContains)); expect(result.stderr, contains(exitMessageContains));
} }
void _createDotPackages(String projectPath, [bool nullSafe = false]) { void createDotPackages(String projectPath, [bool nullSafe = false]) {
final StringBuffer flutterRootUri = StringBuffer('file://'); final StringBuffer flutterRootUri = StringBuffer('file://');
final String canonicalizedFlutterRootPath = fileSystem.path.canonicalize(getFlutterRoot()); final String canonicalizedFlutterRootPath = fileSystem.path.canonicalize(getFlutterRoot());
if (platform.isWindows) { if (platform.isWindows) {
...@@ -84,7 +84,7 @@ void main() { ...@@ -84,7 +84,7 @@ void main() {
fileSystem.file(fileSystem.path.join(projectPath, 'pubspec.yaml')) fileSystem.file(fileSystem.path.join(projectPath, 'pubspec.yaml'))
..createSync(recursive: true) ..createSync(recursive: true)
..writeAsStringSync(pubspecYamlSrc); ..writeAsStringSync(pubspecYamlSrc);
_createDotPackages(projectPath); createDotPackages(projectPath);
libMain = fileSystem.file(fileSystem.path.join(projectPath, 'lib', 'main.dart')) libMain = fileSystem.file(fileSystem.path.join(projectPath, 'lib', 'main.dart'))
..createSync(recursive: true) ..createSync(recursive: true)
..writeAsStringSync(mainDartSrc); ..writeAsStringSync(mainDartSrc);
......
...@@ -44,7 +44,7 @@ void main() { ...@@ -44,7 +44,7 @@ void main() {
tryToDelete(tempDir); tryToDelete(tempDir);
}); });
void _checkBuildDir() { void checkBuildDir() {
// The android/app/build directory should not exists // The android/app/build directory should not exists
final Directory appBuildDir = fileSystem.directory(fileSystem.path.join( final Directory appBuildDir = fileSystem.directory(fileSystem.path.join(
exampleAppDir.path, exampleAppDir.path,
...@@ -65,7 +65,7 @@ void main() { ...@@ -65,7 +65,7 @@ void main() {
'apk', 'apk',
'--target-platform=android-arm', '--target-platform=android-arm',
], workingDirectory: exampleAppDir.path); ], workingDirectory: exampleAppDir.path);
_checkBuildDir(); checkBuildDir();
}, },
); );
...@@ -79,7 +79,7 @@ void main() { ...@@ -79,7 +79,7 @@ void main() {
'appbundle', 'appbundle',
'--target-platform=android-arm', '--target-platform=android-arm',
], workingDirectory: exampleAppDir.path); ], workingDirectory: exampleAppDir.path);
_checkBuildDir(); checkBuildDir();
}, },
); );
} }
...@@ -17,12 +17,12 @@ void main() { ...@@ -17,12 +17,12 @@ void main() {
fileSystem.path.join(flutterTools, 'lib', 'src', 'commands'), fileSystem.path.join(flutterTools, 'lib', 'src', 'commands'),
fileSystem.path.join(flutterTools, 'lib', 'src', 'test'), fileSystem.path.join(flutterTools, 'lib', 'src', 'test'),
]; ];
bool _isNotSkipped(FileSystemEntity entity) => skippedPaths.every((String path) => !entity.path.startsWith(path)); bool isNotSkipped(FileSystemEntity entity) => skippedPaths.every((String path) => !entity.path.startsWith(path));
final Iterable<File> files = fileSystem.directory(fileSystem.path.join(flutterTools, 'lib', 'src')) final Iterable<File> files = fileSystem.directory(fileSystem.path.join(flutterTools, 'lib', 'src'))
.listSync(recursive: true) .listSync(recursive: true)
.where(_isDartFile) .where(_isDartFile)
.where(_isNotSkipped) .where(isNotSkipped)
.map(_asFile); .map(_asFile);
for (final File file in files) { for (final File file in files) {
for (final String line in file.readAsLinesSync()) { for (final String line in file.readAsLinesSync()) {
...@@ -41,13 +41,13 @@ void main() { ...@@ -41,13 +41,13 @@ void main() {
test('no imports of globals without a global prefix', () { test('no imports of globals without a global prefix', () {
final List<String> skippedPaths = <String> []; final List<String> skippedPaths = <String> [];
bool _isNotSkipped(FileSystemEntity entity) => skippedPaths.every((String path) => !entity.path.startsWith(path)); bool isNotSkipped(FileSystemEntity entity) => skippedPaths.every((String path) => !entity.path.startsWith(path));
final Iterable<File> files = fileSystem.directory(fileSystem.path.join(flutterTools, 'lib', 'src')) final Iterable<File> files = fileSystem.directory(fileSystem.path.join(flutterTools, 'lib', 'src'))
.listSync(recursive: true) .listSync(recursive: true)
.followedBy(fileSystem.directory(fileSystem.path.join(flutterTools, 'test',)).listSync(recursive: true)) .followedBy(fileSystem.directory(fileSystem.path.join(flutterTools, 'test',)).listSync(recursive: true))
.where(_isDartFile) .where(_isDartFile)
.where(_isNotSkipped) .where(isNotSkipped)
.map(_asFile); .map(_asFile);
for (final File file in files) { for (final File file in files) {
for (final String line in file.readAsLinesSync()) { for (final String line in file.readAsLinesSync()) {
...@@ -70,13 +70,13 @@ void main() { ...@@ -70,13 +70,13 @@ void main() {
fileSystem.path.join(flutterTools, 'lib', 'src', 'base', 'error_handling_io.dart'), fileSystem.path.join(flutterTools, 'lib', 'src', 'base', 'error_handling_io.dart'),
fileSystem.path.join(flutterTools, 'lib', 'src', 'base', 'multi_root_file_system.dart'), fileSystem.path.join(flutterTools, 'lib', 'src', 'base', 'multi_root_file_system.dart'),
]; ];
bool _isNotAllowed(FileSystemEntity entity) => allowedPaths.every((String path) => path != entity.path); bool isNotAllowed(FileSystemEntity entity) => allowedPaths.every((String path) => path != entity.path);
for (final String dirName in <String>['lib', 'bin']) { for (final String dirName in <String>['lib', 'bin']) {
final Iterable<File> files = fileSystem.directory(fileSystem.path.join(flutterTools, dirName)) final Iterable<File> files = fileSystem.directory(fileSystem.path.join(flutterTools, dirName))
.listSync(recursive: true) .listSync(recursive: true)
.where(_isDartFile) .where(_isDartFile)
.where(_isNotAllowed) .where(isNotAllowed)
.map(_asFile); .map(_asFile);
for (final File file in files) { for (final File file in files) {
for (final String line in file.readAsLinesSync()) { for (final String line in file.readAsLinesSync()) {
...@@ -95,13 +95,13 @@ void main() { ...@@ -95,13 +95,13 @@ void main() {
// Used only for multi-part file uploads, which are non-trivial to reimplement. // Used only for multi-part file uploads, which are non-trivial to reimplement.
fileSystem.path.join(flutterTools, 'lib', 'src', 'reporting', 'crash_reporting.dart'), fileSystem.path.join(flutterTools, 'lib', 'src', 'reporting', 'crash_reporting.dart'),
]; ];
bool _isNotAllowed(FileSystemEntity entity) => allowedPaths.every((String path) => path != entity.path); bool isNotAllowed(FileSystemEntity entity) => allowedPaths.every((String path) => path != entity.path);
for (final String dirName in <String>['lib', 'bin']) { for (final String dirName in <String>['lib', 'bin']) {
final Iterable<File> files = fileSystem.directory(fileSystem.path.join(flutterTools, dirName)) final Iterable<File> files = fileSystem.directory(fileSystem.path.join(flutterTools, dirName))
.listSync(recursive: true) .listSync(recursive: true)
.where(_isDartFile) .where(_isDartFile)
.where(_isNotAllowed) .where(isNotAllowed)
.map(_asFile); .map(_asFile);
for (final File file in files) { for (final File file in files) {
for (final String line in file.readAsLinesSync()) { for (final String line in file.readAsLinesSync()) {
...@@ -121,13 +121,13 @@ void main() { ...@@ -121,13 +121,13 @@ void main() {
fileSystem.path.join(flutterTools, 'lib', 'src', 'test', 'flutter_web_platform.dart'), fileSystem.path.join(flutterTools, 'lib', 'src', 'test', 'flutter_web_platform.dart'),
fileSystem.path.join(flutterTools, 'lib', 'src', 'test', 'test_wrapper.dart'), fileSystem.path.join(flutterTools, 'lib', 'src', 'test', 'test_wrapper.dart'),
]; ];
bool _isNotAllowed(FileSystemEntity entity) => allowedPaths.every((String path) => path != entity.path); bool isNotAllowed(FileSystemEntity entity) => allowedPaths.every((String path) => path != entity.path);
for (final String dirName in <String>['lib']) { for (final String dirName in <String>['lib']) {
final Iterable<File> files = fileSystem.directory(fileSystem.path.join(flutterTools, dirName)) final Iterable<File> files = fileSystem.directory(fileSystem.path.join(flutterTools, dirName))
.listSync(recursive: true) .listSync(recursive: true)
.where(_isDartFile) .where(_isDartFile)
.where(_isNotAllowed) .where(isNotAllowed)
.map(_asFile); .map(_asFile);
for (final File file in files) { for (final File file in files) {
for (final String line in file.readAsLinesSync()) { for (final String line in file.readAsLinesSync()) {
...@@ -191,13 +191,13 @@ void main() { ...@@ -191,13 +191,13 @@ void main() {
fileSystem.path.join(flutterTools, 'lib', 'src', 'convert.dart'), fileSystem.path.join(flutterTools, 'lib', 'src', 'convert.dart'),
fileSystem.path.join(flutterTools, 'lib', 'src', 'base', 'error_handling_io.dart'), fileSystem.path.join(flutterTools, 'lib', 'src', 'base', 'error_handling_io.dart'),
]; ];
bool _isNotAllowed(FileSystemEntity entity) => allowedPaths.every((String path) => path != entity.path); bool isNotAllowed(FileSystemEntity entity) => allowedPaths.every((String path) => path != entity.path);
for (final String dirName in <String>['lib']) { for (final String dirName in <String>['lib']) {
final Iterable<File> files = fileSystem.directory(fileSystem.path.join(flutterTools, dirName)) final Iterable<File> files = fileSystem.directory(fileSystem.path.join(flutterTools, dirName))
.listSync(recursive: true) .listSync(recursive: true)
.where(_isDartFile) .where(_isDartFile)
.where(_isNotAllowed) .where(isNotAllowed)
.map(_asFile); .map(_asFile);
for (final File file in files) { for (final File file in files) {
for (final String line in file.readAsLinesSync()) { for (final String line in file.readAsLinesSync()) {
...@@ -219,13 +219,13 @@ void main() { ...@@ -219,13 +219,13 @@ void main() {
fileSystem.path.join(flutterTools, 'lib', 'devfs_web.dart'), fileSystem.path.join(flutterTools, 'lib', 'devfs_web.dart'),
fileSystem.path.join(flutterTools, 'lib', 'resident_web_runner.dart'), fileSystem.path.join(flutterTools, 'lib', 'resident_web_runner.dart'),
]; ];
bool _isNotAllowed(FileSystemEntity entity) => allowedPaths.every((String path) => !entity.path.contains(path)); bool isNotAllowed(FileSystemEntity entity) => allowedPaths.every((String path) => !entity.path.contains(path));
for (final String dirName in <String>['lib']) { for (final String dirName in <String>['lib']) {
final Iterable<File> files = fileSystem.directory(fileSystem.path.join(flutterTools, dirName)) final Iterable<File> files = fileSystem.directory(fileSystem.path.join(flutterTools, dirName))
.listSync(recursive: true) .listSync(recursive: true)
.where(_isDartFile) .where(_isDartFile)
.where(_isNotAllowed) .where(isNotAllowed)
.map(_asFile); .map(_asFile);
for (final File file in files) { for (final File file in files) {
for (final String line in file.readAsLinesSync()) { for (final String line in file.readAsLinesSync()) {
......
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