Skip to content

Add support for multiple full paths on macos #2276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkgs/test/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Fix dart2wasm tests on windows.
* Increase SDK constraint to ^3.5.0-311.0.dev.
* Support running Node.js tests compiled with dart2wasm.
* Allow `firefox` or `firefox-bin` executable name on macOS.

## 1.25.8

Expand Down
5 changes: 4 additions & 1 deletion pkgs/test/lib/src/runner/browser/default_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ final defaultSettings = UnmodifiableMapView({
),
Runtime.firefox: ExecutableSettings(
linuxExecutable: 'firefox',
macOSExecutable: '/Applications/Firefox.app/Contents/MacOS/firefox-bin',
macOsAbsolutePaths: {
'/Applications/Firefox.app/Contents/MacOS/firefox-bin',
'/Applications/Firefox.app/Contents/MacOS/firefox'
},
windowsExecutable: r'Mozilla Firefox\firefox.exe',
environmentOverride: 'FIREFOX_EXECUTABLE'),
Runtime.safari: ExecutableSettings(
Expand Down
25 changes: 21 additions & 4 deletions pkgs/test/lib/src/runner/executable_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,19 @@ class ExecutableSettings {
/// looked up on the system path. It may not be relative.
final String? _linuxExecutable;

/// The path to the executable on Mac OS.
/// The command to execute on Mac OS.
///
/// This may be an absolute path or a basename, in which case it will be
/// looked up on the system path. It may not be relative.
/// This may be a basename or an absolute path.
/// If this is a basename it is resolved by the OS on the system path.
/// Otherwise, the path must be absolute, not relative.
final String? _macOSExecutable;

/// Potential absolute paths to the executable on Mac OS.
///
/// When multiple paths are provided the first to exist on the filesystem is
/// chosen. Paths must be absolute.
final Set<String>? _macOSAbsolutePaths;

/// The path to the executable on Windows.
///
/// This may be an absolute path; a basename, in which case it will be looked
Expand All @@ -45,7 +52,14 @@ class ExecutableSettings {
if (envVariable != null) return envVariable;
}

if (Platform.isMacOS) return _macOSExecutable!;
if (Platform.isMacOS) {
if (_macOSAbsolutePaths case final paths?) {
for (final path in paths) {
if (File(path).existsSync()) return path;
}
}
return (_macOSExecutable ?? _macOSAbsolutePaths?.first)!;
}
if (!Platform.isWindows) return _linuxExecutable!;
final windowsExecutable = _windowsExecutable!;
if (p.isAbsolute(windowsExecutable)) return windowsExecutable;
Expand Down Expand Up @@ -177,12 +191,14 @@ class ExecutableSettings {
{Iterable<String>? arguments,
String? linuxExecutable,
String? macOSExecutable,
Set<String>? macOsAbsolutePaths,
String? windowsExecutable,
String? environmentOverride,
bool? headless})
: arguments = arguments == null ? const [] : List.unmodifiable(arguments),
_linuxExecutable = linuxExecutable,
_macOSExecutable = macOSExecutable,
_macOSAbsolutePaths = macOsAbsolutePaths,
_windowsExecutable = windowsExecutable,
_environmentOverride = environmentOverride,
_headless = headless;
Expand All @@ -193,5 +209,6 @@ class ExecutableSettings {
headless: other._headless ?? _headless,
linuxExecutable: other._linuxExecutable ?? _linuxExecutable,
macOSExecutable: other._macOSExecutable ?? _macOSExecutable,
macOsAbsolutePaths: other._macOSAbsolutePaths ?? _macOSAbsolutePaths,
windowsExecutable: other._windowsExecutable ?? _windowsExecutable);
}