mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
[flutter_tools] do not make drive require pub if --no-pub is requested (#79379)
This commit is contained in:
parent
1f30bfd417
commit
f59b185be4
@ -147,9 +147,15 @@ class DriveCommand extends RunCommandBase {
|
||||
}
|
||||
|
||||
// `pub` must always be run due to the test script running from source,
|
||||
// even if an application binary is used.
|
||||
// even if an application binary is used. Default to true unless the user explicitly
|
||||
// specified not to.
|
||||
@override
|
||||
bool get shouldRunPub => true;
|
||||
bool get shouldRunPub {
|
||||
if (argResults.wasParsed('pub') && !boolArg('pub')) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
FlutterDriverFactory _flutterDriverFactory;
|
||||
final FileSystem _fileSystem;
|
||||
|
@ -8,11 +8,15 @@ import 'package:file/memory.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/commands/drive.dart';
|
||||
import 'package:flutter_tools/src/dart/pub.dart';
|
||||
import 'package:flutter_tools/src/device.dart';
|
||||
import 'package:test/fake.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
import '../../src/context.dart';
|
||||
import '../../src/fakes.dart';
|
||||
|
||||
void main() {
|
||||
FileSystem fileSystem;
|
||||
@ -25,6 +29,15 @@ void main() {
|
||||
platform = FakePlatform(operatingSystem: 'linux');
|
||||
});
|
||||
|
||||
setUpAll(() {
|
||||
Cache.disableLocking();
|
||||
});
|
||||
|
||||
tearDownAll(() {
|
||||
Cache.enableLocking();
|
||||
});
|
||||
|
||||
|
||||
testWithoutContext('drive --screenshot writes to expected output', () async {
|
||||
final Device screenshotDevice = ScreenshotDevice();
|
||||
|
||||
@ -60,6 +73,33 @@ void main() {
|
||||
expect(logger.statusText, isEmpty);
|
||||
expect(logger.errorText, contains('Error taking screenshot: FileSystemException: Not a directory'));
|
||||
});
|
||||
|
||||
testUsingContext('shouldRunPub is true unless user specifies --no-pub', () async {
|
||||
final DriveCommand command = DriveCommand(fileSystem: fileSystem, logger: logger, platform: platform);
|
||||
fileSystem.file('lib/main.dart').createSync(recursive: true);
|
||||
fileSystem.file('test_driver/main_test.dart').createSync(recursive: true);
|
||||
fileSystem.file('pubspec.yaml').createSync();
|
||||
|
||||
try {
|
||||
await createTestCommandRunner(command).run(const <String>['drive', '--no-pub']);
|
||||
} on Exception {
|
||||
// Expected to throw
|
||||
}
|
||||
|
||||
expect(command.shouldRunPub, false);
|
||||
|
||||
try {
|
||||
await createTestCommandRunner(command).run(const <String>['drive']);
|
||||
} on Exception {
|
||||
// Expected to throw
|
||||
}
|
||||
|
||||
expect(command.shouldRunPub, true);
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
Pub: () => FakePub(),
|
||||
});
|
||||
}
|
||||
|
||||
class ScreenshotDevice extends Fake implements Device {
|
||||
|
Loading…
Reference in New Issue
Block a user