06bdbd777f
Strips the dart-lang/ai dependency from the SDK entirely, as well as the snapshot. Bug: https://github.com/dart-lang/ai/issues/479 Change-Id: Id919c6a8fbf5fedeffb37e5181bc2fbd85adf986 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/507220 Reviewed-by: Ben Konyi <bkonyi@google.com> Commit-Queue: Ben Konyi <bkonyi@google.com> Auto-Submit: Jake Macdonald <jakemac@google.com>
72 lines
2.1 KiB
Dart
72 lines
2.1 KiB
Dart
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
import 'dart:async';
|
|
import 'package:args/command_runner.dart';
|
|
import 'package:dartdev/src/commands/dart_mcp_server.dart';
|
|
import 'package:test/test.dart';
|
|
|
|
void main() {
|
|
group('DartMCPServerCommand', () {
|
|
late FakeRunner runner;
|
|
late DartMCPServerCommand command;
|
|
|
|
setUp(() {
|
|
runner = FakeRunner();
|
|
command = DartMCPServerCommand();
|
|
runner.addCommand(command);
|
|
});
|
|
|
|
test('delegates to `run dart_mcp_server@`', () async {
|
|
await runner.run(['mcp-server']);
|
|
expect(runner.capturedArgs, equals(['run', 'dart_mcp_server@']));
|
|
});
|
|
|
|
test('forwards command arguments', () async {
|
|
await runner.run(['mcp-server', 'foo', 'bar']);
|
|
expect(
|
|
runner.capturedArgs,
|
|
equals(['run', 'dart_mcp_server@', 'foo', 'bar']),
|
|
);
|
|
});
|
|
|
|
test('strips experimental flag', () async {
|
|
await runner.run(['mcp-server', '--experimental-mcp-server']);
|
|
expect(runner.capturedArgs, equals(['run', 'dart_mcp_server@']));
|
|
});
|
|
|
|
test('strips experimental flag and keeps other args', () async {
|
|
await runner.run(['mcp-server', '--experimental-mcp-server', 'foo']);
|
|
expect(runner.capturedArgs, equals(['run', 'dart_mcp_server@', 'foo']));
|
|
});
|
|
|
|
test('forwards global arguments', () async {
|
|
runner.argParser.addFlag('global-flag', negatable: false);
|
|
await runner.run(['--global-flag', 'mcp-server']);
|
|
expect(
|
|
runner.capturedArgs,
|
|
equals(['--global-flag', 'run', 'dart_mcp_server@']),
|
|
);
|
|
});
|
|
});
|
|
}
|
|
|
|
class FakeRunner extends CommandRunner<int> {
|
|
List<String>? capturedArgs;
|
|
bool isFirstCall = true;
|
|
|
|
FakeRunner() : super('dart', 'dart command runner');
|
|
|
|
@override
|
|
Future<int?> run(Iterable<String> args) async {
|
|
if (isFirstCall) {
|
|
isFirstCall = false;
|
|
return await super.run(args);
|
|
} else {
|
|
capturedArgs = args.toList();
|
|
return 0;
|
|
}
|
|
}
|
|
}
|