Unverified Commit efd48792 authored by Jia Hao's avatar Jia Hao Committed by GitHub

[flutter_tools] Merge some test options into DebuggingOptions (#75213)

parent b046ea62
...@@ -17,6 +17,7 @@ import 'package:flutter_tools/src/build_info.dart'; ...@@ -17,6 +17,7 @@ import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/context_runner.dart'; import 'package:flutter_tools/src/context_runner.dart';
import 'package:flutter_tools/src/artifacts.dart'; import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/reporting/reporting.dart'; import 'package:flutter_tools/src/reporting/reporting.dart';
...@@ -142,15 +143,17 @@ Future<void> run(List<String> args) async { ...@@ -142,15 +143,17 @@ Future<void> run(List<String> args) async {
exitCode = await const FlutterTestRunner().runTests( exitCode = await const FlutterTestRunner().runTests(
const TestWrapper(), const TestWrapper(),
tests.keys.toList(), tests.keys.toList(),
watcher: collector, debuggingOptions: DebuggingOptions.enabled(
ipv6: false, BuildInfo(
enableObservatory: collector != null,
buildInfo: BuildInfo(
BuildMode.debug, BuildMode.debug,
'', '',
treeShakeIcons: false, treeShakeIcons: false,
packagesPath: globals.fs.path.normalize(globals.fs.path.absolute(argResults[_kOptionPackages] as String), packagesPath: globals.fs.path.normalize(globals.fs.path.absolute(argResults[_kOptionPackages] as String)),
)), ),
),
watcher: collector,
ipv6: false,
enableObservatory: collector != null,
precompiledDillFiles: tests, precompiledDillFiles: tests,
concurrency: math.max(1, globals.platform.numberOfProcessors - 2), concurrency: math.max(1, globals.platform.numberOfProcessors - 2),
icudtlPath: globals.fs.path.absolute(argResults[_kOptionIcudtl] as String), icudtlPath: globals.fs.path.absolute(argResults[_kOptionIcudtl] as String),
......
...@@ -13,6 +13,7 @@ import '../build_info.dart'; ...@@ -13,6 +13,7 @@ import '../build_info.dart';
import '../bundle.dart'; import '../bundle.dart';
import '../cache.dart'; import '../cache.dart';
import '../devfs.dart'; import '../devfs.dart';
import '../device.dart';
import '../globals.dart' as globals; import '../globals.dart' as globals;
import '../project.dart'; import '../project.dart';
import '../runner/flutter_command.dart'; import '../runner/flutter_command.dart';
...@@ -265,30 +266,32 @@ class TestCommand extends FlutterCommand { ...@@ -265,30 +266,32 @@ class TestCommand extends FlutterCommand {
watcher = collector; watcher = collector;
} }
final bool disableServiceAuthCodes = boolArg('disable-service-auth-codes'); final DebuggingOptions debuggingOptions = DebuggingOptions.enabled(
buildInfo,
startPaused: startPaused,
disableServiceAuthCodes: boolArg('disable-service-auth-codes'),
disableDds: disableDds,
nullAssertions: boolArg(FlutterOptions.kNullAssertions),
);
final int result = await testRunner.runTests( final int result = await testRunner.runTests(
testWrapper, testWrapper,
files, files,
debuggingOptions: debuggingOptions,
names: names, names: names,
plainNames: plainNames, plainNames: plainNames,
tags: tags, tags: tags,
excludeTags: excludeTags, excludeTags: excludeTags,
watcher: watcher, watcher: watcher,
enableObservatory: collector != null || startPaused || boolArg('enable-vmservice'), enableObservatory: collector != null || startPaused || boolArg('enable-vmservice'),
startPaused: startPaused,
disableServiceAuthCodes: disableServiceAuthCodes,
disableDds: disableDds,
ipv6: boolArg('ipv6'), ipv6: boolArg('ipv6'),
machine: machine, machine: machine,
buildInfo: buildInfo,
updateGoldens: boolArg('update-goldens'), updateGoldens: boolArg('update-goldens'),
concurrency: jobs, concurrency: jobs,
buildTestAssets: buildTestAssets, buildTestAssets: buildTestAssets,
flutterProject: flutterProject, flutterProject: flutterProject,
web: stringArg('platform') == 'chrome', web: stringArg('platform') == 'chrome',
randomSeed: stringArg('test-randomize-ordering-seed'), randomSeed: stringArg('test-randomize-ordering-seed'),
nullAssertions: boolArg(FlutterOptions.kNullAssertions),
reporter: stringArg('reporter'), reporter: stringArg('reporter'),
timeout: stringArg('timeout'), timeout: stringArg('timeout'),
); );
......
...@@ -17,10 +17,10 @@ import 'package:vm_service/vm_service.dart' as vm_service; ...@@ -17,10 +17,10 @@ import 'package:vm_service/vm_service.dart' as vm_service;
import '../base/common.dart'; import '../base/common.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/io.dart'; import '../base/io.dart';
import '../build_info.dart';
import '../compile.dart'; import '../compile.dart';
import '../convert.dart'; import '../convert.dart';
import '../dart/language_version.dart'; import '../dart/language_version.dart';
import '../device.dart';
import '../globals.dart' as globals; import '../globals.dart' as globals;
import '../project.dart'; import '../project.dart';
import '../test/test_wrapper.dart'; import '../test/test_wrapper.dart';
...@@ -46,29 +46,23 @@ typedef PlatformPluginRegistration = void Function(FlutterPlatform platform); ...@@ -46,29 +46,23 @@ typedef PlatformPluginRegistration = void Function(FlutterPlatform platform);
FlutterPlatform installHook({ FlutterPlatform installHook({
TestWrapper testWrapper = const TestWrapper(), TestWrapper testWrapper = const TestWrapper(),
@required String shellPath, @required String shellPath,
@required DebuggingOptions debuggingOptions,
TestWatcher watcher, TestWatcher watcher,
bool enableObservatory = false, bool enableObservatory = false,
bool machine = false, bool machine = false,
bool startPaused = false,
bool disableServiceAuthCodes = false,
bool disableDds = false,
int port = 0, int port = 0,
String precompiledDillPath, String precompiledDillPath,
Map<String, String> precompiledDillFiles, Map<String, String> precompiledDillFiles,
bool updateGoldens = false, bool updateGoldens = false,
bool buildTestAssets = false, bool buildTestAssets = false,
int observatoryPort,
InternetAddressType serverType = InternetAddressType.IPv4, InternetAddressType serverType = InternetAddressType.IPv4,
Uri projectRootDirectory, Uri projectRootDirectory,
FlutterProject flutterProject, FlutterProject flutterProject,
String icudtlPath, String icudtlPath,
PlatformPluginRegistration platformPluginRegistration, PlatformPluginRegistration platformPluginRegistration,
bool nullAssertions = false,
@required BuildInfo buildInfo,
List<String> additionalArguments,
}) { }) {
assert(testWrapper != null); assert(testWrapper != null);
assert(enableObservatory || (!startPaused && observatoryPort == null)); assert(enableObservatory || (!debuggingOptions.startPaused && debuggingOptions.hostVmServicePort == null));
// registerPlatformPlugin can be injected for testing since it's not very mock-friendly. // registerPlatformPlugin can be injected for testing since it's not very mock-friendly.
platformPluginRegistration ??= (FlutterPlatform platform) { platformPluginRegistration ??= (FlutterPlatform platform) {
...@@ -81,13 +75,10 @@ FlutterPlatform installHook({ ...@@ -81,13 +75,10 @@ FlutterPlatform installHook({
}; };
final FlutterPlatform platform = FlutterPlatform( final FlutterPlatform platform = FlutterPlatform(
shellPath: shellPath, shellPath: shellPath,
debuggingOptions: debuggingOptions,
watcher: watcher, watcher: watcher,
machine: machine, machine: machine,
enableObservatory: enableObservatory, enableObservatory: enableObservatory,
startPaused: startPaused,
disableServiceAuthCodes: disableServiceAuthCodes,
disableDds: disableDds,
explicitObservatoryPort: observatoryPort,
host: _kHosts[serverType], host: _kHosts[serverType],
port: port, port: port,
precompiledDillPath: precompiledDillPath, precompiledDillPath: precompiledDillPath,
...@@ -97,9 +88,6 @@ FlutterPlatform installHook({ ...@@ -97,9 +88,6 @@ FlutterPlatform installHook({
projectRootDirectory: projectRootDirectory, projectRootDirectory: projectRootDirectory,
flutterProject: flutterProject, flutterProject: flutterProject,
icudtlPath: icudtlPath, icudtlPath: icudtlPath,
nullAssertions: nullAssertions,
buildInfo: buildInfo,
additionalArguments: additionalArguments,
); );
platformPluginRegistration(platform); platformPluginRegistration(platform);
return platform; return platform;
...@@ -233,13 +221,10 @@ typedef Finalizer = Future<void> Function(); ...@@ -233,13 +221,10 @@ typedef Finalizer = Future<void> Function();
class FlutterPlatform extends PlatformPlugin { class FlutterPlatform extends PlatformPlugin {
FlutterPlatform({ FlutterPlatform({
@required this.shellPath, @required this.shellPath,
@required this.debuggingOptions,
this.watcher, this.watcher,
this.enableObservatory, this.enableObservatory,
this.machine, this.machine,
this.startPaused,
this.disableServiceAuthCodes,
this.disableDds,
this.explicitObservatoryPort,
this.host, this.host,
this.port, this.port,
this.precompiledDillPath, this.precompiledDillPath,
...@@ -249,19 +234,13 @@ class FlutterPlatform extends PlatformPlugin { ...@@ -249,19 +234,13 @@ class FlutterPlatform extends PlatformPlugin {
this.projectRootDirectory, this.projectRootDirectory,
this.flutterProject, this.flutterProject,
this.icudtlPath, this.icudtlPath,
this.nullAssertions = false,
this.additionalArguments,
@required this.buildInfo,
}) : assert(shellPath != null); }) : assert(shellPath != null);
final String shellPath; final String shellPath;
final DebuggingOptions debuggingOptions;
final TestWatcher watcher; final TestWatcher watcher;
final bool enableObservatory; final bool enableObservatory;
final bool machine; final bool machine;
final bool startPaused;
final bool disableServiceAuthCodes;
final bool disableDds;
final int explicitObservatoryPort;
final InternetAddress host; final InternetAddress host;
final int port; final int port;
final String precompiledDillPath; final String precompiledDillPath;
...@@ -271,9 +250,6 @@ class FlutterPlatform extends PlatformPlugin { ...@@ -271,9 +250,6 @@ class FlutterPlatform extends PlatformPlugin {
final Uri projectRootDirectory; final Uri projectRootDirectory;
final FlutterProject flutterProject; final FlutterProject flutterProject;
final String icudtlPath; final String icudtlPath;
final bool nullAssertions;
final BuildInfo buildInfo;
final List<String> additionalArguments;
Directory fontsDirectory; Directory fontsDirectory;
...@@ -313,7 +289,7 @@ class FlutterPlatform extends PlatformPlugin { ...@@ -313,7 +289,7 @@ class FlutterPlatform extends PlatformPlugin {
StreamChannel<dynamic> loadChannel(String path, SuitePlatform platform) { StreamChannel<dynamic> loadChannel(String path, SuitePlatform platform) {
if (_testCount > 0) { if (_testCount > 0) {
// Fail if there will be a port conflict. // Fail if there will be a port conflict.
if (explicitObservatoryPort != null) { if (debuggingOptions.hostVmServicePort != null) {
throwToolExit('installHook() was called with an observatory port or debugger mode enabled, but then more than one test suite was run.'); throwToolExit('installHook() was called with an observatory port or debugger mode enabled, but then more than one test suite was run.');
} }
// Fail if we're passing in a precompiled entry-point. // Fail if we're passing in a precompiled entry-point.
...@@ -370,14 +346,11 @@ class FlutterPlatform extends PlatformPlugin { ...@@ -370,14 +346,11 @@ class FlutterPlatform extends PlatformPlugin {
@visibleForTesting @visibleForTesting
Future<HttpServer> bind(InternetAddress host, int port) => HttpServer.bind(host, port); Future<HttpServer> bind(InternetAddress host, int port) => HttpServer.bind(host, port);
PackageConfig _packageConfig;
Future<_AsyncError> _startTest( Future<_AsyncError> _startTest(
String testPath, String testPath,
StreamChannel<dynamic> controller, StreamChannel<dynamic> controller,
int ourTestCount, int ourTestCount,
) async { ) async {
_packageConfig ??= buildInfo.packageConfig;
globals.printTrace('test $ourTestCount: starting test $testPath'); globals.printTrace('test $ourTestCount: starting test $testPath');
_AsyncError outOfBandError; // error that we couldn't send to the harness that we need to send via our future _AsyncError outOfBandError; // error that we couldn't send to the harness that we need to send via our future
...@@ -432,7 +405,7 @@ class FlutterPlatform extends PlatformPlugin { ...@@ -432,7 +405,7 @@ class FlutterPlatform extends PlatformPlugin {
if (precompiledDillPath == null && precompiledDillFiles == null) { if (precompiledDillPath == null && precompiledDillFiles == null) {
// Lazily instantiate compiler so it is built only if it is actually used. // Lazily instantiate compiler so it is built only if it is actually used.
compiler ??= TestCompiler(buildInfo, flutterProject); compiler ??= TestCompiler(debuggingOptions.buildInfo, flutterProject);
mainDart = await compiler.compile(globals.fs.file(mainDart).uri); mainDart = await compiler.compile(globals.fs.file(mainDart).uri);
if (mainDart == null) { if (mainDart == null) {
...@@ -444,13 +417,8 @@ class FlutterPlatform extends PlatformPlugin { ...@@ -444,13 +417,8 @@ class FlutterPlatform extends PlatformPlugin {
final Process process = await _startProcess( final Process process = await _startProcess(
shellPath, shellPath,
mainDart, mainDart,
packages: buildInfo.packagesPath,
enableObservatory: enableObservatory, enableObservatory: enableObservatory,
startPaused: startPaused,
disableServiceAuthCodes: disableServiceAuthCodes,
observatoryPort: disableDds ? explicitObservatoryPort : 0,
serverPort: server.port, serverPort: server.port,
additionalArguments: additionalArguments,
); );
subprocessActive = true; subprocessActive = true;
finalizers.add(() async { finalizers.add(() async {
...@@ -484,15 +452,15 @@ class FlutterPlatform extends PlatformPlugin { ...@@ -484,15 +452,15 @@ class FlutterPlatform extends PlatformPlugin {
process, process,
reportObservatoryUri: (Uri detectedUri) async { reportObservatoryUri: (Uri detectedUri) async {
assert(!gotProcessObservatoryUri.isCompleted); assert(!gotProcessObservatoryUri.isCompleted);
assert(explicitObservatoryPort == null || assert(debuggingOptions.hostVmServicePort == null ||
explicitObservatoryPort == detectedUri.port); debuggingOptions.hostVmServicePort == detectedUri.port);
Uri forwardingUri; Uri forwardingUri;
if (!disableDds) { if (!debuggingOptions.disableDds) {
final DartDevelopmentService dds = await DartDevelopmentService.startDartDevelopmentService( final DartDevelopmentService dds = await DartDevelopmentService.startDartDevelopmentService(
detectedUri, detectedUri,
serviceUri: ddsServiceUri, serviceUri: ddsServiceUri,
enableAuthCodes: !disableServiceAuthCodes, enableAuthCodes: !debuggingOptions.disableServiceAuthCodes,
ipv6: host.type == InternetAddressType.IPv6, ipv6: host.type == InternetAddressType.IPv6,
); );
forwardingUri = dds.uri; forwardingUri = dds.uri;
...@@ -508,7 +476,7 @@ class FlutterPlatform extends PlatformPlugin { ...@@ -508,7 +476,7 @@ class FlutterPlatform extends PlatformPlugin {
globals.printTrace('Successfully connected to service protocol: $forwardingUri'); globals.printTrace('Successfully connected to service protocol: $forwardingUri');
})); }));
} }
if (startPaused && !machine) { if (debuggingOptions.startPaused && !machine) {
globals.printStatus('The test process has been started.'); globals.printStatus('The test process has been started.');
globals.printStatus('You can now connect to it using observatory. To connect, load the following Web site in your browser:'); globals.printStatus('You can now connect to it using observatory. To connect, load the following Web site in your browser:');
globals.printStatus(' $forwardingUri'); globals.printStatus(' $forwardingUri');
...@@ -637,16 +605,18 @@ class FlutterPlatform extends PlatformPlugin { ...@@ -637,16 +605,18 @@ class FlutterPlatform extends PlatformPlugin {
}) { }) {
assert(testUrl.scheme == 'file'); assert(testUrl.scheme == 'file');
final File file = globals.fs.file(testUrl); final File file = globals.fs.file(testUrl);
final PackageConfig packageConfig = debuggingOptions.buildInfo.packageConfig;
final LanguageVersion languageVersion = determineLanguageVersion( final LanguageVersion languageVersion = determineLanguageVersion(
file, file,
_packageConfig[flutterProject?.manifest?.appName], packageConfig[flutterProject?.manifest?.appName],
); );
return generateTestBootstrap( return generateTestBootstrap(
testUrl: testUrl, testUrl: testUrl,
testConfigFile: findTestConfigFile(globals.fs.file(testUrl)), testConfigFile: findTestConfigFile(globals.fs.file(testUrl)),
host: host, host: host,
updateGoldens: updateGoldens, updateGoldens: updateGoldens,
flutterTestDep: _packageConfig['flutter_test'] != null, flutterTestDep: packageConfig['flutter_test'] != null,
languageVersionHeader: '// @dart=${languageVersion.major}.${languageVersion.minor}' languageVersionHeader: '// @dart=${languageVersion.major}.${languageVersion.minor}'
); );
} }
...@@ -693,16 +663,14 @@ class FlutterPlatform extends PlatformPlugin { ...@@ -693,16 +663,14 @@ class FlutterPlatform extends PlatformPlugin {
Future<Process> _startProcess( Future<Process> _startProcess(
String executable, String executable,
String testPath, { String testPath, {
String packages,
bool enableObservatory = false, bool enableObservatory = false,
bool startPaused = false,
bool disableServiceAuthCodes = false,
int observatoryPort,
int serverPort, int serverPort,
List<String> additionalArguments,
}) { }) {
assert(executable != null); // Please provide the path to the shell in the SKY_SHELL environment variable. assert(executable != null); // Please provide the path to the shell in the SKY_SHELL environment variable.
assert(!startPaused || enableObservatory); assert(!debuggingOptions.startPaused || enableObservatory);
final int observatoryPort = debuggingOptions.disableDds ? debuggingOptions.hostVmServicePort : 0;
final List<String> command = <String>[ final List<String> command = <String>[
executable, executable,
if (enableObservatory) ...<String>[ if (enableObservatory) ...<String>[
...@@ -716,8 +684,8 @@ class FlutterPlatform extends PlatformPlugin { ...@@ -716,8 +684,8 @@ class FlutterPlatform extends PlatformPlugin {
// I mention this only so that you won't be tempted, as I was, to apply // I mention this only so that you won't be tempted, as I was, to apply
// the obvious simplification to this code and remove this entire feature. // the obvious simplification to this code and remove this entire feature.
if (observatoryPort != null) '--observatory-port=$observatoryPort', if (observatoryPort != null) '--observatory-port=$observatoryPort',
if (startPaused) '--start-paused', if (debuggingOptions.startPaused) '--start-paused',
if (disableServiceAuthCodes) '--disable-service-auth-codes', if (debuggingOptions.disableServiceAuthCodes) '--disable-service-auth-codes',
] ]
else else
'--disable-observatory', '--disable-observatory',
...@@ -730,10 +698,10 @@ class FlutterPlatform extends PlatformPlugin { ...@@ -730,10 +698,10 @@ class FlutterPlatform extends PlatformPlugin {
'--enable-dart-profiling', '--enable-dart-profiling',
'--non-interactive', '--non-interactive',
'--use-test-fonts', '--use-test-fonts',
'--packages=$packages', '--packages=${debuggingOptions.buildInfo.packagesPath}',
if (nullAssertions) if (debuggingOptions.nullAssertions)
'--dart-flags=--null_assertions', '--dart-flags=--null_assertions',
...?additionalArguments, ...debuggingOptions.dartEntrypointArgs,
testPath, testPath,
]; ];
...@@ -829,7 +797,7 @@ class FlutterPlatform extends PlatformPlugin { ...@@ -829,7 +797,7 @@ class FlutterPlatform extends PlatformPlugin {
InternetAddress.loopbackIPv6 : InternetAddress.loopbackIPv6 :
InternetAddress.loopbackIPv4 InternetAddress.loopbackIPv4
).host, ).host,
port: explicitObservatoryPort ?? 0, port: debuggingOptions.hostVmServicePort ?? 0,
); );
} }
} }
......
...@@ -10,7 +10,7 @@ import '../artifacts.dart'; ...@@ -10,7 +10,7 @@ import '../artifacts.dart';
import '../base/common.dart'; import '../base/common.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/io.dart'; import '../base/io.dart';
import '../build_info.dart'; import '../device.dart';
import '../globals.dart' as globals; import '../globals.dart' as globals;
import '../project.dart'; import '../project.dart';
import '../web/chrome.dart'; import '../web/chrome.dart';
...@@ -29,14 +29,12 @@ abstract class FlutterTestRunner { ...@@ -29,14 +29,12 @@ abstract class FlutterTestRunner {
Future<int> runTests( Future<int> runTests(
TestWrapper testWrapper, TestWrapper testWrapper,
List<String> testFiles, { List<String> testFiles, {
@required DebuggingOptions debuggingOptions,
List<String> names = const <String>[], List<String> names = const <String>[],
List<String> plainNames = const <String>[], List<String> plainNames = const <String>[],
String tags, String tags,
String excludeTags, String excludeTags,
bool enableObservatory = false, bool enableObservatory = false,
bool startPaused = false,
bool disableServiceAuthCodes = false,
bool disableDds = false,
bool ipv6 = false, bool ipv6 = false,
bool machine = false, bool machine = false,
String precompiledDillPath, String precompiledDillPath,
...@@ -50,11 +48,8 @@ abstract class FlutterTestRunner { ...@@ -50,11 +48,8 @@ abstract class FlutterTestRunner {
Directory coverageDirectory, Directory coverageDirectory,
bool web = false, bool web = false,
String randomSeed, String randomSeed,
bool nullAssertions = false,
@required BuildInfo buildInfo,
String reporter, String reporter,
String timeout, String timeout,
List<String> additionalArguments,
}); });
} }
...@@ -65,14 +60,12 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner { ...@@ -65,14 +60,12 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner {
Future<int> runTests( Future<int> runTests(
TestWrapper testWrapper, TestWrapper testWrapper,
List<String> testFiles, { List<String> testFiles, {
@required DebuggingOptions debuggingOptions,
List<String> names = const <String>[], List<String> names = const <String>[],
List<String> plainNames = const <String>[], List<String> plainNames = const <String>[],
String tags, String tags,
String excludeTags, String excludeTags,
bool enableObservatory = false, bool enableObservatory = false,
bool startPaused = false,
bool disableServiceAuthCodes = false,
bool disableDds = false,
bool ipv6 = false, bool ipv6 = false,
bool machine = false, bool machine = false,
String precompiledDillPath, String precompiledDillPath,
...@@ -86,11 +79,8 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner { ...@@ -86,11 +79,8 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner {
Directory coverageDirectory, Directory coverageDirectory,
bool web = false, bool web = false,
String randomSeed, String randomSeed,
bool nullAssertions = false,
@required BuildInfo buildInfo,
String reporter, String reporter,
String timeout, String timeout,
List<String> additionalArguments,
}) async { }) async {
// Configure package:test to use the Flutter engine for child processes. // Configure package:test to use the Flutter engine for child processes.
final String shellPath = globals.artifacts.getArtifactPath(Artifact.flutterTester); final String shellPath = globals.artifacts.getArtifactPath(Artifact.flutterTester);
...@@ -99,7 +89,7 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner { ...@@ -99,7 +89,7 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner {
final List<String> testArgs = <String>[ final List<String> testArgs = <String>[
if (!globals.terminal.supportsColor) if (!globals.terminal.supportsColor)
'--no-color', '--no-color',
if (startPaused) if (debuggingOptions.startPaused)
'--pause-after-load', '--pause-after-load',
if (machine) if (machine)
...<String>['-r', 'json'] ...<String>['-r', 'json']
...@@ -136,7 +126,7 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner { ...@@ -136,7 +126,7 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner {
projectDirectory: flutterProject.directory, projectDirectory: flutterProject.directory,
testOutputDir: tempBuildDir, testOutputDir: tempBuildDir,
testFiles: testFiles, testFiles: testFiles,
buildInfo: buildInfo, buildInfo: debuggingOptions.buildInfo,
); );
if (result == null) { if (result == null) {
throwToolExit('Failed to compile tests'); throwToolExit('Failed to compile tests');
...@@ -155,9 +145,9 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner { ...@@ -155,9 +145,9 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner {
updateGoldens: updateGoldens, updateGoldens: updateGoldens,
shellPath: shellPath, shellPath: shellPath,
flutterProject: flutterProject, flutterProject: flutterProject,
pauseAfterLoad: startPaused, pauseAfterLoad: debuggingOptions.startPaused,
nullAssertions: nullAssertions, nullAssertions: debuggingOptions.nullAssertions,
buildInfo: buildInfo, buildInfo: debuggingOptions.buildInfo,
webMemoryFS: result, webMemoryFS: result,
logger: globals.logger, logger: globals.logger,
fileSystem: globals.fs, fileSystem: globals.fs,
...@@ -187,12 +177,10 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner { ...@@ -187,12 +177,10 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner {
final loader.FlutterPlatform platform = loader.installHook( final loader.FlutterPlatform platform = loader.installHook(
testWrapper: testWrapper, testWrapper: testWrapper,
shellPath: shellPath, shellPath: shellPath,
debuggingOptions: debuggingOptions,
watcher: watcher, watcher: watcher,
enableObservatory: enableObservatory, enableObservatory: enableObservatory,
machine: machine, machine: machine,
startPaused: startPaused,
disableServiceAuthCodes: disableServiceAuthCodes,
disableDds: disableDds,
serverType: serverType, serverType: serverType,
precompiledDillPath: precompiledDillPath, precompiledDillPath: precompiledDillPath,
precompiledDillFiles: precompiledDillFiles, precompiledDillFiles: precompiledDillFiles,
...@@ -201,9 +189,6 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner { ...@@ -201,9 +189,6 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner {
projectRootDirectory: globals.fs.currentDirectory.uri, projectRootDirectory: globals.fs.currentDirectory.uri,
flutterProject: flutterProject, flutterProject: flutterProject,
icudtlPath: icudtlPath, icudtlPath: icudtlPath,
nullAssertions: nullAssertions,
buildInfo: buildInfo,
additionalArguments: additionalArguments,
); );
try { try {
......
...@@ -13,10 +13,12 @@ import 'package:flutter_tools/src/base/file_system.dart'; ...@@ -13,10 +13,12 @@ import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/test.dart'; import 'package:flutter_tools/src/commands/test.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/test/runner.dart'; import 'package:flutter_tools/src/test/runner.dart';
import 'package:flutter_tools/src/test/test_wrapper.dart'; import 'package:flutter_tools/src/test/test_wrapper.dart';
import 'package:flutter_tools/src/test/watcher.dart'; import 'package:flutter_tools/src/test/watcher.dart';
import 'package:meta/meta.dart';
import 'package:process/process.dart'; import 'package:process/process.dart';
import '../../src/common.dart'; import '../../src/common.dart';
...@@ -163,15 +165,13 @@ class FakeFlutterTestRunner implements FlutterTestRunner { ...@@ -163,15 +165,13 @@ class FakeFlutterTestRunner implements FlutterTestRunner {
Future<int> runTests( Future<int> runTests(
TestWrapper testWrapper, TestWrapper testWrapper,
List<String> testFiles, { List<String> testFiles, {
@required DebuggingOptions debuggingOptions,
Directory workDir, Directory workDir,
List<String> names = const <String>[], List<String> names = const <String>[],
List<String> plainNames = const <String>[], List<String> plainNames = const <String>[],
String tags, String tags,
String excludeTags, String excludeTags,
bool enableObservatory = false, bool enableObservatory = false,
bool startPaused = false,
bool disableDds = false,
bool disableServiceAuthCodes = false,
bool ipv6 = false, bool ipv6 = false,
bool machine = false, bool machine = false,
String precompiledDillPath, String precompiledDillPath,
...@@ -188,16 +188,12 @@ class FakeFlutterTestRunner implements FlutterTestRunner { ...@@ -188,16 +188,12 @@ class FakeFlutterTestRunner implements FlutterTestRunner {
bool web = false, bool web = false,
String randomSeed, String randomSeed,
@override List<String> extraFrontEndOptions, @override List<String> extraFrontEndOptions,
bool nullAssertions = false,
BuildInfo buildInfo,
String reporter, String reporter,
String timeout, String timeout,
List<String> additionalArguments,
}) async { }) async {
lastEnableObservatoryValue = enableObservatory; lastEnableObservatoryValue = enableObservatory;
return exitCode; return exitCode;
} }
} }
class FakePackageTest implements TestWrapper { class FakePackageTest implements TestWrapper {
......
...@@ -11,6 +11,7 @@ import 'package:flutter_tools/src/base/file_system.dart'; ...@@ -11,6 +11,7 @@ import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/test/flutter_platform.dart'; import 'package:flutter_tools/src/test/flutter_platform.dart';
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
import 'package:mockito/mockito.dart'; import 'package:mockito/mockito.dart';
...@@ -35,9 +36,11 @@ void main() { ...@@ -35,9 +36,11 @@ void main() {
testUsingContext('ensureConfiguration throws an error if an ' testUsingContext('ensureConfiguration throws an error if an '
'explicitObservatoryPort is specified and more than one test file', () async { 'explicitObservatoryPort is specified and more than one test file', () async {
final FlutterPlatform flutterPlatform = FlutterPlatform( final FlutterPlatform flutterPlatform = FlutterPlatform(
buildInfo: BuildInfo.debug,
shellPath: '/', shellPath: '/',
explicitObservatoryPort: 1234, debuggingOptions: DebuggingOptions.enabled(
BuildInfo.debug,
hostVmServicePort: 1234,
),
); );
flutterPlatform.loadChannel('test1.dart', MockSuitePlatform()); flutterPlatform.loadChannel('test1.dart', MockSuitePlatform());
...@@ -50,7 +53,7 @@ void main() { ...@@ -50,7 +53,7 @@ void main() {
testUsingContext('ensureConfiguration throws an error if a precompiled ' testUsingContext('ensureConfiguration throws an error if a precompiled '
'entrypoint is specified and more that one test file', () { 'entrypoint is specified and more that one test file', () {
final FlutterPlatform flutterPlatform = FlutterPlatform( final FlutterPlatform flutterPlatform = FlutterPlatform(
buildInfo: BuildInfo.debug, debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
shellPath: '/', shellPath: '/',
precompiledDillPath: 'example.dill', precompiledDillPath: 'example.dill',
); );
...@@ -173,35 +176,41 @@ void main() { ...@@ -173,35 +176,41 @@ void main() {
testUsingContext('installHook creates a FlutterPlatform', () { testUsingContext('installHook creates a FlutterPlatform', () {
expect(() => installHook( expect(() => installHook(
buildInfo: BuildInfo.debug,
shellPath: 'abc', shellPath: 'abc',
enableObservatory: false, debuggingOptions: DebuggingOptions.enabled(
BuildInfo.debug,
startPaused: true, startPaused: true,
),
enableObservatory: false,
), throwsAssertionError); ), throwsAssertionError);
expect(() => installHook( expect(() => installHook(
buildInfo: BuildInfo.debug,
shellPath: 'abc', shellPath: 'abc',
debuggingOptions: DebuggingOptions.enabled(
BuildInfo.debug,
startPaused: true,
hostVmServicePort: 123,
),
enableObservatory: false, enableObservatory: false,
startPaused: false,
observatoryPort: 123,
), throwsAssertionError); ), throwsAssertionError);
FlutterPlatform capturedPlatform; FlutterPlatform capturedPlatform;
final Map<String, String> expectedPrecompiledDillFiles = <String, String>{'Key': 'Value'}; final Map<String, String> expectedPrecompiledDillFiles = <String, String>{'Key': 'Value'};
final FlutterPlatform flutterPlatform = installHook( final FlutterPlatform flutterPlatform = installHook(
shellPath: 'abc', shellPath: 'abc',
enableObservatory: true, debuggingOptions: DebuggingOptions.enabled(
machine: true, BuildInfo.debug,
startPaused: true, startPaused: true,
disableServiceAuthCodes: true, disableServiceAuthCodes: true,
hostVmServicePort: 200,
),
enableObservatory: true,
machine: true,
port: 100, port: 100,
precompiledDillPath: 'def', precompiledDillPath: 'def',
precompiledDillFiles: expectedPrecompiledDillFiles, precompiledDillFiles: expectedPrecompiledDillFiles,
buildInfo: BuildInfo.debug,
updateGoldens: true, updateGoldens: true,
buildTestAssets: true, buildTestAssets: true,
observatoryPort: 200,
serverType: InternetAddressType.IPv6, serverType: InternetAddressType.IPv6,
icudtlPath: 'ghi', icudtlPath: 'ghi',
platformPluginRegistration: (FlutterPlatform platform) { platformPluginRegistration: (FlutterPlatform platform) {
...@@ -210,16 +219,16 @@ void main() { ...@@ -210,16 +219,16 @@ void main() {
expect(identical(capturedPlatform, flutterPlatform), equals(true)); expect(identical(capturedPlatform, flutterPlatform), equals(true));
expect(flutterPlatform.shellPath, equals('abc')); expect(flutterPlatform.shellPath, equals('abc'));
expect(flutterPlatform.debuggingOptions.buildInfo, equals(BuildInfo.debug));
expect(flutterPlatform.debuggingOptions.startPaused, equals(true));
expect(flutterPlatform.debuggingOptions.disableServiceAuthCodes, equals(true));
expect(flutterPlatform.debuggingOptions.hostVmServicePort, equals(200));
expect(flutterPlatform.enableObservatory, equals(true)); expect(flutterPlatform.enableObservatory, equals(true));
expect(flutterPlatform.machine, equals(true)); expect(flutterPlatform.machine, equals(true));
expect(flutterPlatform.startPaused, equals(true));
expect(flutterPlatform.disableServiceAuthCodes, equals(true));
expect(flutterPlatform.port, equals(100)); expect(flutterPlatform.port, equals(100));
expect(flutterPlatform.host, InternetAddress.loopbackIPv6); expect(flutterPlatform.host, InternetAddress.loopbackIPv6);
expect(flutterPlatform.explicitObservatoryPort, equals(200));
expect(flutterPlatform.precompiledDillPath, equals('def')); expect(flutterPlatform.precompiledDillPath, equals('def'));
expect(flutterPlatform.precompiledDillFiles, expectedPrecompiledDillFiles); expect(flutterPlatform.precompiledDillFiles, expectedPrecompiledDillFiles);
expect(flutterPlatform.buildInfo, equals(BuildInfo.debug));
expect(flutterPlatform.updateGoldens, equals(true)); expect(flutterPlatform.updateGoldens, equals(true));
expect(flutterPlatform.buildTestAssets, equals(true)); expect(flutterPlatform.buildTestAssets, equals(true));
expect(flutterPlatform.icudtlPath, equals('ghi')); expect(flutterPlatform.icudtlPath, equals('ghi'));
...@@ -278,18 +287,20 @@ class MockHttpServer extends Mock implements HttpServer {} ...@@ -278,18 +287,20 @@ class MockHttpServer extends Mock implements HttpServer {}
// //
// Uses a mock HttpServer. We don't want to bind random ports in our CI hosts. // Uses a mock HttpServer. We don't want to bind random ports in our CI hosts.
class TestFlutterPlatform extends FlutterPlatform { class TestFlutterPlatform extends FlutterPlatform {
TestFlutterPlatform([List<String> additionalArguments]) : super( TestFlutterPlatform([List<String> dartEntrypointArgs = const <String>[]]) : super(
buildInfo: const BuildInfo(BuildMode.debug, '', treeShakeIcons: false, packagesPath: '.dart_tool/package_config.json'),
shellPath: '/', shellPath: '/',
debuggingOptions: DebuggingOptions.enabled(
const BuildInfo(BuildMode.debug, '', treeShakeIcons: false, packagesPath: '.dart_tool/package_config.json'),
startPaused: false,
disableDds: true,
dartEntrypointArgs: dartEntrypointArgs,
),
precompiledDillPath: 'example.dill', precompiledDillPath: 'example.dill',
host: InternetAddress.loopbackIPv6, host: InternetAddress.loopbackIPv6,
port: 0, port: 0,
updateGoldens: false, updateGoldens: false,
startPaused: false,
enableObservatory: false, enableObservatory: false,
buildTestAssets: false, buildTestAssets: false,
disableDds: true,
additionalArguments: additionalArguments,
); );
@override @override
...@@ -302,19 +313,20 @@ class TestFlutterPlatform extends FlutterPlatform { ...@@ -302,19 +313,20 @@ class TestFlutterPlatform extends FlutterPlatform {
// Uses a mock HttpServer. We don't want to bind random ports in our CI hosts. // Uses a mock HttpServer. We don't want to bind random ports in our CI hosts.
class TestObservatoryFlutterPlatform extends FlutterPlatform { class TestObservatoryFlutterPlatform extends FlutterPlatform {
TestObservatoryFlutterPlatform() : super( TestObservatoryFlutterPlatform() : super(
buildInfo: const BuildInfo(BuildMode.debug, '', treeShakeIcons: false, packagesPath: '.dart_tool/package_config.json'),
shellPath: '/', shellPath: '/',
debuggingOptions: DebuggingOptions.enabled(
const BuildInfo(BuildMode.debug, '', treeShakeIcons: false, packagesPath: '.dart_tool/package_config.json'),
startPaused: false,
disableDds: false,
disableServiceAuthCodes: false,
hostVmServicePort: 1234,
),
precompiledDillPath: 'example.dill', precompiledDillPath: 'example.dill',
host: InternetAddress.loopbackIPv6, host: InternetAddress.loopbackIPv6,
port: 0, port: 0,
updateGoldens: false, updateGoldens: false,
startPaused: false,
enableObservatory: true, enableObservatory: true,
explicitObservatoryPort: 1234,
buildTestAssets: false, buildTestAssets: false,
disableServiceAuthCodes: false,
disableDds: false,
additionalArguments: null,
); );
final Completer<Uri> _ddsServiceUriCompleter = Completer<Uri>(); final Completer<Uri> _ddsServiceUriCompleter = Completer<Uri>();
......
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