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