Unverified Commit f59b185b authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] do not make drive require pub if --no-pub is requested (#79379)

parent 1f30bfd4
......@@ -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 {
......
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