Android analyze command should run pub (#153953)
The android command will build the android project partially and thus will need to run pub
This commit is contained in:
parent
454908185f
commit
dde2328185
@ -210,9 +210,10 @@ class AnalyzeCommand extends FlutterCommand {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Don't run pub if asking for android analysis.
|
||||
// Android analyze needs to process resource, i.e. evaluating build
|
||||
// settings and assets, and thus needs to run pub.
|
||||
if (boolArg('android')) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.shouldRunPub;
|
||||
|
@ -23,6 +23,26 @@ import '../../src/test_flutter_command_runner.dart';
|
||||
|
||||
void main() {
|
||||
|
||||
testUsingContext('Android analyze command should run pub', () async {
|
||||
final FileSystem fileSystem = MemoryFileSystem.test();
|
||||
final Platform platform = FakePlatform();
|
||||
final BufferLogger logger = BufferLogger.test();
|
||||
final FakeProcessManager processManager = FakeProcessManager.empty();
|
||||
final Terminal terminal = Terminal.test();
|
||||
final AnalyzeCommand command = FakeAndroidAnalyzeCommand(
|
||||
artifacts: Artifacts.test(),
|
||||
fileSystem: fileSystem,
|
||||
logger: logger,
|
||||
platform: platform,
|
||||
processManager: processManager,
|
||||
terminal: terminal,
|
||||
allProjectValidators: <ProjectValidator>[],
|
||||
suppressAnalytics: true,
|
||||
);
|
||||
fileSystem.currentDirectory.childFile('pubspec.yaml').createSync();
|
||||
expect(command.shouldRunPub, isTrue);
|
||||
});
|
||||
|
||||
group('Android analyze command', () {
|
||||
late FileSystem fileSystem;
|
||||
late Platform platform;
|
||||
@ -65,7 +85,6 @@ void main() {
|
||||
fileSystem.directory(homePath).childDirectory(dir).createSync(recursive: true);
|
||||
}
|
||||
builder = FakeAndroidBuilder();
|
||||
|
||||
});
|
||||
|
||||
testUsingContext('can list build variants', () async {
|
||||
@ -130,3 +149,30 @@ class FakeAndroidBuilder extends Fake implements AndroidBuilder {
|
||||
return outputPath;
|
||||
}
|
||||
}
|
||||
|
||||
class FakeAndroidAnalyzeCommand extends AnalyzeCommand {
|
||||
FakeAndroidAnalyzeCommand({
|
||||
required super.fileSystem,
|
||||
required super.platform,
|
||||
required super.terminal,
|
||||
required super.logger,
|
||||
required super.processManager,
|
||||
required super.artifacts,
|
||||
required super.allProjectValidators,
|
||||
required super.suppressAnalytics,
|
||||
});
|
||||
|
||||
@override
|
||||
bool boolArg(String arg, {bool global = false}) {
|
||||
switch (arg) {
|
||||
case 'current-package':
|
||||
return true;
|
||||
case 'android':
|
||||
return true;
|
||||
case 'pub':
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user