Unverified Commit fc1e7642 authored by Emmanuel Garcia's avatar Emmanuel Garcia Committed by GitHub

Expose enable-experiment in Flutter drive (#66311)

parent 1a9ea39a
......@@ -93,7 +93,7 @@ Future<void> main(List<String> args) async {
DevicesCommand(),
DoctorCommand(verbose: verbose),
DowngradeCommand(),
DriveCommand(),
DriveCommand(verboseHelp: verboseHelp),
EmulatorsCommand(),
FormatCommand(),
GenerateCommand(),
......
......@@ -50,9 +50,11 @@ import 'run.dart';
/// successful the exit code will be `0`. Otherwise, you will see a non-zero
/// exit code.
class DriveCommand extends RunCommandBase {
DriveCommand() {
DriveCommand({
bool verboseHelp = false,
}) {
requiresPubspecYaml();
addEnableExperimentation(hide: !verboseHelp);
argParser
..addFlag('keep-app-running',
defaultsTo: null,
......@@ -322,7 +324,18 @@ $ex
}
try {
await testRunner(<String>[testFile], environment);
await testRunner(
<String>[
if (buildInfo.dartExperiments.isNotEmpty)
'--enable-experiment=${buildInfo.dartExperiments.join(',')}',
if (buildInfo.nullSafetyMode == NullSafetyMode.sound)
'--sound-null-safety',
if (buildInfo.nullSafetyMode == NullSafetyMode.unsound)
'--no-sound-null-safety',
testFile,
],
environment,
);
} on Exception catch (error, stackTrace) {
if (error is ToolExit) {
rethrow;
......
......@@ -205,7 +205,7 @@ void main() {
return LaunchResult.succeeded();
});
testRunner = expectAsync2((List<String> testArgs, Map<String, String> environment) async {
expect(testArgs, <String>[testFile]);
expect(testArgs, <String>['--no-sound-null-safety', testFile]);
// VM_SERVICE_URL is not set by drive command arguments
expect(environment, <String, String>{
'VM_SERVICE_URL': 'null',
......@@ -273,6 +273,90 @@ void main() {
ProcessManager: () => FakeProcessManager.any(),
});
testUsingContext('enable experiment', () async {
final MockAndroidDevice mockDevice = MockAndroidDevice();
applyDdsMocks(mockDevice);
testDeviceManager.addDevice(mockDevice);
final String testApp = globals.fs.path.join(tempDir.path, 'test', 'e2e.dart');
final String testFile = globals.fs.path.join(tempDir.path, 'test_driver', 'e2e_test.dart');
appStarter = expectAsync2((DriveCommand command, Uri webUri) async {
return LaunchResult.succeeded();
});
testRunner = expectAsync2((List<String> testArgs, Map<String, String> environment) async {
expect(
testArgs,
<String>[
'--enable-experiment=experiment1,experiment2',
'--no-sound-null-safety',
testFile,
]
);
});
appStopper = expectAsync1((DriveCommand command) async {
return true;
});
final MemoryFileSystem memFs = fs;
await memFs.file(testApp).writeAsString('main() {}');
await memFs.file(testFile).writeAsString('main() {}');
final List<String> args = <String>[
'drive',
'--target=$testApp',
'--no-pub',
'--enable-experiment=experiment1',
'--enable-experiment=experiment2',
];
await createTestCommandRunner(command).run(args);
expect(testLogger.errorText, isEmpty);
}, overrides: <Type, Generator>{
FileSystem: () => fs,
ProcessManager: () => FakeProcessManager.any(),
});
testUsingContext('sound null safety', () async {
final MockAndroidDevice mockDevice = MockAndroidDevice();
applyDdsMocks(mockDevice);
testDeviceManager.addDevice(mockDevice);
final String testApp = globals.fs.path.join(tempDir.path, 'test', 'e2e.dart');
final String testFile = globals.fs.path.join(tempDir.path, 'test_driver', 'e2e_test.dart');
appStarter = expectAsync2((DriveCommand command, Uri webUri) async {
return LaunchResult.succeeded();
});
testRunner = expectAsync2((List<String> testArgs, Map<String, String> environment) async {
expect(
testArgs,
<String>[
'--sound-null-safety',
testFile,
]
);
});
appStopper = expectAsync1((DriveCommand command) async {
return true;
});
final MemoryFileSystem memFs = fs;
await memFs.file(testApp).writeAsString('main() {}');
await memFs.file(testFile).writeAsString('main() {}');
final List<String> args = <String>[
'drive',
'--target=$testApp',
'--no-pub',
'--sound-null-safety',
];
await createTestCommandRunner(command).run(args);
expect(testLogger.errorText, isEmpty);
}, overrides: <Type, Generator>{
FileSystem: () => fs,
ProcessManager: () => FakeProcessManager.any(),
});
group('findTargetDevice', () {
testUsingContext('uses specified device', () async {
testDeviceManager.specifiedDeviceId = '123';
......
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