mirror of
https://github.com/flutter/packages.git
synced 2025-05-31 05:30:36 +08:00
[tool] Update to Dart 3 (#6030)
Updates the repo tooling to Dart 3, now that the N-2 version has Dart 3, which allows us to use Dart 3 features (e.g., records) going forward. To allow the update: - Removes `break` commands from `switch`es (all done automatically with `dart fix --apply`) - Replaces mocking of `ProcessResult` with just creating an actual `ProcessResult` since it's a `final` data class and thus can't (but also doesn't need to be) mocked.
This commit is contained in:
@ -123,7 +123,6 @@ abstract class PackageLoopingCommand extends PackageCommand {
|
|||||||
switch (packageLoopingType) {
|
switch (packageLoopingType) {
|
||||||
case PackageLoopingType.topLevelOnly:
|
case PackageLoopingType.topLevelOnly:
|
||||||
yield* getTargetPackages(filterExcluded: false);
|
yield* getTargetPackages(filterExcluded: false);
|
||||||
break;
|
|
||||||
case PackageLoopingType.includeExamples:
|
case PackageLoopingType.includeExamples:
|
||||||
await for (final PackageEnumerationEntry packageEntry
|
await for (final PackageEnumerationEntry packageEntry
|
||||||
in getTargetPackages(filterExcluded: false)) {
|
in getTargetPackages(filterExcluded: false)) {
|
||||||
@ -135,10 +134,8 @@ abstract class PackageLoopingCommand extends PackageCommand {
|
|||||||
package,
|
package,
|
||||||
excluded: packageEntry.excluded)));
|
excluded: packageEntry.excluded)));
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case PackageLoopingType.includeAllSubpackages:
|
case PackageLoopingType.includeAllSubpackages:
|
||||||
yield* getTargetPackagesAndSubpackages(filterExcluded: false);
|
yield* getTargetPackagesAndSubpackages(filterExcluded: false);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,22 +72,16 @@ class RepositoryPackage {
|
|||||||
switch (platform) {
|
switch (platform) {
|
||||||
case FlutterPlatform.android:
|
case FlutterPlatform.android:
|
||||||
directoryName = 'android';
|
directoryName = 'android';
|
||||||
break;
|
|
||||||
case FlutterPlatform.ios:
|
case FlutterPlatform.ios:
|
||||||
directoryName = 'ios';
|
directoryName = 'ios';
|
||||||
break;
|
|
||||||
case FlutterPlatform.linux:
|
case FlutterPlatform.linux:
|
||||||
directoryName = 'linux';
|
directoryName = 'linux';
|
||||||
break;
|
|
||||||
case FlutterPlatform.macos:
|
case FlutterPlatform.macos:
|
||||||
directoryName = 'macos';
|
directoryName = 'macos';
|
||||||
break;
|
|
||||||
case FlutterPlatform.web:
|
case FlutterPlatform.web:
|
||||||
directoryName = 'web';
|
directoryName = 'web';
|
||||||
break;
|
|
||||||
case FlutterPlatform.windows:
|
case FlutterPlatform.windows:
|
||||||
directoryName = 'windows';
|
directoryName = 'windows';
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return directory.childDirectory(directoryName);
|
return directory.childDirectory(directoryName);
|
||||||
}
|
}
|
||||||
|
@ -125,30 +125,23 @@ class FetchDepsCommand extends PackageLoopingCommand {
|
|||||||
switch (platform) {
|
switch (platform) {
|
||||||
case FlutterPlatform.android:
|
case FlutterPlatform.android:
|
||||||
result = await _fetchAndroidDeps(package);
|
result = await _fetchAndroidDeps(package);
|
||||||
break;
|
|
||||||
case FlutterPlatform.ios:
|
case FlutterPlatform.ios:
|
||||||
result = await _fetchDarwinDeps(package, platformIOS);
|
result = await _fetchDarwinDeps(package, platformIOS);
|
||||||
break;
|
|
||||||
case FlutterPlatform.macos:
|
case FlutterPlatform.macos:
|
||||||
result = await _fetchDarwinDeps(package, platformMacOS);
|
result = await _fetchDarwinDeps(package, platformMacOS);
|
||||||
break;
|
|
||||||
case FlutterPlatform.linux:
|
case FlutterPlatform.linux:
|
||||||
case FlutterPlatform.web:
|
case FlutterPlatform.web:
|
||||||
case FlutterPlatform.windows:
|
case FlutterPlatform.windows:
|
||||||
// No native dependency handling yet.
|
// No native dependency handling yet.
|
||||||
result = PackageResult.skip('Nothing to do for $platform.');
|
result = PackageResult.skip('Nothing to do for $platform.');
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
switch (result.state) {
|
switch (result.state) {
|
||||||
case RunState.succeeded:
|
case RunState.succeeded:
|
||||||
fetchedDeps = true;
|
fetchedDeps = true;
|
||||||
break;
|
|
||||||
case RunState.skipped:
|
case RunState.skipped:
|
||||||
skips.add(result.details.first);
|
skips.add(result.details.first);
|
||||||
break;
|
|
||||||
case RunState.failed:
|
case RunState.failed:
|
||||||
errors.addAll(result.details);
|
errors.addAll(result.details);
|
||||||
break;
|
|
||||||
case RunState.excluded:
|
case RunState.excluded:
|
||||||
throw StateError('Unreachable');
|
throw StateError('Unreachable');
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,6 @@ class ListCommand extends PackageCommand {
|
|||||||
await for (final PackageEnumerationEntry entry in getTargetPackages()) {
|
await for (final PackageEnumerationEntry entry in getTargetPackages()) {
|
||||||
print(entry.package.path);
|
print(entry.package.path);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case _example:
|
case _example:
|
||||||
final Stream<RepositoryPackage> examples = getTargetPackages()
|
final Stream<RepositoryPackage> examples = getTargetPackages()
|
||||||
.expand<RepositoryPackage>(
|
.expand<RepositoryPackage>(
|
||||||
@ -50,18 +49,15 @@ class ListCommand extends PackageCommand {
|
|||||||
await for (final RepositoryPackage package in examples) {
|
await for (final RepositoryPackage package in examples) {
|
||||||
print(package.path);
|
print(package.path);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case _allPackage:
|
case _allPackage:
|
||||||
await for (final PackageEnumerationEntry entry
|
await for (final PackageEnumerationEntry entry
|
||||||
in getTargetPackagesAndSubpackages()) {
|
in getTargetPackagesAndSubpackages()) {
|
||||||
print(entry.package.path);
|
print(entry.package.path);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case _file:
|
case _file:
|
||||||
await for (final File file in getFiles()) {
|
await for (final File file in getFiles()) {
|
||||||
print(file.path);
|
print(file.path);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -481,7 +481,6 @@ this command.
|
|||||||
switch (exitCode) {
|
switch (exitCode) {
|
||||||
case xcodebuildNoTestExitCode:
|
case xcodebuildNoTestExitCode:
|
||||||
_printNoExampleTestsMessage(example, platform);
|
_printNoExampleTestsMessage(example, platform);
|
||||||
break;
|
|
||||||
case 0:
|
case 0:
|
||||||
printSuccess('Successfully ran $platform xctest for $exampleName');
|
printSuccess('Successfully ran $platform xctest for $exampleName');
|
||||||
// If this is the first test, assume success until something fails.
|
// If this is the first test, assume success until something fails.
|
||||||
@ -491,7 +490,6 @@ this command.
|
|||||||
if (exampleHasUnitTests) {
|
if (exampleHasUnitTests) {
|
||||||
ranUnitTests = true;
|
ranUnitTests = true;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
// Any failure means a failure overall.
|
// Any failure means a failure overall.
|
||||||
overallResult = RunState.failed;
|
overallResult = RunState.failed;
|
||||||
|
@ -113,7 +113,6 @@ class UpdateDependencyCommand extends PackageLoopingCommand {
|
|||||||
switch (response.result) {
|
switch (response.result) {
|
||||||
case PubVersionFinderResult.success:
|
case PubVersionFinderResult.success:
|
||||||
_targetVersion = response.versions.first.toString();
|
_targetVersion = response.versions.first.toString();
|
||||||
break;
|
|
||||||
case PubVersionFinderResult.fail:
|
case PubVersionFinderResult.fail:
|
||||||
printError('''
|
printError('''
|
||||||
Error fetching $_targetPubPackage version from pub: ${response.httpResponse.statusCode}:
|
Error fetching $_targetPubPackage version from pub: ${response.httpResponse.statusCode}:
|
||||||
|
@ -138,20 +138,15 @@ class UpdateExcerptsCommand extends PackageLoopingCommand {
|
|||||||
switch (extension) {
|
switch (extension) {
|
||||||
case '':
|
case '':
|
||||||
language = 'txt';
|
language = 'txt';
|
||||||
break;
|
|
||||||
case '.kt':
|
case '.kt':
|
||||||
language = 'kotlin';
|
language = 'kotlin';
|
||||||
break;
|
|
||||||
case '.cc':
|
case '.cc':
|
||||||
case '.cpp':
|
case '.cpp':
|
||||||
language = 'c++';
|
language = 'c++';
|
||||||
break;
|
|
||||||
case '.m':
|
case '.m':
|
||||||
language = 'objectivec';
|
language = 'objectivec';
|
||||||
break;
|
|
||||||
case '.gradle':
|
case '.gradle':
|
||||||
language = 'groovy';
|
language = 'groovy';
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
language = extension.substring(1);
|
language = extension.substring(1);
|
||||||
break;
|
break;
|
||||||
@ -173,7 +168,6 @@ class UpdateExcerptsCommand extends PackageLoopingCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
output.writeln(line);
|
output.writeln(line);
|
||||||
break;
|
|
||||||
case _ExcerptParseMode.pragma:
|
case _ExcerptParseMode.pragma:
|
||||||
if (!line.startsWith('```')) {
|
if (!line.startsWith('```')) {
|
||||||
errors.add(
|
errors.add(
|
||||||
@ -195,7 +189,6 @@ class UpdateExcerptsCommand extends PackageLoopingCommand {
|
|||||||
mode = _ExcerptParseMode.injecting;
|
mode = _ExcerptParseMode.injecting;
|
||||||
}
|
}
|
||||||
output.writeln(line);
|
output.writeln(line);
|
||||||
break;
|
|
||||||
case _ExcerptParseMode.injecting:
|
case _ExcerptParseMode.injecting:
|
||||||
if (line == '```') {
|
if (line == '```') {
|
||||||
if (existingBlock.toString() != excerpt) {
|
if (existingBlock.toString() != excerpt) {
|
||||||
@ -210,7 +203,6 @@ class UpdateExcerptsCommand extends PackageLoopingCommand {
|
|||||||
} else {
|
} else {
|
||||||
existingBlock.writeln(line);
|
existingBlock.writeln(line);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (detectedChange) {
|
if (detectedChange) {
|
||||||
@ -250,23 +242,18 @@ class UpdateExcerptsCommand extends PackageLoopingCommand {
|
|||||||
case 'objectivec':
|
case 'objectivec':
|
||||||
case 'swift':
|
case 'swift':
|
||||||
prefix = '// ';
|
prefix = '// ';
|
||||||
break;
|
|
||||||
case 'css':
|
case 'css':
|
||||||
prefix = '/* ';
|
prefix = '/* ';
|
||||||
suffix = ' */';
|
suffix = ' */';
|
||||||
break;
|
|
||||||
case 'html':
|
case 'html':
|
||||||
case 'xml':
|
case 'xml':
|
||||||
prefix = '<!--';
|
prefix = '<!--';
|
||||||
suffix = '-->';
|
suffix = '-->';
|
||||||
padding = ' ';
|
padding = ' ';
|
||||||
break;
|
|
||||||
case 'yaml':
|
case 'yaml':
|
||||||
prefix = '# ';
|
prefix = '# ';
|
||||||
break;
|
|
||||||
case 'sh':
|
case 'sh':
|
||||||
prefix = '# ';
|
prefix = '# ';
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
final String startRegionMarker = '$prefix#docregion $section$suffix';
|
final String startRegionMarker = '$prefix#docregion $section$suffix';
|
||||||
final String endRegionMarker = '$prefix#enddocregion $section$suffix';
|
final String endRegionMarker = '$prefix#enddocregion $section$suffix';
|
||||||
|
@ -100,10 +100,8 @@ class UpdateReleaseInfoCommand extends PackageLoopingCommand {
|
|||||||
switch (getStringArg(_versionTypeFlag)) {
|
switch (getStringArg(_versionTypeFlag)) {
|
||||||
case _versionMinor:
|
case _versionMinor:
|
||||||
_versionChange = _VersionIncrementType.minor;
|
_versionChange = _VersionIncrementType.minor;
|
||||||
break;
|
|
||||||
case _versionBugfix:
|
case _versionBugfix:
|
||||||
_versionChange = _VersionIncrementType.bugfix;
|
_versionChange = _VersionIncrementType.bugfix;
|
||||||
break;
|
|
||||||
case _versionMinimal:
|
case _versionMinimal:
|
||||||
final GitVersionFinder gitVersionFinder = await retrieveVersionFinder();
|
final GitVersionFinder gitVersionFinder = await retrieveVersionFinder();
|
||||||
// If the line below fails with "Not a valid object name FETCH_HEAD"
|
// If the line below fails with "Not a valid object name FETCH_HEAD"
|
||||||
@ -113,10 +111,8 @@ class UpdateReleaseInfoCommand extends PackageLoopingCommand {
|
|||||||
_changedFiles = await gitVersionFinder.getChangedFiles();
|
_changedFiles = await gitVersionFinder.getChangedFiles();
|
||||||
// Anothing other than a fixed change is null.
|
// Anothing other than a fixed change is null.
|
||||||
_versionChange = null;
|
_versionChange = null;
|
||||||
break;
|
|
||||||
case _versionNext:
|
case _versionNext:
|
||||||
_versionChange = null;
|
_versionChange = null;
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
throw UnimplementedError('Unimplemented version change type');
|
throw UnimplementedError('Unimplemented version change type');
|
||||||
}
|
}
|
||||||
@ -169,10 +165,8 @@ class UpdateReleaseInfoCommand extends PackageLoopingCommand {
|
|||||||
switch (updateOutcome) {
|
switch (updateOutcome) {
|
||||||
case _ChangelogUpdateOutcome.addedSection:
|
case _ChangelogUpdateOutcome.addedSection:
|
||||||
print('${indentation}Added a $nextVersionString section.');
|
print('${indentation}Added a $nextVersionString section.');
|
||||||
break;
|
|
||||||
case _ChangelogUpdateOutcome.updatedSection:
|
case _ChangelogUpdateOutcome.updatedSection:
|
||||||
print('${indentation}Updated NEXT section.');
|
print('${indentation}Updated NEXT section.');
|
||||||
break;
|
|
||||||
case _ChangelogUpdateOutcome.failed:
|
case _ChangelogUpdateOutcome.failed:
|
||||||
return PackageResult.fail(<String>['Could not update CHANGELOG.md.']);
|
return PackageResult.fail(<String>['Could not update CHANGELOG.md.']);
|
||||||
}
|
}
|
||||||
@ -217,7 +211,6 @@ class UpdateReleaseInfoCommand extends PackageLoopingCommand {
|
|||||||
].forEach(newChangelog.writeln);
|
].forEach(newChangelog.writeln);
|
||||||
state = _ChangelogUpdateState.finishedUpdating;
|
state = _ChangelogUpdateState.finishedUpdating;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case _ChangelogUpdateState.findingFirstListItem:
|
case _ChangelogUpdateState.findingFirstListItem:
|
||||||
final RegExpMatch? match = listItemPattern.firstMatch(line);
|
final RegExpMatch? match = listItemPattern.firstMatch(line);
|
||||||
if (match != null) {
|
if (match != null) {
|
||||||
@ -239,11 +232,9 @@ class UpdateReleaseInfoCommand extends PackageLoopingCommand {
|
|||||||
printError(' Existing NEXT section has unrecognized format.');
|
printError(' Existing NEXT section has unrecognized format.');
|
||||||
return _ChangelogUpdateOutcome.failed;
|
return _ChangelogUpdateOutcome.failed;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case _ChangelogUpdateState.finishedUpdating:
|
case _ChangelogUpdateState.finishedUpdating:
|
||||||
// Once changes are done, add the rest of the lines as-is.
|
// Once changes are done, add the rest of the lines as-is.
|
||||||
newChangelog.writeln(line);
|
newChangelog.writeln(line);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,20 +210,16 @@ class VersionCheckCommand extends PackageLoopingCommand {
|
|||||||
switch (versionState) {
|
switch (versionState) {
|
||||||
case _CurrentVersionState.unchanged:
|
case _CurrentVersionState.unchanged:
|
||||||
versionChanged = false;
|
versionChanged = false;
|
||||||
break;
|
|
||||||
case _CurrentVersionState.validIncrease:
|
case _CurrentVersionState.validIncrease:
|
||||||
case _CurrentVersionState.validRevert:
|
case _CurrentVersionState.validRevert:
|
||||||
case _CurrentVersionState.newPackage:
|
case _CurrentVersionState.newPackage:
|
||||||
versionChanged = true;
|
versionChanged = true;
|
||||||
break;
|
|
||||||
case _CurrentVersionState.invalidChange:
|
case _CurrentVersionState.invalidChange:
|
||||||
versionChanged = true;
|
versionChanged = true;
|
||||||
errors.add('Disallowed version change.');
|
errors.add('Disallowed version change.');
|
||||||
break;
|
|
||||||
case _CurrentVersionState.unknown:
|
case _CurrentVersionState.unknown:
|
||||||
versionChanged = false;
|
versionChanged = false;
|
||||||
errors.add('Unable to determine previous version.');
|
errors.add('Unable to determine previous version.');
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(await _validateChangelogVersion(package,
|
if (!(await _validateChangelogVersion(package,
|
||||||
|
@ -28,7 +28,7 @@ dependencies:
|
|||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
build_runner: ^2.0.3
|
build_runner: ^2.0.3
|
||||||
matcher: ^0.12.10
|
matcher: ^0.12.10
|
||||||
mockito: '>=5.3.2 <=5.4.0'
|
mockito: '>=5.3.2 <=5.5.0'
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=2.18.0 <4.0.0'
|
sdk: '>=3.0.0 <4.0.0'
|
||||||
|
@ -25,15 +25,14 @@ void main() {
|
|||||||
final List<String> arguments =
|
final List<String> arguments =
|
||||||
invocation.positionalArguments[0]! as List<String>;
|
invocation.positionalArguments[0]! as List<String>;
|
||||||
gitDirCommands.add(arguments);
|
gitDirCommands.add(arguments);
|
||||||
final MockProcessResult mockProcessResult = MockProcessResult();
|
String? gitStdOut;
|
||||||
if (arguments[0] == 'diff') {
|
if (arguments[0] == 'diff') {
|
||||||
when<String?>(mockProcessResult.stdout as String?)
|
gitStdOut = gitDiffResponse;
|
||||||
.thenReturn(gitDiffResponse);
|
|
||||||
} else if (arguments[0] == 'merge-base') {
|
} else if (arguments[0] == 'merge-base') {
|
||||||
when<String?>(mockProcessResult.stdout as String?)
|
gitStdOut = mergeBaseResponse;
|
||||||
.thenReturn(mergeBaseResponse);
|
|
||||||
}
|
}
|
||||||
return Future<ProcessResult>.value(mockProcessResult);
|
return Future<ProcessResult>.value(
|
||||||
|
ProcessResult(0, 0, gitStdOut ?? '', ''));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -128,5 +127,3 @@ file2/file2.cc
|
|||||||
verify(gitDir.runCommand(<String>['diff', '--name-only', customBaseSha]));
|
verify(gitDir.runCommand(<String>['diff', '--name-only', customBaseSha]));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
class MockProcessResult extends Mock implements ProcessResult {}
|
|
||||||
|
@ -1,23 +1,26 @@
|
|||||||
// Mocks generated by Mockito 5.4.0 from annotations
|
// Mocks generated by Mockito 5.4.4 from annotations
|
||||||
// in flutter_plugin_tools/test/common/package_command_test.dart.
|
// in flutter_plugin_tools/test/common/package_command_test.dart.
|
||||||
// Do not manually edit this file.
|
// Do not manually edit this file.
|
||||||
|
|
||||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||||
import 'dart:async' as _i6;
|
import 'dart:async' as _i6;
|
||||||
import 'dart:io' as _i4;
|
import 'dart:io' as _i10;
|
||||||
|
|
||||||
import 'package:git/src/branch_reference.dart' as _i3;
|
import 'package:git/src/branch_reference.dart' as _i3;
|
||||||
import 'package:git/src/commit.dart' as _i2;
|
import 'package:git/src/commit.dart' as _i2;
|
||||||
import 'package:git/src/commit_reference.dart' as _i8;
|
import 'package:git/src/commit_reference.dart' as _i8;
|
||||||
import 'package:git/src/git_dir.dart' as _i5;
|
import 'package:git/src/git_dir.dart' as _i4;
|
||||||
import 'package:git/src/tag.dart' as _i7;
|
import 'package:git/src/tag.dart' as _i7;
|
||||||
import 'package:git/src/tree_entry.dart' as _i9;
|
import 'package:git/src/tree_entry.dart' as _i9;
|
||||||
import 'package:mockito/mockito.dart' as _i1;
|
import 'package:mockito/mockito.dart' as _i1;
|
||||||
|
import 'package:mockito/src/dummies.dart' as _i5;
|
||||||
|
|
||||||
// ignore_for_file: type=lint
|
// ignore_for_file: type=lint
|
||||||
// ignore_for_file: avoid_redundant_argument_values
|
// ignore_for_file: avoid_redundant_argument_values
|
||||||
// ignore_for_file: avoid_setters_without_getters
|
// ignore_for_file: avoid_setters_without_getters
|
||||||
// ignore_for_file: comment_references
|
// ignore_for_file: comment_references
|
||||||
|
// ignore_for_file: deprecated_member_use
|
||||||
|
// ignore_for_file: deprecated_member_use_from_same_package
|
||||||
// ignore_for_file: implementation_imports
|
// ignore_for_file: implementation_imports
|
||||||
// ignore_for_file: invalid_use_of_visible_for_testing_member
|
// ignore_for_file: invalid_use_of_visible_for_testing_member
|
||||||
// ignore_for_file: prefer_const_constructors
|
// ignore_for_file: prefer_const_constructors
|
||||||
@ -46,20 +49,10 @@ class _FakeBranchReference_1 extends _i1.SmartFake
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
class _FakeProcessResult_2 extends _i1.SmartFake implements _i4.ProcessResult {
|
|
||||||
_FakeProcessResult_2(
|
|
||||||
Object parent,
|
|
||||||
Invocation parentInvocation,
|
|
||||||
) : super(
|
|
||||||
parent,
|
|
||||||
parentInvocation,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A class which mocks [GitDir].
|
/// A class which mocks [GitDir].
|
||||||
///
|
///
|
||||||
/// See the documentation for Mockito's code generation for more information.
|
/// See the documentation for Mockito's code generation for more information.
|
||||||
class MockGitDir extends _i1.Mock implements _i5.GitDir {
|
class MockGitDir extends _i1.Mock implements _i4.GitDir {
|
||||||
MockGitDir() {
|
MockGitDir() {
|
||||||
_i1.throwOnMissingStub(this);
|
_i1.throwOnMissingStub(this);
|
||||||
}
|
}
|
||||||
@ -67,8 +60,12 @@ class MockGitDir extends _i1.Mock implements _i5.GitDir {
|
|||||||
@override
|
@override
|
||||||
String get path => (super.noSuchMethod(
|
String get path => (super.noSuchMethod(
|
||||||
Invocation.getter(#path),
|
Invocation.getter(#path),
|
||||||
returnValue: '',
|
returnValue: _i5.dummyValue<String>(
|
||||||
|
this,
|
||||||
|
Invocation.getter(#path),
|
||||||
|
),
|
||||||
) as String);
|
) as String);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_i6.Future<int> commitCount([String? branchName = r'HEAD']) =>
|
_i6.Future<int> commitCount([String? branchName = r'HEAD']) =>
|
||||||
(super.noSuchMethod(
|
(super.noSuchMethod(
|
||||||
@ -78,6 +75,7 @@ class MockGitDir extends _i1.Mock implements _i5.GitDir {
|
|||||||
),
|
),
|
||||||
returnValue: _i6.Future<int>.value(0),
|
returnValue: _i6.Future<int>.value(0),
|
||||||
) as _i6.Future<int>);
|
) as _i6.Future<int>);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_i6.Future<_i2.Commit> commitFromRevision(String? revision) =>
|
_i6.Future<_i2.Commit> commitFromRevision(String? revision) =>
|
||||||
(super.noSuchMethod(
|
(super.noSuchMethod(
|
||||||
@ -93,6 +91,7 @@ class MockGitDir extends _i1.Mock implements _i5.GitDir {
|
|||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
) as _i6.Future<_i2.Commit>);
|
) as _i6.Future<_i2.Commit>);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_i6.Future<Map<String, _i2.Commit>> commits([String? branchName = r'HEAD']) =>
|
_i6.Future<Map<String, _i2.Commit>> commits([String? branchName = r'HEAD']) =>
|
||||||
(super.noSuchMethod(
|
(super.noSuchMethod(
|
||||||
@ -103,6 +102,7 @@ class MockGitDir extends _i1.Mock implements _i5.GitDir {
|
|||||||
returnValue:
|
returnValue:
|
||||||
_i6.Future<Map<String, _i2.Commit>>.value(<String, _i2.Commit>{}),
|
_i6.Future<Map<String, _i2.Commit>>.value(<String, _i2.Commit>{}),
|
||||||
) as _i6.Future<Map<String, _i2.Commit>>);
|
) as _i6.Future<Map<String, _i2.Commit>>);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_i6.Future<_i3.BranchReference?> branchReference(String? branchName) =>
|
_i6.Future<_i3.BranchReference?> branchReference(String? branchName) =>
|
||||||
(super.noSuchMethod(
|
(super.noSuchMethod(
|
||||||
@ -112,6 +112,7 @@ class MockGitDir extends _i1.Mock implements _i5.GitDir {
|
|||||||
),
|
),
|
||||||
returnValue: _i6.Future<_i3.BranchReference?>.value(),
|
returnValue: _i6.Future<_i3.BranchReference?>.value(),
|
||||||
) as _i6.Future<_i3.BranchReference?>);
|
) as _i6.Future<_i3.BranchReference?>);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_i6.Future<List<_i3.BranchReference>> branches() => (super.noSuchMethod(
|
_i6.Future<List<_i3.BranchReference>> branches() => (super.noSuchMethod(
|
||||||
Invocation.method(
|
Invocation.method(
|
||||||
@ -121,6 +122,7 @@ class MockGitDir extends _i1.Mock implements _i5.GitDir {
|
|||||||
returnValue: _i6.Future<List<_i3.BranchReference>>.value(
|
returnValue: _i6.Future<List<_i3.BranchReference>>.value(
|
||||||
<_i3.BranchReference>[]),
|
<_i3.BranchReference>[]),
|
||||||
) as _i6.Future<List<_i3.BranchReference>>);
|
) as _i6.Future<List<_i3.BranchReference>>);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_i6.Stream<_i7.Tag> tags() => (super.noSuchMethod(
|
_i6.Stream<_i7.Tag> tags() => (super.noSuchMethod(
|
||||||
Invocation.method(
|
Invocation.method(
|
||||||
@ -129,6 +131,7 @@ class MockGitDir extends _i1.Mock implements _i5.GitDir {
|
|||||||
),
|
),
|
||||||
returnValue: _i6.Stream<_i7.Tag>.empty(),
|
returnValue: _i6.Stream<_i7.Tag>.empty(),
|
||||||
) as _i6.Stream<_i7.Tag>);
|
) as _i6.Stream<_i7.Tag>);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_i6.Future<List<_i8.CommitReference>> showRef({
|
_i6.Future<List<_i8.CommitReference>> showRef({
|
||||||
bool? heads = false,
|
bool? heads = false,
|
||||||
@ -146,6 +149,7 @@ class MockGitDir extends _i1.Mock implements _i5.GitDir {
|
|||||||
returnValue: _i6.Future<List<_i8.CommitReference>>.value(
|
returnValue: _i6.Future<List<_i8.CommitReference>>.value(
|
||||||
<_i8.CommitReference>[]),
|
<_i8.CommitReference>[]),
|
||||||
) as _i6.Future<List<_i8.CommitReference>>);
|
) as _i6.Future<List<_i8.CommitReference>>);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_i6.Future<_i3.BranchReference> currentBranch() => (super.noSuchMethod(
|
_i6.Future<_i3.BranchReference> currentBranch() => (super.noSuchMethod(
|
||||||
Invocation.method(
|
Invocation.method(
|
||||||
@ -161,6 +165,7 @@ class MockGitDir extends _i1.Mock implements _i5.GitDir {
|
|||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
) as _i6.Future<_i3.BranchReference>);
|
) as _i6.Future<_i3.BranchReference>);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_i6.Future<List<_i9.TreeEntry>> lsTree(
|
_i6.Future<List<_i9.TreeEntry>> lsTree(
|
||||||
String? treeish, {
|
String? treeish, {
|
||||||
@ -178,6 +183,7 @@ class MockGitDir extends _i1.Mock implements _i5.GitDir {
|
|||||||
),
|
),
|
||||||
returnValue: _i6.Future<List<_i9.TreeEntry>>.value(<_i9.TreeEntry>[]),
|
returnValue: _i6.Future<List<_i9.TreeEntry>>.value(<_i9.TreeEntry>[]),
|
||||||
) as _i6.Future<List<_i9.TreeEntry>>);
|
) as _i6.Future<List<_i9.TreeEntry>>);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_i6.Future<String?> createOrUpdateBranch(
|
_i6.Future<String?> createOrUpdateBranch(
|
||||||
String? branchName,
|
String? branchName,
|
||||||
@ -195,6 +201,7 @@ class MockGitDir extends _i1.Mock implements _i5.GitDir {
|
|||||||
),
|
),
|
||||||
returnValue: _i6.Future<String?>.value(),
|
returnValue: _i6.Future<String?>.value(),
|
||||||
) as _i6.Future<String?>);
|
) as _i6.Future<String?>);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_i6.Future<String> commitTree(
|
_i6.Future<String> commitTree(
|
||||||
String? treeSha,
|
String? treeSha,
|
||||||
@ -210,8 +217,19 @@ class MockGitDir extends _i1.Mock implements _i5.GitDir {
|
|||||||
],
|
],
|
||||||
{#parentCommitShas: parentCommitShas},
|
{#parentCommitShas: parentCommitShas},
|
||||||
),
|
),
|
||||||
returnValue: _i6.Future<String>.value(''),
|
returnValue: _i6.Future<String>.value(_i5.dummyValue<String>(
|
||||||
|
this,
|
||||||
|
Invocation.method(
|
||||||
|
#commitTree,
|
||||||
|
[
|
||||||
|
treeSha,
|
||||||
|
commitMessage,
|
||||||
|
],
|
||||||
|
{#parentCommitShas: parentCommitShas},
|
||||||
|
),
|
||||||
|
)),
|
||||||
) as _i6.Future<String>);
|
) as _i6.Future<String>);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_i6.Future<Map<String, String>> writeObjects(List<String>? paths) =>
|
_i6.Future<Map<String, String>> writeObjects(List<String>? paths) =>
|
||||||
(super.noSuchMethod(
|
(super.noSuchMethod(
|
||||||
@ -221,8 +239,9 @@ class MockGitDir extends _i1.Mock implements _i5.GitDir {
|
|||||||
),
|
),
|
||||||
returnValue: _i6.Future<Map<String, String>>.value(<String, String>{}),
|
returnValue: _i6.Future<Map<String, String>>.value(<String, String>{}),
|
||||||
) as _i6.Future<Map<String, String>>);
|
) as _i6.Future<Map<String, String>>);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_i6.Future<_i4.ProcessResult> runCommand(
|
_i6.Future<_i10.ProcessResult> runCommand(
|
||||||
Iterable<String>? args, {
|
Iterable<String>? args, {
|
||||||
bool? throwOnError = true,
|
bool? throwOnError = true,
|
||||||
}) =>
|
}) =>
|
||||||
@ -232,7 +251,8 @@ class MockGitDir extends _i1.Mock implements _i5.GitDir {
|
|||||||
[args],
|
[args],
|
||||||
{#throwOnError: throwOnError},
|
{#throwOnError: throwOnError},
|
||||||
),
|
),
|
||||||
returnValue: _i6.Future<_i4.ProcessResult>.value(_FakeProcessResult_2(
|
returnValue: _i6.Future<_i10.ProcessResult>.value(
|
||||||
|
_i5.dummyValue<_i10.ProcessResult>(
|
||||||
this,
|
this,
|
||||||
Invocation.method(
|
Invocation.method(
|
||||||
#runCommand,
|
#runCommand,
|
||||||
@ -240,7 +260,8 @@ class MockGitDir extends _i1.Mock implements _i5.GitDir {
|
|||||||
{#throwOnError: throwOnError},
|
{#throwOnError: throwOnError},
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
) as _i6.Future<_i4.ProcessResult>);
|
) as _i6.Future<_i10.ProcessResult>);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_i6.Future<bool> isWorkingTreeClean() => (super.noSuchMethod(
|
_i6.Future<bool> isWorkingTreeClean() => (super.noSuchMethod(
|
||||||
Invocation.method(
|
Invocation.method(
|
||||||
@ -249,10 +270,11 @@ class MockGitDir extends _i1.Mock implements _i5.GitDir {
|
|||||||
),
|
),
|
||||||
returnValue: _i6.Future<bool>.value(false),
|
returnValue: _i6.Future<bool>.value(false),
|
||||||
) as _i6.Future<bool>);
|
) as _i6.Future<bool>);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_i6.Future<_i2.Commit?> updateBranch(
|
_i6.Future<_i2.Commit?> updateBranch(
|
||||||
String? branchName,
|
String? branchName,
|
||||||
_i6.Future<dynamic> Function(_i4.Directory)? populater,
|
_i6.Future<dynamic> Function(_i10.Directory)? populater,
|
||||||
String? commitMessage,
|
String? commitMessage,
|
||||||
) =>
|
) =>
|
||||||
(super.noSuchMethod(
|
(super.noSuchMethod(
|
||||||
@ -266,6 +288,7 @@ class MockGitDir extends _i1.Mock implements _i5.GitDir {
|
|||||||
),
|
),
|
||||||
returnValue: _i6.Future<_i2.Commit?>.value(),
|
returnValue: _i6.Future<_i2.Commit?>.value(),
|
||||||
) as _i6.Future<_i2.Commit?>);
|
) as _i6.Future<_i2.Commit?>);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_i6.Future<_i2.Commit?> updateBranchWithDirectoryContents(
|
_i6.Future<_i2.Commit?> updateBranchWithDirectoryContents(
|
||||||
String? branchName,
|
String? branchName,
|
||||||
|
@ -116,12 +116,12 @@ void main() {
|
|||||||
.thenAnswer((Invocation invocation) {
|
.thenAnswer((Invocation invocation) {
|
||||||
final List<String> arguments =
|
final List<String> arguments =
|
||||||
invocation.positionalArguments[0]! as List<String>;
|
invocation.positionalArguments[0]! as List<String>;
|
||||||
final MockProcessResult mockProcessResult = MockProcessResult();
|
String? gitStdOut;
|
||||||
if (arguments[0] == 'diff') {
|
if (arguments[0] == 'diff') {
|
||||||
when<String?>(mockProcessResult.stdout as String?)
|
gitStdOut = gitDiffResponse;
|
||||||
.thenReturn(gitDiffResponse);
|
|
||||||
}
|
}
|
||||||
return Future<io.ProcessResult>.value(mockProcessResult);
|
return Future<io.ProcessResult>.value(
|
||||||
|
io.ProcessResult(0, 0, gitStdOut ?? '', ''));
|
||||||
});
|
});
|
||||||
|
|
||||||
return TestPackageLoopingCommand(
|
return TestPackageLoopingCommand(
|
||||||
@ -945,5 +945,3 @@ class TestPackageLoopingCommand extends PackageLoopingCommand {
|
|||||||
capturedOutput.addAll(output);
|
capturedOutput.addAll(output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MockProcessResult extends Mock implements io.ProcessResult {}
|
|
||||||
|
@ -394,8 +394,9 @@ void main() {
|
|||||||
platformIOS: const PlatformDetails(PlatformSupport.inline)
|
platformIOS: const PlatformDetails(PlatformSupport.inline)
|
||||||
});
|
});
|
||||||
|
|
||||||
final Iterable<Directory> exampleDirs = plugin.getExamples().map(
|
final Iterable<Directory> exampleDirs = plugin
|
||||||
(RepositoryPackage example) => example.directory);
|
.getExamples()
|
||||||
|
.map((RepositoryPackage example) => example.directory);
|
||||||
|
|
||||||
final List<String> output = await runCapturingPrint(
|
final List<String> output = await runCapturingPrint(
|
||||||
runner, <String>['fetch-deps', '--no-dart', '--ios']);
|
runner, <String>['fetch-deps', '--no-dart', '--ios']);
|
||||||
@ -435,7 +436,8 @@ void main() {
|
|||||||
.mockProcessesForExecutable[getFlutterCommand(mockPlatform)] =
|
.mockProcessesForExecutable[getFlutterCommand(mockPlatform)] =
|
||||||
<FakeProcessInfo>[
|
<FakeProcessInfo>[
|
||||||
FakeProcessInfo(MockProcess(), <String>['precache']),
|
FakeProcessInfo(MockProcess(), <String>['precache']),
|
||||||
FakeProcessInfo(MockProcess(exitCode: 1), <String>['build', 'ios', '--config-only']),
|
FakeProcessInfo(MockProcess(exitCode: 1),
|
||||||
|
<String>['build', 'ios', '--config-only']),
|
||||||
];
|
];
|
||||||
|
|
||||||
Error? commandError;
|
Error? commandError;
|
||||||
@ -499,8 +501,9 @@ void main() {
|
|||||||
platformMacOS: const PlatformDetails(PlatformSupport.inline)
|
platformMacOS: const PlatformDetails(PlatformSupport.inline)
|
||||||
});
|
});
|
||||||
|
|
||||||
final Iterable<Directory> exampleDirs = plugin.getExamples().map(
|
final Iterable<Directory> exampleDirs = plugin
|
||||||
(RepositoryPackage example) => example.directory);
|
.getExamples()
|
||||||
|
.map((RepositoryPackage example) => example.directory);
|
||||||
|
|
||||||
final List<String> output = await runCapturingPrint(
|
final List<String> output = await runCapturingPrint(
|
||||||
runner, <String>['fetch-deps', '--no-dart', '--macos']);
|
runner, <String>['fetch-deps', '--no-dart', '--macos']);
|
||||||
@ -540,7 +543,8 @@ void main() {
|
|||||||
.mockProcessesForExecutable[getFlutterCommand(mockPlatform)] =
|
.mockProcessesForExecutable[getFlutterCommand(mockPlatform)] =
|
||||||
<FakeProcessInfo>[
|
<FakeProcessInfo>[
|
||||||
FakeProcessInfo(MockProcess(), <String>['precache']),
|
FakeProcessInfo(MockProcess(), <String>['precache']),
|
||||||
FakeProcessInfo(MockProcess(exitCode: 1), <String>['build', 'macos', '--config-only']),
|
FakeProcessInfo(MockProcess(exitCode: 1),
|
||||||
|
<String>['build', 'macos', '--config-only']),
|
||||||
];
|
];
|
||||||
|
|
||||||
Error? commandError;
|
Error? commandError;
|
||||||
|
@ -306,13 +306,11 @@ String _pluginPlatformSection(
|
|||||||
if (support.hasDartCode) {
|
if (support.hasDartCode) {
|
||||||
lines.add(' dartPluginClass: FakeDartPlugin');
|
lines.add(' dartPluginClass: FakeDartPlugin');
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case platformWeb:
|
case platformWeb:
|
||||||
lines.addAll(<String>[
|
lines.addAll(<String>[
|
||||||
' pluginClass: FakePlugin',
|
' pluginClass: FakePlugin',
|
||||||
' fileName: ${packageName}_web.dart',
|
' fileName: ${packageName}_web.dart',
|
||||||
]);
|
]);
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
assert(false, 'Unrecognized platform: $platform');
|
assert(false, 'Unrecognized platform: $platform');
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user