Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import 'package:vm_service/utils.dart';
import 'package:vm_service/vm_service.dart';
import 'package:vm_service/vm_service_io.dart';

import 'io_utils.dart';
import 'test_utils.dart';

class AppFixture {
Expand Down Expand Up @@ -102,7 +103,7 @@ class CliAppFixture extends AppFixture {
'(Observatory|The Dart VM service is) listening on ',
);

final process = await Process.start(Platform.resolvedExecutable, <String>[
final process = await Process.start(dartVMPath, <String>[
'--observe=0',
'--pause-isolates-on-start',
appScriptPath,
Expand Down
21 changes: 21 additions & 0 deletions packages/devtools_shared/lib/src/test/io_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,24 @@ mixin IOMixin {
return process.exitCode;
}
}

/// The path to the Dart VM executable.
///
/// If running under `flutter_tester`, this will attempt to find the Dart SDK
/// binary bundled with the Flutter SDK.
String get dartVMPath {
final resolved = Platform.resolvedExecutable;
if (resolved.contains('flutter_tester')) {
final binaryName = Platform.isWindows ? 'dart.exe' : 'dart';

final platformDir = path.dirname(resolved); // 'darwin-x64' or similar
final engineDir = path.dirname(platformDir); // 'engine'
final artifactsDir = path.dirname(engineDir); // 'artifacts'
final cacheDir = path.dirname(artifactsDir); // 'cache'
final dartPath = path.join(cacheDir, 'dart-sdk', 'bin', binaryName);
if (File(dartPath).existsSync()) {
return dartPath;
}
}
return resolved;
}
Comment thread
srawlins marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import 'dart:io';

import 'package:devtools_shared/src/test/io_utils.dart';
import 'package:path/path.dart' as p;
import 'package:test/test.dart';

Expand Down Expand Up @@ -104,7 +105,7 @@ class ExtensionTestManager {

// Run `dart pub get` on this package to generate the
// `.dart_tool/package_config.json` file.
final process = await Process.run(Platform.resolvedExecutable, [
final process = await Process.run(dartVMPath, [
'pub',
'get',
], workingDirectory: packageRoot.path);
Expand Down
5 changes: 3 additions & 2 deletions packages/devtools_shared/test/helpers/helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'dart:convert';
import 'dart:io';

import 'package:devtools_shared/devtools_shared.dart';
import 'package:devtools_shared/src/test/io_utils.dart';
import 'package:path/path.dart' as path;

typedef TestDtdConnectionInfo = ({DtdInfo? info, Process? process});
Expand All @@ -22,7 +23,7 @@ Future<TestDtdConnectionInfo> startDtd() async {
TestDtdConnectionInfo onFailure() => (info: null, process: dtdProcess);

try {
dtdProcess = await Process.start(Platform.resolvedExecutable, [
dtdProcess = await Process.start(dartVMPath, [
'tooling-daemon',
'--machine',
]);
Expand Down Expand Up @@ -72,7 +73,7 @@ class TestDartApp {

Future<String> start() async {
await _initTestApp();
process = await Process.start(Platform.resolvedExecutable, [
process = await Process.start(dartVMPath, [
'--observe=0',
'run',
'bin/main.dart',
Expand Down
Loading