Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
polina-c committed Sep 1, 2023
1 parent 532b473 commit b910722
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
13 changes: 3 additions & 10 deletions packages/devtools_app/integration_test/run_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@ void main(List<String> args) async {
return;
}

Exception? exception;
final chromedriver = ChromeDriver();

// Start chrome driver before running the flutter integration test.
await chromedriver.start();

try {
// Start chrome driver before running the flutter integration test.
await chromedriver.start();

if (testRunnerArgs.testTarget != null) {
// TODO(kenz): add support for specifying a directory as the target instead
// of a single file.
Expand All @@ -52,15 +51,9 @@ void main(List<String> args) async {
await _runTest(newArgsWithTarget);
}
}
} on Exception catch (e) {
exception = e;
} finally {
await chromedriver.stop();
}

if (exception != null) {
throw exception;
}
}

Future<void> _runTest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,35 @@ import '_io_utils.dart';
import '_utils.dart';

class ChromeDriver with IOMixin {
late final Process _process;
Process? _process;

// TODO(kenz): add error messaging if the chromedriver executable is not
// found. We can also consider using web installers directly in this script:
// https://github.com/flutter/flutter/wiki/Running-Flutter-Driver-tests-with-Web#web-installers-repo.
Future<void> start() async {
try {
debugLog('starting the chromedriver process');
_process = await Process.start(
final process = _process = await Process.start(
'chromedriver',
[
'--port=4444',
],
);
listenToProcessOutput(_process, printTag: 'ChromeDriver');
listenToProcessOutput(process, printTag: 'ChromeDriver');
} catch (e) {
// ignore: avoid-throw-in-catch-block, by design
throw Exception('Error starting chromedriver: $e');
}
}

Future<void> stop() async {
final process = _process;
_process = null;

if (process == null) return;

await cancelAllStreamSubscriptions();
debugLog('killing the chromedriver process');
await killGracefully(_process);
await killGracefully(process);
}
}

0 comments on commit b910722

Please sign in to comment.