-
Notifications
You must be signed in to change notification settings - Fork 324
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start chromedriver once for running all integration tests (#5976)
- Loading branch information
1 parent
7733b73
commit 6658554
Showing
4 changed files
with
93 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
packages/devtools_app/integration_test/test_infra/run/_chrome_driver.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright 2023 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'dart:io'; | ||
|
||
import '_io_utils.dart'; | ||
import '_utils.dart'; | ||
|
||
class ChromeDriver with IOMixin { | ||
late final 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( | ||
'chromedriver', | ||
[ | ||
'--port=4444', | ||
], | ||
); | ||
listenToProcessOutput(_process, printTag: 'ChromeDriver'); | ||
} catch (e) { | ||
// ignore: avoid-throw-in-catch-block, by design | ||
throw Exception('Error starting chromedriver: $e'); | ||
} | ||
} | ||
|
||
Future<void> stop() async { | ||
await cancelAllStreamSubscriptions(); | ||
debugLog('killing the chromedriver process'); | ||
_process.kill(); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
packages/devtools_app/integration_test/test_infra/run/_utils.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright 2023 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
// ignore_for_file: avoid_print | ||
|
||
bool debugTestScript = false; | ||
|
||
void debugLog(String log) { | ||
if (debugTestScript) { | ||
print(log); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters