Skip to content

Commit 2904779

Browse files
authored
feat(runner): add env overrides for safari and ff (#2042)
adds `SAFARI_EXECUTABLE` and `FIREFOX_EXECUTABLE` this allows you to use FF Developer Edition and Safari Technology Preview. Also there are already `MS_EDGE_EXECUTABLE` that were missing test.
1 parent 5435028 commit 2904779

File tree

5 files changed

+48
-2
lines changed

5 files changed

+48
-2
lines changed

pkgs/test/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
`TestOn`, `Timeout`.
66
* Fix the `root_` fields in the JSON reporter when running a test on Windows
77
with an absolute path.
8+
* Add support for `SAFARI_EXECUTABLE`, `FIREFOX_EXECUTABLE` and
9+
`MS_EDGE_EXECUTABLE` for custom browser installations.
810
* Allow the latest analyzer (6.x.x).
911

1012
## 1.24.3

pkgs/test/lib/src/runner/browser/default_settings.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ final defaultSettings = UnmodifiableMapView({
2525
Runtime.firefox: ExecutableSettings(
2626
linuxExecutable: 'firefox',
2727
macOSExecutable: '/Applications/Firefox.app/Contents/MacOS/firefox-bin',
28-
windowsExecutable: r'Mozilla Firefox\firefox.exe'),
28+
windowsExecutable: r'Mozilla Firefox\firefox.exe',
29+
environmentOverride: 'FIREFOX_EXECUTABLE'),
2930
Runtime.internetExplorer:
3031
ExecutableSettings(windowsExecutable: r'Internet Explorer\iexplore.exe'),
3132
Runtime.safari: ExecutableSettings(
32-
macOSExecutable: '/Applications/Safari.app/Contents/MacOS/Safari'),
33+
macOSExecutable: '/Applications/Safari.app/Contents/MacOS/Safari',
34+
environmentOverride: 'SAFARI_EXECUTABLE'),
3335
});

pkgs/test/test/runner/browser/firefox_test.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,20 @@ void main() {
8181
await test.shouldExit(1);
8282
});
8383

84+
test('can override firefox location with FIREFOX_EXECUTABLE var', () async {
85+
await d.file('test.dart', '''
86+
import 'package:test/test.dart';
87+
88+
void main() {
89+
test("success", () {});
90+
}
91+
''').create();
92+
var test = await runTest(['-p', 'firefox', 'test.dart'],
93+
environment: {'FIREFOX_EXECUTABLE': '/some/bad/path'});
94+
expect(test.stdout, emitsThrough(contains('Failed to run Firefox:')));
95+
await test.shouldExit(1);
96+
});
97+
8498
test('not impacted by CHROME_EXECUTABLE var', () async {
8599
await d.file('test.dart', '''
86100
import 'dart:html';

pkgs/test/test/runner/browser/microsoft_edge_test.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,18 @@ void main() {
7474
expect(test.stdout, emitsThrough(contains('-1: Some tests failed.')));
7575
await test.shouldExit(1);
7676
});
77+
78+
test('can override edge location with MS_EDGE_EXECUTABLE var', () async {
79+
await d.file('test.dart', '''
80+
import 'package:test/test.dart';
81+
82+
void main() {
83+
test("success", () {});
84+
}
85+
''').create();
86+
var test = await runTest(['-p', 'edge', 'test.dart'],
87+
environment: {'MS_EDGE_EXECUTABLE': '/some/bad/path'});
88+
expect(test.stdout, emitsThrough(contains('Failed to run Edge:')));
89+
await test.shouldExit(1);
90+
});
7791
}

pkgs/test/test/runner/browser/safari_test.dart

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

0 commit comments

Comments
 (0)