keep the clide.dart barrel Flutter-free

`lib/kernel/src/toolchain.dart` is a `ChangeNotifier`, so it pulls in
`package:flutter/foundation.dart`. `GitClient` and `PqlClient` imported
it for the resolved binary paths, which leaked Flutter through the
`package:clide/clide.dart` barrel — breaking `dart test` on every core
subsystem suite (`ci/test_core.sh`), since pure Dart can't compile
Flutter packages.

Split the Flutter-free pieces into `toolchain_paths.dart`: `ResolvedPaths`,
`resolveToolchainPaths`, and a new read-only `ToolchainView` interface
with a `ToolchainView.resolved()` const factory. `Toolchain` now
implements `ToolchainView`; the clients depend on the interface. Core
test setups that built a `Toolchain` just to call `applyResolved`
switch to the factory.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-05-14 21:21:09 +02:00
co-authored by Claude
parent a3a10cddf3
commit 5cad98224f
10 changed files with 172 additions and 170 deletions
+2 -3
View File
@@ -8,7 +8,7 @@ library;
import 'dart:io';
import 'package:clide/clide.dart';
import 'package:clide/kernel/src/toolchain.dart';
import 'package:clide/kernel/src/toolchain_paths.dart';
import 'package:clide/src/daemon/git_commands.dart';
import 'package:test/test.dart';
@@ -18,8 +18,7 @@ void main() {
setUp(() async {
sandbox = await Directory.systemTemp.createTemp('clide-git-cmd-err-');
final toolchain = Toolchain();
toolchain.applyResolved(const ResolvedPaths(git: '/tmp/clide-no-such-git-binary'));
final toolchain = ToolchainView.resolved(const ResolvedPaths(git: '/tmp/clide-no-such-git-binary'));
final git = GitClient(toolchain: toolchain, workDir: sandbox);
dispatcher = DaemonDispatcher();
final sink = RecordingEventSink();
+2 -3
View File
@@ -1,7 +1,7 @@
import 'dart:io';
import 'package:clide/clide.dart';
import 'package:clide/kernel/src/toolchain.dart';
import 'package:clide/kernel/src/toolchain_paths.dart';
import 'package:clide/src/daemon/git_commands.dart';
import 'package:test/test.dart';
@@ -33,8 +33,7 @@ void main() {
sink = RecordingEventSink();
dispatcher = DaemonDispatcher();
final toolchain = Toolchain();
toolchain.applyResolved(Toolchain.resolvePaths(workspaceRoot: sandbox.path));
final toolchain = ToolchainView.resolved(resolveToolchainPaths(sandbox.path));
final gitClient = GitClient(toolchain: toolchain, workDir: sandbox);
registerGitCommands(dispatcher, gitClient, sink);
});
+2 -3
View File
@@ -8,7 +8,7 @@ library;
import 'dart:io';
import 'package:clide/clide.dart';
import 'package:clide/kernel/src/toolchain.dart';
import 'package:clide/kernel/src/toolchain_paths.dart';
import 'package:clide/src/daemon/pql_commands.dart';
import 'package:clide/src/pql/client.dart';
import 'package:test/test.dart';
@@ -17,8 +17,7 @@ void main() {
late DaemonDispatcher dispatcher;
setUp(() {
final toolchain = Toolchain();
toolchain.applyResolved(const ResolvedPaths(pql: '/tmp/clide-no-such-pql-binary'));
final toolchain = ToolchainView.resolved(const ResolvedPaths(pql: '/tmp/clide-no-such-pql-binary'));
final pql = PqlClient(workDir: Directory.current, toolchain: toolchain);
dispatcher = DaemonDispatcher();
registerPqlCommands(dispatcher, pql);
+2 -3
View File
@@ -1,7 +1,7 @@
import 'dart:io';
import 'package:clide/clide.dart';
import 'package:clide/kernel/src/toolchain.dart';
import 'package:clide/kernel/src/toolchain_paths.dart';
import 'package:clide/src/daemon/pql_commands.dart';
import 'package:test/test.dart';
@@ -10,8 +10,7 @@ void main() {
late PqlClient pql;
setUp(() {
final toolchain = Toolchain();
toolchain.applyResolved(Toolchain.resolvePaths(workspaceRoot: Directory.current.path));
final toolchain = ToolchainView.resolved(resolveToolchainPaths(Directory.current.path));
pql = PqlClient(workDir: Directory.current, toolchain: toolchain);
dispatcher = DaemonDispatcher();
registerPqlCommands(dispatcher, pql);
+3 -8
View File
@@ -5,16 +5,12 @@ library;
import 'dart:io';
import 'package:clide/kernel/src/toolchain.dart';
import 'package:clide/kernel/src/toolchain_paths.dart';
import 'package:clide/src/git/client.dart';
import 'package:clide/src/git/operations.dart' show GitException;
import 'package:test/test.dart';
Toolchain _toolchain() {
final t = Toolchain();
t.applyResolved(Toolchain.resolvePaths(workspaceRoot: Directory.current.path));
return t;
}
ToolchainView _toolchain() => ToolchainView.resolved(resolveToolchainPaths(Directory.current.path));
Future<Directory> _newRepo({String filename = 'file.txt', String contents = 'hello\n'}) async {
final dir = await Directory.systemTemp.createTemp('clide-git-client-');
@@ -195,8 +191,7 @@ void main() {
group('GitClient — error surface', () {
test('a bad git binary path makes _run throw GitException', () async {
final t = Toolchain();
t.applyResolved(const ResolvedPaths(git: '/tmp/clide-no-such-git-binary'));
final t = ToolchainView.resolved(const ResolvedPaths(git: '/tmp/clide-no-such-git-binary'));
final dir = await Directory.systemTemp.createTemp('clide-git-bad-');
addTearDown(() => dir.deleteSync(recursive: true));
final git = GitClient(toolchain: t, workDir: dir);
+3 -5
View File
@@ -5,15 +5,14 @@ library;
import 'dart:io';
import 'package:clide/kernel/src/toolchain.dart';
import 'package:clide/kernel/src/toolchain_paths.dart';
import 'package:clide/src/pql/client.dart';
import 'package:test/test.dart';
void main() {
late PqlClient pql;
setUp(() {
final toolchain = Toolchain();
toolchain.applyResolved(Toolchain.resolvePaths(workspaceRoot: Directory.current.path));
final toolchain = ToolchainView.resolved(resolveToolchainPaths(Directory.current.path));
pql = PqlClient(workDir: Directory.current, toolchain: toolchain);
});
@@ -123,9 +122,8 @@ void main() {
group('PqlClient — error surface', () {
test('non-existent pql binary raises a PqlException with ProcessException details', () async {
final t = Toolchain();
// Inject a bad path — Process.run will throw ProcessException.
t.applyResolved(const ResolvedPaths(pql: '/tmp/clide-no-such-pql-binary'));
final t = ToolchainView.resolved(const ResolvedPaths(pql: '/tmp/clide-no-such-pql-binary'));
final bad = PqlClient(workDir: Directory.current, toolchain: t);
try {
await bad.files();