Skip to content

Commit 6a71aeb

Browse files
authored
run tests on windows, fix executable paths for dart/flutter (#149)
Closes #32 I believe this should just work now that we are using headless flutter Initially also added macos tests but those bots tend to wait queued for a long time, so I have removed them.
1 parent 2a5eb30 commit 6a71aeb

File tree

8 files changed

+173
-109
lines changed

8 files changed

+173
-109
lines changed

.github/workflows/dart_mcp.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,16 @@ defaults:
2121

2222
jobs:
2323
build:
24-
runs-on: ubuntu-latest
24+
runs-on: ${{ matrix.os }}
2525
strategy:
2626
fail-fast: false
2727
matrix:
28-
sdk: [stable, dev]
28+
sdk:
29+
- stable
30+
- dev
31+
os:
32+
- ubuntu-latest
33+
- windows-latest
2934
steps:
3035
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
3136
- uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c

.github/workflows/dart_mcp_server.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,16 @@ defaults:
2323

2424
jobs:
2525
build:
26-
runs-on: ubuntu-latest
26+
runs-on: ${{ matrix.os }}
2727
strategy:
2828
fail-fast: false
2929
matrix:
30-
flutterSdk: [stable, master]
30+
flutterSdk:
31+
- stable
32+
- master
33+
os:
34+
- ubuntu-latest
35+
- windows-latest
3136
steps:
3237
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
3338
# We need the flutter SDK in order to run the counter app for integration

pkgs/dart_mcp_server/lib/src/utils/sdk.dart

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ class Sdk {
4747
if (dartSdkPath.parent case final cacheDir
4848
when cacheDir.basename == 'cache' && flutterSdkPath == null) {
4949
if (cacheDir.parent case final binDir when binDir.basename == 'bin') {
50-
final flutterExecutable = binDir.child('flutter');
50+
final flutterExecutable = binDir.child(
51+
'flutter${Platform.isWindows ? '.bat' : ''}',
52+
);
5153
if (File(flutterExecutable).existsSync()) {
5254
flutterSdkPath = binDir.parent;
5355
}
@@ -61,7 +63,9 @@ class Sdk {
6163
///
6264
/// Throws an [ArgumentError] if [dartSdkPath] is `null`.
6365
String get dartExecutablePath =>
64-
dartSdkPath?.child('bin').child('dart') ??
66+
dartSdkPath
67+
?.child('bin')
68+
.child('dart${Platform.isWindows ? '.exe' : ''}') ??
6569
(throw ArgumentError(
6670
'Dart SDK location unknown, try setting the DART_SDK environment '
6771
'variable.',
@@ -71,7 +75,9 @@ class Sdk {
7175
///
7276
/// Throws an [ArgumentError] if [flutterSdkPath] is `null`.
7377
String get flutterExecutablePath =>
74-
flutterSdkPath?.child('bin').child('flutter') ??
78+
flutterSdkPath
79+
?.child('bin')
80+
.child('flutter${Platform.isWindows ? '.bat' : ''}') ??
7581
(throw ArgumentError(
7682
'Flutter SDK location unknown. To work on flutter projects, you must '
7783
'spawn the server using `dart` from the flutter SDK and not a Dart '

pkgs/dart_mcp_server/test/test_harness.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
import 'dart:async';
66
import 'dart:convert';
7-
import 'dart:io';
7+
import 'dart:io' hide File;
8+
import 'dart:io' as io show File;
89

910
import 'package:async/async.dart';
1011
import 'package:dart_mcp/client.dart';
@@ -256,7 +257,7 @@ final class AppDebugSession {
256257
await process.shouldExit(0);
257258
} else {
258259
unawaited(process.kill());
259-
await process.shouldExit(anyOf(0, -9));
260+
await process.shouldExit(anyOf(0, Platform.isWindows ? -1 : -9));
260261
}
261262
}
262263

@@ -497,5 +498,6 @@ class _CommandMatcher extends Matcher {
497498
}
498499

499500
extension RootPath on Root {
500-
String get path => Uri.parse(uri).path;
501+
/// Get the OS specific file path for this root.
502+
String get path => io.File.fromUri(Uri.parse(uri)).path;
501503
}

pkgs/dart_mcp_server/test/tools/analyzer_test.dart

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
import 'dart:io';
6-
75
import 'package:dart_mcp/server.dart';
86
import 'package:dart_mcp_server/src/mixins/analyzer.dart';
97
import 'package:dart_mcp_server/src/utils/constants.dart';
@@ -75,14 +73,18 @@ void main() {
7573
});
7674

7775
test('can look up symbols in a workspace', () async {
78-
final currentRoot = testHarness.rootForPath(Directory.current.path);
79-
testHarness.mcpClient.addRoot(currentRoot);
76+
final example = d.dir('lib', [
77+
d.file('awesome_class.dart', 'class MyAwesomeClass {}'),
78+
]);
79+
await example.create();
80+
final exampleRoot = testHarness.rootForPath(example.io.path);
81+
testHarness.mcpClient.addRoot(exampleRoot);
8082
await pumpEventQueue();
8183

8284
final result = await testHarness.callToolWithRetry(
8385
CallToolRequest(
8486
name: DartAnalyzerSupport.resolveWorkspaceSymbolTool.name,
85-
arguments: {ParameterNames.query: 'DartAnalyzerSupport'},
87+
arguments: {ParameterNames.query: 'MyAwesomeClass'},
8688
),
8789
);
8890
expect(result.isError, isNot(true));
@@ -92,7 +94,7 @@ void main() {
9294
isA<TextContent>().having(
9395
(t) => t.text,
9496
'text',
95-
contains('analyzer.dart'),
97+
contains('awesome_class.dart'),
9698
),
9799
);
98100
});

pkgs/dart_mcp_server/test/tools/dart_cli_test.dart

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
import 'dart:io';
6+
57
import 'package:dart_mcp/server.dart';
68
import 'package:dart_mcp_server/src/mixins/dash_cli.dart';
79
import 'package:dart_mcp_server/src/utils/constants.dart';
@@ -15,6 +17,8 @@ void main() {
1517
late TestProcessManager testProcessManager;
1618
late Root exampleFlutterAppRoot;
1719
late Root dartCliAppRoot;
20+
final dartExecutableName = 'dart${Platform.isWindows ? '.exe' : ''}';
21+
final flutterExecutableName = 'flutter${Platform.isWindows ? '.bat' : ''}';
1822

1923
// TODO: Use setUpAll, currently this fails due to an apparent TestProcess
2024
// issue.
@@ -76,7 +80,7 @@ dependencies:
7680
expect(result.isError, isNot(true));
7781
expect(testProcessManager.commandsRan, [
7882
equalsCommand((
79-
command: [endsWith('dart'), 'fix', '--apply'],
83+
command: [endsWith(dartExecutableName), 'fix', '--apply'],
8084
workingDirectory: exampleFlutterAppRoot.path,
8185
)),
8286
]);
@@ -98,7 +102,7 @@ dependencies:
98102
expect(result.isError, isNot(true));
99103
expect(testProcessManager.commandsRan, [
100104
equalsCommand((
101-
command: [endsWith('dart'), 'format', '.'],
105+
command: [endsWith(dartExecutableName), 'format', '.'],
102106
workingDirectory: exampleFlutterAppRoot.path,
103107
)),
104108
]);
@@ -123,7 +127,12 @@ dependencies:
123127
expect(result.isError, isNot(true));
124128
expect(testProcessManager.commandsRan, [
125129
equalsCommand((
126-
command: [endsWith('dart'), 'format', 'foo.dart', 'bar.dart'],
130+
command: [
131+
endsWith(dartExecutableName),
132+
'format',
133+
'foo.dart',
134+
'bar.dart',
135+
],
127136
workingDirectory: exampleFlutterAppRoot.path,
128137
)),
129138
]);
@@ -155,15 +164,15 @@ dependencies:
155164
expect(testProcessManager.commandsRan, [
156165
equalsCommand((
157166
command: [
158-
endsWith('flutter'),
167+
endsWith(flutterExecutableName),
159168
'test',
160169
'foo_test.dart',
161170
'bar_test.dart',
162171
],
163172
workingDirectory: exampleFlutterAppRoot.path,
164173
)),
165174
equalsCommand((
166-
command: [endsWith('dart'), 'test', 'zip_test.dart'],
175+
command: [endsWith(dartExecutableName), 'test', 'zip_test.dart'],
167176
workingDirectory: dartCliAppRoot.path,
168177
)),
169178
]);
@@ -186,7 +195,7 @@ dependencies:
186195
expect(testProcessManager.commandsRan, [
187196
equalsCommand((
188197
command: [
189-
endsWith('dart'),
198+
endsWith(dartExecutableName),
190199
'create',
191200
'--template',
192201
'cli',
@@ -213,7 +222,7 @@ dependencies:
213222
expect(testProcessManager.commandsRan, [
214223
equalsCommand((
215224
command: [
216-
endsWith('flutter'),
225+
endsWith(flutterExecutableName),
217226
'create',
218227
'--template',
219228
'app',
@@ -243,7 +252,7 @@ dependencies:
243252
expect(testProcessManager.commandsRan, [
244253
equalsCommand((
245254
command: [
246-
endsWith('flutter'),
255+
endsWith(flutterExecutableName),
247256
'create',
248257
'--template',
249258
'app',

0 commit comments

Comments
 (0)