Unverified Commit 8df0d686 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] remove globals from pub (#55412)

parent cbc121e3
......@@ -205,7 +205,7 @@ class PackagesPublishCommand extends FlutterCommand {
if (boolArg('force')) '--force',
];
Cache.releaseLockEarly();
await pub.interactively(<String>['publish', ...args]);
await pub.interactively(<String>['publish', ...args], stdio: globals.stdio);
return FlutterCommandResult.success();
}
}
......@@ -236,7 +236,7 @@ class PackagesForwardCommand extends FlutterCommand {
@override
Future<FlutterCommandResult> runCommand() async {
Cache.releaseLockEarly();
await pub.interactively(<String>[_commandName, ...argResults.rest]);
await pub.interactively(<String>[_commandName, ...argResults.rest], stdio: globals.stdio);
return FlutterCommandResult.success();
}
......@@ -264,7 +264,7 @@ class PackagesPassthroughCommand extends FlutterCommand {
@override
Future<FlutterCommandResult> runCommand() async {
Cache.releaseLockEarly();
await pub.interactively(argResults.rest);
await pub.interactively(argResults.rest, stdio: globals.stdio);
return FlutterCommandResult.success();
}
}
......@@ -167,7 +167,14 @@ Future<T> runInContext<T>(
processManager: globals.processManager,
logger: globals.logger,
),
Pub: () => const Pub(),
Pub: () => Pub(
fileSystem: globals.fs,
logger: globals.logger,
processManager: globals.processManager,
botDetector: globals.botDetector,
platform: globals.platform,
usage: globals.flutterUsage,
),
ShutdownHooks: () => ShutdownHooks(logger: globals.logger),
Signals: () => Signals(),
Stdio: () => Stdio(),
......
......@@ -129,7 +129,8 @@ class PubResultEvent extends UsageEvent {
PubResultEvent({
@required String context,
@required String result,
}) : super('pub-result', context, label: result, flutterUsage: globals.flutterUsage);
@required Usage usage,
}) : super('pub-result', context, label: result, flutterUsage: usage);
}
/// An event that reports something about a build.
......
......@@ -15,6 +15,7 @@ import 'package:flutter_tools/src/dart/sdk.dart';
import 'package:flutter_tools/src/runner/flutter_command_runner.dart';
import 'package:platform/platform.dart';
import 'package:process/process.dart';
import 'package:flutter_tools/src/globals.dart' as globals;
import '../../src/common.dart';
import '../../src/context.dart';
......@@ -65,7 +66,15 @@ void main() {
testUsingContext('AnalysisServer success', () async {
_createSampleProject(tempDir);
await const Pub().get(context: PubContext.flutterTests, directory: tempDir.path);
final Pub pub = Pub(
fileSystem: fileSystem,
logger: logger,
processManager: processManager,
platform: const LocalPlatform(),
botDetector: globals.botDetector,
usage: globals.flutterUsage,
);
await pub.get(context: PubContext.flutterTests, directory: tempDir.path);
server = AnalysisServer(dartSdkPath, <String>[tempDir.path],
fileSystem: fileSystem,
......@@ -90,7 +99,15 @@ void main() {
testUsingContext('AnalysisServer errors', () async {
_createSampleProject(tempDir, brokenCode: true);
await const Pub().get(context: PubContext.flutterTests, directory: tempDir.path);
final Pub pub = Pub(
fileSystem: fileSystem,
logger: logger,
processManager: processManager,
platform: const LocalPlatform(),
usage: globals.flutterUsage,
botDetector: globals.botDetector,
);
await pub.get(context: PubContext.flutterTests, directory: tempDir.path);
server = AnalysisServer(dartSdkPath, <String>[tempDir.path],
fileSystem: fileSystem,
......
......@@ -86,7 +86,14 @@ void main() {
);
return _runFlutterTest(projectDir);
}, overrides: <Type, Generator>{
Pub: () => const Pub(),
Pub: () => Pub(
fileSystem: globals.fs,
logger: globals.logger,
processManager: globals.processManager,
usage: globals.flutterUsage,
botDetector: globals.botDetector,
platform: globals.platform,
),
});
testUsingContext('can create a default project if empty directory exists', () async {
......@@ -104,7 +111,14 @@ void main() {
],
);
}, overrides: <Type, Generator>{
Pub: () => const Pub(),
Pub: () => Pub(
fileSystem: globals.fs,
logger: globals.logger,
processManager: globals.processManager,
usage: globals.flutterUsage,
botDetector: globals.botDetector,
platform: globals.platform,
),
});
testUsingContext('creates a module project correctly', () async {
......@@ -126,7 +140,14 @@ void main() {
]);
return _runFlutterTest(projectDir);
}, overrides: <Type, Generator>{
Pub: () => const Pub(),
Pub: () => Pub(
fileSystem: globals.fs,
logger: globals.logger,
processManager: globals.processManager,
usage: globals.flutterUsage,
botDetector: globals.botDetector,
platform: globals.platform,
),
});
testUsingContext('cannot create a project if non-empty non-project directory exists with .metadata', () async {
......@@ -144,7 +165,14 @@ void main() {
]),
throwsToolExit(message: 'Sorry, unable to detect the type of project to recreate'));
}, overrides: <Type, Generator>{
Pub: () => const Pub(),
Pub: () => Pub(
fileSystem: globals.fs,
logger: globals.logger,
processManager: globals.processManager,
usage: globals.flutterUsage,
botDetector: globals.botDetector,
platform: globals.platform,
),
...noColorTerminalOverride,
});
......@@ -170,7 +198,14 @@ void main() {
],
);
}, overrides: <Type, Generator>{
Pub: () => const Pub(),
Pub: () => Pub(
fileSystem: globals.fs,
logger: globals.logger,
processManager: globals.processManager,
usage: globals.flutterUsage,
botDetector: globals.botDetector,
platform: globals.platform,
),
});
testUsingContext('detects and recreates an app project correctly', () async {
......@@ -195,7 +230,14 @@ void main() {
],
);
}, overrides: <Type, Generator>{
Pub: () => const Pub(),
Pub: () => Pub(
fileSystem: globals.fs,
logger: globals.logger,
processManager: globals.processManager,
usage: globals.flutterUsage,
botDetector: globals.botDetector,
platform: globals.platform,
),
});
testUsingContext('detects and recreates a plugin project correctly', () async {
......@@ -220,7 +262,14 @@ void main() {
],
);
}, overrides: <Type, Generator>{
Pub: () => const Pub(),
Pub: () => Pub(
fileSystem: globals.fs,
logger: globals.logger,
processManager: globals.processManager,
usage: globals.flutterUsage,
botDetector: globals.botDetector,
platform: globals.platform,
),
});
testUsingContext('detects and recreates a package project correctly', () async {
......@@ -251,7 +300,14 @@ void main() {
],
);
}, overrides: <Type, Generator>{
Pub: () => const Pub(),
Pub: () => Pub(
fileSystem: globals.fs,
logger: globals.logger,
processManager: globals.processManager,
usage: globals.flutterUsage,
botDetector: globals.botDetector,
platform: globals.platform,
),
});
testUsingContext('kotlin/swift legacy app project', () async {
......@@ -273,7 +329,14 @@ void main() {
],
);
}, overrides: <Type, Generator>{
Pub: () => const Pub(),
Pub: () => Pub(
fileSystem: globals.fs,
logger: globals.logger,
processManager: globals.processManager,
usage: globals.flutterUsage,
botDetector: globals.botDetector,
platform: globals.platform,
),
});
testUsingContext('can create a package project', () async {
......@@ -303,7 +366,14 @@ void main() {
);
return _runFlutterTest(projectDir);
}, overrides: <Type, Generator>{
Pub: () => const Pub(),
Pub: () => Pub(
fileSystem: globals.fs,
logger: globals.logger,
processManager: globals.processManager,
usage: globals.flutterUsage,
botDetector: globals.botDetector,
platform: globals.platform,
),
});
testUsingContext('can create a plugin project', () async {
......@@ -325,7 +395,14 @@ void main() {
);
return _runFlutterTest(projectDir.childDirectory('example'));
}, overrides: <Type, Generator>{
Pub: () => const Pub(),
Pub: () => Pub(
fileSystem: globals.fs,
logger: globals.logger,
processManager: globals.processManager,
usage: globals.flutterUsage,
botDetector: globals.botDetector,
platform: globals.platform,
),
});
testUsingContext('plugin example app depends on plugin', () async {
......@@ -344,7 +421,14 @@ void main() {
final PathDependency pathDependency = pubspec.dependencies[pluginName] as PathDependency;
expect(pathDependency.path, '../');
}, overrides: <Type, Generator>{
Pub: () => const Pub(),
Pub: () => Pub(
fileSystem: globals.fs,
logger: globals.logger,
processManager: globals.processManager,
usage: globals.flutterUsage,
botDetector: globals.botDetector,
platform: globals.platform,
),
});
testUsingContext('kotlin/swift plugin project', () async {
......@@ -429,7 +513,14 @@ void main() {
<String>['lib/main.dart'],
);
}, overrides: <Type, Generator>{
Pub: () => const Pub(),
Pub: () => Pub(
fileSystem: globals.fs,
logger: globals.logger,
processManager: globals.processManager,
usage: globals.flutterUsage,
botDetector: globals.botDetector,
platform: globals.platform,
),
});
testUsingContext('module project with pub', () async {
......@@ -464,7 +555,14 @@ void main() {
'.android/Flutter/src/main/java/io/flutter/facade/Flutter.java',
]);
}, overrides: <Type, Generator>{
Pub: () => const Pub(),
Pub: () => Pub(
fileSystem: globals.fs,
logger: globals.logger,
processManager: globals.processManager,
usage: globals.flutterUsage,
botDetector: globals.botDetector,
platform: globals.platform,
),
});
......@@ -1038,7 +1136,14 @@ void main() {
],
);
}, overrides: <Type, Generator>{
Pub: () => const Pub(),
Pub: () => Pub(
fileSystem: globals.fs,
logger: globals.logger,
processManager: globals.processManager,
usage: globals.flutterUsage,
botDetector: globals.botDetector,
platform: globals.platform,
),
});
testUsingContext('can re-gen module .ios/ folder, reusing custom org', () async {
......@@ -1055,7 +1160,14 @@ void main() {
'com.bar.foo.flutterProject',
);
}, overrides: <Type, Generator>{
Pub: () => const Pub(),
Pub: () => Pub(
fileSystem: globals.fs,
logger: globals.logger,
processManager: globals.processManager,
usage: globals.flutterUsage,
botDetector: globals.botDetector,
platform: globals.platform,
),
});
testUsingContext('can re-gen app android/ folder, reusing custom org', () async {
......@@ -1210,7 +1322,14 @@ void main() {
],
);
}, overrides: <Type, Generator>{
Pub: () => const Pub(),
Pub: () => Pub(
fileSystem: globals.fs,
logger: globals.logger,
processManager: globals.processManager,
usage: globals.flutterUsage,
botDetector: globals.botDetector,
platform: globals.platform,
),
});
testUsingContext(
......@@ -1227,7 +1346,14 @@ void main() {
},
overrides: <Type, Generator>{
ProcessManager: () => loggingProcessManager,
Pub: () => const Pub(),
Pub: () => Pub(
fileSystem: globals.fs,
logger: globals.logger,
processManager: globals.processManager,
usage: globals.flutterUsage,
botDetector: globals.botDetector,
platform: globals.platform,
),
},
);
......@@ -1245,7 +1371,14 @@ void main() {
},
overrides: <Type, Generator>{
ProcessManager: () => loggingProcessManager,
Pub: () => const Pub(),
Pub: () => Pub(
fileSystem: globals.fs,
logger: globals.logger,
processManager: globals.processManager,
usage: globals.flutterUsage,
botDetector: globals.botDetector,
platform: globals.platform,
),
},
);
......
......@@ -4,7 +4,9 @@
import 'dart:async';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/dart/pub.dart';
import 'package:meta/meta.dart';
class ThrowingPub implements Pub {
@override
......@@ -34,7 +36,7 @@ class ThrowingPub implements Pub {
}
@override
Future<void> interactively(List<String> arguments, {String directory}) {
Future<void> interactively(List<String> arguments, {String directory, @required Stdio stdio,}) {
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