diff --git a/lib/web_ui/dev/felt.dart b/lib/web_ui/dev/felt.dart index fd4d2f6c73645..9b860872f3387 100644 --- a/lib/web_ui/dev/felt.dart +++ b/lib/web_ui/dev/felt.dart @@ -35,6 +35,7 @@ void main(List args) async { final bool result = await runner.run(args); if (result == false) { print('Sub-command returned false: `${args.join(' ')}`'); + _cleanup(); io.exit(1); } } on UsageException catch (e) { diff --git a/lib/web_ui/dev/integration_tests_manager.dart b/lib/web_ui/dev/integration_tests_manager.dart index 6e5457da4fe0b..8a7967784c966 100644 --- a/lib/web_ui/dev/integration_tests_manager.dart +++ b/lib/web_ui/dev/integration_tests_manager.dart @@ -5,7 +5,6 @@ import 'dart:io' as io; import 'package:path/path.dart' as pathlib; import 'package:web_driver_installer/chrome_driver_installer.dart'; -import 'package:yaml/yaml.dart'; import 'chrome_installer.dart'; import 'common.dart'; @@ -21,8 +20,7 @@ class IntegrationTestsManager { /// It usually changes with each the browser version changes. /// A better solution would be installing the browser and the driver at the /// same time. - // TODO(nurhan): change the web installers to install driver and the browser - // at the same time. + // TODO(nurhan): https://github.com/flutter/flutter/issues/53179. final io.Directory _browserDriverDir; /// This is the parent directory for all drivers. @@ -32,10 +30,10 @@ class IntegrationTestsManager { final io.Directory _drivers; IntegrationTestsManager(this._browser) - : this._browserDriverDir = io.Directory( - pathlib.join(environment.webUiRootDir.path, 'drivers', _browser)), + : this._browserDriverDir = io.Directory(pathlib.join( + environment.webUiDartToolDir.path, 'drivers', _browser)), this._drivers = io.Directory( - pathlib.join(environment.webUiRootDir.path, 'drivers')); + pathlib.join(environment.webUiDartToolDir.path, 'drivers')); Future runTests() async { if (_browser != 'chrome') { @@ -77,6 +75,7 @@ class IntegrationTestsManager { startProcess( './chromedriver/chromedriver', ['--port=4444'], + workingDirectory: io.Directory.current.path ); print('INFO: Driver started'); } @@ -89,12 +88,16 @@ class IntegrationTestsManager { _browserDriverDir.createSync(recursive: true); temporaryDirectories.add(_drivers); + io.Directory temp = io.Directory.current; + io.Directory.current = _browserDriverDir; + // TODO(nurhan): https://github.com/flutter/flutter/issues/53179 final String chromeDriverVersion = await queryChromeDriverVersion(); ChromeDriverInstaller chromeDriverInstaller = ChromeDriverInstaller.withVersion(chromeDriverVersion); await chromeDriverInstaller.install(alwaysInstall: true); await _runDriver(); + io.Directory.current = temp; } /// Runs all the web tests under e2e_tests/web. diff --git a/lib/web_ui/dev/test_runner.dart b/lib/web_ui/dev/test_runner.dart index fa66b05954d3c..8ca3fa13e3530 100644 --- a/lib/web_ui/dev/test_runner.dart +++ b/lib/web_ui/dev/test_runner.dart @@ -115,13 +115,18 @@ class TestCommand extends Command { case TestTypesRequested.integration: return runIntegrationTests(); case TestTypesRequested.all: - bool integrationTestResult = await runIntegrationTests(); - bool unitTestResult = await runUnitTests(); - if (integrationTestResult != unitTestResult) { - print('Tests run. Integration tests passed: $integrationTestResult ' - 'unit tests passed: $unitTestResult'); + // TODO(nurhan): https://github.com/flutter/flutter/issues/53322 + if (runAllTests) { + bool integrationTestResult = await runIntegrationTests(); + bool unitTestResult = await runUnitTests(); + if (integrationTestResult != unitTestResult) { + print('Tests run. Integration tests passed: $integrationTestResult ' + 'unit tests passed: $unitTestResult'); + } + return integrationTestResult && unitTestResult; + } else { + return await runUnitTests(); } - return integrationTestResult && unitTestResult; } return false; } @@ -145,13 +150,11 @@ class TestCommand extends Command { await _runPubGet(); } - final List targets = - this.targets.map((t) => FilePath.fromCwd(t)).toList(); - await _buildTests(targets: targets); - if (targets.isEmpty) { + await _buildTests(targets: targetFiles); + if (runAllTests) { await _runAllTests(); } else { - await _runTargetTests(targets); + await _runTargetTests(targetFiles); } return true; } @@ -165,6 +168,16 @@ class TestCommand extends Command { /// Paths to targets to run, e.g. a single test. List get targets => argResults.rest; + /// The target test files to run. + /// + /// The value can be null if the developer prefers to run all the tests. + List get targetFiles => (targets.isEmpty) + ? null + : targets.map((t) => FilePath.fromCwd(t)).toList(); + + /// Whether all tests should run. + bool get runAllTests => targets.isEmpty; + String get browser => argResults['browser']; bool get isChrome => argResults['browser'] == 'chrome';