Unverified Commit b7881e5b authored by Sigurd Meldgaard's avatar Sigurd Meldgaard Committed by GitHub

Align `flutter pub get/upgrade/add/remove/downgrade` (#117896)

* Align `flutter pub get/upgrade/add/remove/downgrade`

* Add final . to command description

* Remove trailing whitespace

* Don't print message that command is being run

* Update expectations

* Use relative path

* Remove duplicated line

* Improve function dartdoc
parent cf529ec5
......@@ -29,7 +29,6 @@ class FakePub extends Fake implements Pub {
Future<void> get({
PubContext? context,
required FlutterProject project,
bool skipIfAbsent = false,
bool upgrade = false,
bool offline = false,
bool generateSyntheticPackage = false,
......
......@@ -480,7 +480,6 @@ class FakePub extends Fake implements Pub {
Future<void> get({
PubContext? context,
required FlutterProject project,
bool skipIfAbsent = false,
bool upgrade = false,
bool offline = false,
bool generateSyntheticPackage = false,
......
......@@ -35,7 +35,7 @@ void main() {
fileSystem.currentDirectory.childFile('.flutter-plugins').createSync();
fileSystem.currentDirectory.childFile('.flutter-plugins-dependencies').createSync();
final PackagesGetCommand command = PackagesGetCommand('get', false);
final PackagesGetCommand command = PackagesGetCommand('get', '', PubContext.pubGet);
final CommandRunner<void> commandRunner = createTestCommandRunner(command);
await commandRunner.run(<String>['get']);
......@@ -60,7 +60,7 @@ void main() {
..createSync(recursive: true)
..writeAsBytesSync(<int>[0]);
final PackagesGetCommand command = PackagesGetCommand('get', false);
final PackagesGetCommand command = PackagesGetCommand('get', '', PubContext.pubGet);
final CommandRunner<void> commandRunner = createTestCommandRunner(command);
await commandRunner.run(<String>['get']);
......@@ -81,7 +81,7 @@ void main() {
final Directory targetDirectory = fileSystem.currentDirectory.childDirectory('target');
targetDirectory.childFile('pubspec.yaml').createSync();
final PackagesGetCommand command = PackagesGetCommand('get', false);
final PackagesGetCommand command = PackagesGetCommand('get', '', PubContext.pubGet);
final CommandRunner<void> commandRunner = createTestCommandRunner(command);
await commandRunner.run(<String>['get', targetDirectory.path]);
......@@ -98,7 +98,7 @@ void main() {
fileSystem.currentDirectory.childFile('pubspec.yaml').createSync();
fileSystem.currentDirectory.childDirectory('example').createSync(recursive: true);
final PackagesGetCommand command = PackagesGetCommand('get', false);
final PackagesGetCommand command = PackagesGetCommand('get', '', PubContext.pubGet);
final CommandRunner<void> commandRunner = createTestCommandRunner(command);
await commandRunner.run(<String>['get']);
......@@ -115,7 +115,7 @@ void main() {
});
testUsingContext('pub get throws error on missing directory', () async {
final PackagesGetCommand command = PackagesGetCommand('get', false);
final PackagesGetCommand command = PackagesGetCommand('get', '', PubContext.pubGet);
final CommandRunner<void> commandRunner = createTestCommandRunner(command);
try {
......@@ -159,7 +159,7 @@ void main() {
'''
);
final PackagesGetCommand command = PackagesGetCommand('get', false);
final PackagesGetCommand command = PackagesGetCommand('get', '', PubContext.pubGet);
final CommandRunner<void> commandRunner = createTestCommandRunner(command);
await commandRunner.run(<String>['get']);
......@@ -183,23 +183,21 @@ class FakePub extends Fake implements Pub {
final FileSystem fileSystem;
@override
Future<void> get({
Future<void> interactively(
List<String> arguments, {
FlutterProject? project,
required PubContext context,
required FlutterProject project,
bool skipIfAbsent = false,
bool upgrade = false,
bool offline = false,
required String command,
bool touchesPackageConfig = false,
bool generateSyntheticPackage = false,
bool generateSyntheticPackageForExample = false,
String? flutterRootOverride,
bool checkUpToDate = false,
bool shouldSkipThirdPartyGenerator = true,
bool printProgress = true,
}) async {
fileSystem.directory(project.directory)
.childDirectory('.dart_tool')
.childFile('package_config.json')
..createSync(recursive: true)
..writeAsStringSync('{"configVersion":2,"packages":[]}');
if (project != null) {
fileSystem.directory(project.directory)
.childDirectory('.dart_tool')
.childFile('package_config.json')
..createSync(recursive: true)
..writeAsStringSync('{"configVersion":2,"packages":[]}');
}
}
}
......@@ -275,7 +275,6 @@ class FakePub extends Fake implements Pub {
Future<void> get({
required PubContext context,
required FlutterProject project,
bool skipIfAbsent = false,
bool upgrade = false,
bool offline = false,
bool generateSyntheticPackage = false,
......
......@@ -72,6 +72,7 @@ void main() {
'packages',
verb,
...?args,
'--directory',
projectPath,
]);
return command;
......
......@@ -1208,7 +1208,6 @@ class FakePub extends Fake implements Pub {
Future<void> get({
PubContext? context,
required FlutterProject project,
bool skipIfAbsent = false,
bool upgrade = false,
bool offline = false,
bool generateSyntheticPackage = false,
......
......@@ -557,7 +557,7 @@ exit code: 66
),
throwsA(isA<ToolExit>().having((ToolExit error) => error.message, 'message', toolExitMessage)),
);
expect(logger.statusText, 'Running "flutter pub get" in /...\n');
expect(logger.statusText, isEmpty);
expect(
mockStdio.stdout.writes.map(utf8.decode),
<String>[
......@@ -634,9 +634,7 @@ exit code: 66
),
),
);
expect(logger.statusText,
'Running "flutter pub get" in /...\n'
);
expect(logger.statusText, isEmpty);
expect(logger.errorText, isEmpty);
expect(processManager, hasNoRemainingExpectations);
});
......@@ -1074,7 +1072,6 @@ exit code: 66
context: PubContext.flutterTests,
); // pub sets date of .packages to 2002
expect(logger.statusText, 'Running "flutter pub get" in /...\n');
expect(logger.errorText, isEmpty);
expect(fileSystem.file('pubspec.yaml').lastModifiedSync(), DateTime(2001)); // because nothing should touch it
logger.clear();
......@@ -1089,7 +1086,7 @@ exit code: 66
context: PubContext.flutterTests,
); // pub does nothing
expect(logger.statusText, 'Running "flutter pub get" in /...\n');
expect(logger.statusText, isEmpty);
expect(logger.errorText, isEmpty);
expect(fileSystem.file('pubspec.yaml').lastModifiedSync(), DateTime(2001)); // because nothing should touch it
logger.clear();
......
......@@ -951,7 +951,6 @@ class FakePub extends Fake implements Pub {
Future<void> get({
required PubContext context,
required FlutterProject project,
bool skipIfAbsent = false,
bool upgrade = false,
bool offline = false,
String? flutterRootOverride,
......
......@@ -110,15 +110,8 @@ class FakeCommand {
Map<String, String>? environment,
Encoding? encoding,
) {
expect(command.length, this.command.length);
for(int i = 0; i < command.length; i++) {
final Pattern expected = this.command[i];
if (expected is String) {
expect(command[i], expected);
} else {
expect(command[i], matches(this.command[i]));
}
}
final List<dynamic> matchers = this.command.map((Pattern x) => x is String ? x : matches(x)).toList();
expect(command, matchers);
if (this.workingDirectory != null) {
expect(this.workingDirectory, workingDirectory);
}
......
......@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/dart/pub.dart';
import 'package:flutter_tools/src/project.dart';
......@@ -21,7 +20,6 @@ class ThrowingPub implements Pub {
Future<void> get({
PubContext? context,
required FlutterProject project,
bool skipIfAbsent = false,
bool upgrade = false,
bool offline = false,
bool checkLastModified = true,
......@@ -39,10 +37,12 @@ class ThrowingPub implements Pub {
@override
Future<void> interactively(
List<String> arguments, {
String? directory,
required Stdio stdio,
FlutterProject? project,
required PubContext context,
required String command,
bool touchesPackageConfig = false,
bool generateSyntheticPackage = false,
bool printProgress = true,
}) {
throw UnsupportedError('Attempted to invoke pub during test.');
}
......
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