Skip to content

Support CLI arguments to the run_tests tool #164

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

Closed
wants to merge 1 commit into from
Closed
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
38 changes: 29 additions & 9 deletions pkgs/dart_mcp_server/lib/src/mixins/dash_cli.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,19 @@ base mixin DashCliSupport on ToolsSupport, LoggingSupport, RootsTrackingSupport

/// Implementation of the [runTestsTool].
Future<CallToolResult> _runTests(CallToolRequest request) async {
final cliArgs = (request.arguments?['args'] as List?)?.cast<String>();
final hasReporterArg =
cliArgs?.any(
(a) => a == '-r' || a == '--reporter' || a.startsWith('--reporter='),
) ??
false;
return runCommandInRoots(
request,
arguments: ['test', '--reporter=failures-only'],
arguments: [
'test',
if (!hasReporterArg) '--reporter=failures-only',
...?cliArgs,
],
commandDescription: 'dart|flutter test',
processManager: processManager,
knownRoots: await roots,
Expand Down Expand Up @@ -187,14 +197,24 @@ base mixin DashCliSupport on ToolsSupport, LoggingSupport, RootsTrackingSupport
),
);

static final runTestsTool = Tool(
name: 'run_tests',
description: 'Runs Dart or Flutter tests for the given project roots.',
annotations: ToolAnnotations(title: 'Run tests', readOnlyHint: true),
inputSchema: Schema.object(
properties: {ParameterNames.roots: rootsSchema(supportsPaths: true)},
),
);
static final Tool runTestsTool = () {
return Tool(
name: 'run_tests',
description:
'Run Dart tests with an agent centric UX. '
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'Run Dart tests with an agent centric UX. '
'Run Dart or Flutter tests with an agent centric UX. '

'ALWAYS use instead of `dart test` or `flutter test` shell commands.',
annotations: ToolAnnotations(title: 'Run tests', readOnlyHint: true),
inputSchema: Schema.object(
properties: {
ParameterNames.roots: rootsSchema(supportsPaths: true),
'args': Schema.list(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: add args to ParameterNames

description: 'CLI arguments',
items: Schema.string(),
),
},
),
);
}();

static final createProjectTool = Tool(
name: 'create_project',
Expand Down