Skip to content

Commit 5318343

Browse files
authored
Add support for CHROME_EXECUTABLE environment variable (#1883)
Closes #1862
1 parent c5d017c commit 5318343

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

pkgs/test/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
## 1.22.3-dev
1+
## 1.23.0-dev
22

33
* Avoid empty expandable groups for tests without extra output in Github
44
reporter.
5+
* Add support for CHROME_EXECUTABLE environment variable. This overrides any
6+
config file settings.
57

68
## 1.22.2
79

pkgs/test/lib/src/runner/executable_settings.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ class ExecutableSettings {
3636

3737
/// The path to the executable for the current operating system.
3838
String get executable {
39+
final envVariable = Platform.environment['CHROME_EXECUTABLE'];
40+
if (envVariable != null) return envVariable;
41+
3942
if (Platform.isMacOS) return _macOSExecutable!;
4043
if (!Platform.isWindows) return _linuxExecutable!;
4144
final windowsExecutable = _windowsExecutable!;

pkgs/test/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: test
2-
version: 1.22.3-dev
2+
version: 1.23.0-dev
33
description: >-
44
A full featured library for writing and running Dart tests across platforms.
55
repository: https://github.com/dart-lang/test/tree/master/pkgs/test

pkgs/test/test/runner/browser/chrome_test.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,18 @@ void main() {
8282
expect(test.stdout, emitsThrough(contains('-1: Some tests failed.')));
8383
await test.shouldExit(1);
8484
});
85+
86+
test('can override chrome location with CHROME_EXECUTABLE var', () async {
87+
await d.file('test.dart', '''
88+
import 'package:test/test.dart';
89+
90+
void main() {
91+
test("success", () {});
92+
}
93+
''').create();
94+
var test = await runTest(['-p', 'chrome', 'test.dart'],
95+
environment: {'CHROME_EXECUTABLE': '/some/bad/path'});
96+
expect(test.stdout, emitsThrough(contains('Failed to run Chrome:')));
97+
await test.shouldExit(1);
98+
});
8599
}

0 commit comments

Comments
 (0)