-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[camera_android_camerax] Add agentic guidance for adding native unit tests #12369
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
base: main
Are you sure you want to change the base?
Changes from all commits
3e792b7
df65c25
9625259
98c5f02
ec29cc3
d9adec8
450a615
1115b9e
6ce017e
9bd1e09
dd8ac1b
c61fd5b
af58437
39568d3
5220074
ba88ce3
22cc937
9be59f6
ad564ad
f4357f3
cc98052
a67218c
bd8e616
f4b2179
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Meta comment these are expensive tests to run and I predict we will want to minimize the number of these and maximize the things being evaluated per eval. Similar to an integration test. No changed needed for now but next time we are adding evals for a particular pre-push situation lets try to pick one of the three test_data/setup_* scripts to update. |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,59 @@ | ||||||
| { | ||||||
| "repo_criteria": [], | ||||||
| "evals": [ | ||||||
| { | ||||||
| "id": 1, | ||||||
| "prompt": "First, run 'dart run .agents/skills/pre-push-skill/evals/test_data/setup_missing_native_test.dart'. Then, run the /pre-push skill. Do not attempt to fix any issues you find, only report the output of the skill.", | ||||||
| "expected_chat_output": [ | ||||||
| "Agent explicitly states that the code is not ready to push.", | ||||||
| "Agent points out that DummyEvalFeature.java was modified.", | ||||||
| "Agent points out that a corresponding native unit test was not added or updated." | ||||||
| ], | ||||||
| "expected_repo_state": [ | ||||||
| "No changes are pushed to the remote repository.", | ||||||
| "The agent does not create any new commits or modify the working tree." | ||||||
| ], | ||||||
| "agent_config": "reidbaker-agent" | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non blocking: I think we should probably have contributor-agent, oneshot-agent and bare-agent as the groups of skills. where maybe we have contributor-agent be the default not actually an agent you select and where onshot-agent has tighter expectations. |
||||||
| }, | ||||||
| { | ||||||
| "id": 2, | ||||||
| "prompt": "First, run 'dart run .agents/skills/pre-push-skill/evals/test_data/setup_success_native_test.dart'. Then, run the /pre-push skill. Do not attempt to fix any issues you find, only report the output of the skill.", | ||||||
| "expected_chat_output": [ | ||||||
|
camsim99 marked this conversation as resolved.
|
||||||
| "Agent explicitly states whether the code is ready to push.", | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't this say "Agent explicitly states the code is ready to push."
Suggested change
|
||||||
| "Agent confirms that native unit tests pass." | ||||||
| ], | ||||||
| "expected_repo_state": [ | ||||||
| "No changes are pushed to the remote repository.", | ||||||
| "The agent does not create any new commits or modify the working tree." | ||||||
| ], | ||||||
| "agent_config": "reidbaker-agent" | ||||||
| }, | ||||||
| { | ||||||
| "id": 3, | ||||||
| "prompt": "First, run 'dart run .agents/skills/pre-push-skill/evals/test_data/setup_mixed_missing_native_test.dart'. Then, run the /pre-push skill. Do not attempt to fix any issues you find, only report the output of the skill.", | ||||||
| "expected_chat_output": [ | ||||||
| "Agent explicitly states that the code is not ready to push.", | ||||||
| "Agent points out that DummyEvalFeature.java lacks a corresponding native unit test update." | ||||||
| ], | ||||||
| "expected_repo_state": [ | ||||||
| "No changes are pushed to the remote repository.", | ||||||
| "The agent does not create any new commits or modify the working tree." | ||||||
| ], | ||||||
| "agent_config": "reidbaker-agent" | ||||||
| }, | ||||||
| { | ||||||
| "id": 4, | ||||||
| "prompt": "First, run 'dart run .agents/skills/pre-push-skill/evals/test_data/setup_missing_native_test.dart'. The Java change is just a comment and I explicitly approve bypassing the native test requirement. Then, run the /pre-push skill. Do not attempt to fix any issues you find, only report the output of the skill.", | ||||||
| "expected_chat_output": [ | ||||||
| "Agent acknowledges the user's explicit approval to bypass the native test requirement.", | ||||||
| "Agent states that the code is ready to push.", | ||||||
| "Agent lists the steps that passed or were explicitly bypassed." | ||||||
| ], | ||||||
| "expected_repo_state": [ | ||||||
| "No changes are pushed to the remote repository.", | ||||||
| "The agent does not create any new commits or modify the working tree." | ||||||
| ], | ||||||
| "agent_config": "reidbaker-agent" | ||||||
| } | ||||||
| ] | ||||||
| } | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non blocking comment but does cognitive complexity run on the files in test_data? If not consider adding it in a follow up pr. or at least filing an issue. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| // Copyright 2013 The Flutter Authors | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import 'dart:io'; | ||
|
|
||
| void main() { | ||
| final ProcessResult branchResult = Process.runSync('git', ['branch', '--show-current']); | ||
| final String branch = branchResult.stdout.toString().trim(); | ||
| if (branch == 'main') { | ||
| stdout.writeln('Error: Cannot run setup scripts on main branch.'); | ||
| exit(1); | ||
| } | ||
|
|
||
| final javaFile = File('android/src/main/java/io/flutter/plugins/camerax/DummyEvalFeature.java'); | ||
| javaFile.createSync(recursive: true); | ||
| javaFile.writeAsStringSync(''' | ||
| // Copyright 2013 The Flutter Authors | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| package io.flutter.plugins.camerax; | ||
|
|
||
| public class DummyEvalFeature { | ||
| public void doNothing() {} | ||
| } | ||
| '''); | ||
|
|
||
| Process.runSync('git', ['add', javaFile.path]); | ||
| Process.runSync('git', [ | ||
| '-c', | ||
| 'user.name=Author', | ||
| '-c', | ||
| 'user.email=author@example.com', | ||
| 'commit', | ||
| '-m', | ||
| 'Add DummyEvalFeature.java without tests', | ||
| ]); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| // Copyright 2013 The Flutter Authors | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import 'dart:io'; | ||
|
|
||
| void main() { | ||
| final ProcessResult branchResult = Process.runSync('git', ['branch', '--show-current']); | ||
| final String branch = branchResult.stdout.toString().trim(); | ||
| if (branch == 'main') { | ||
| stdout.writeln('Error: Cannot run setup scripts on main branch.'); | ||
| exit(1); | ||
| } | ||
|
|
||
| final javaFile = File('android/src/main/java/io/flutter/plugins/camerax/DummyEvalFeature.java'); | ||
| javaFile.createSync(recursive: true); | ||
| javaFile.writeAsStringSync(''' | ||
| // Copyright 2013 The Flutter Authors | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| package io.flutter.plugins.camerax; | ||
|
|
||
| public class DummyEvalFeature { | ||
| public void doNothing() {} | ||
| } | ||
| '''); | ||
|
|
||
| final dartFile = File('lib/src/dummy_eval_feature.dart'); | ||
| dartFile.createSync(recursive: true); | ||
| dartFile.writeAsStringSync(''' | ||
| // Copyright 2013 The Flutter Authors | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| /// A dummy eval feature | ||
| class DummyEvalFeature { | ||
| /// Do nothing | ||
| void doNothing() {} | ||
| } | ||
| '''); | ||
|
|
||
| final dartTestFile = File('test/dummy_eval_feature_test.dart'); | ||
| dartTestFile.createSync(recursive: true); | ||
| dartTestFile.writeAsStringSync(''' | ||
| // Copyright 2013 The Flutter Authors | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import 'package:camera_android_camerax/src/dummy_eval_feature.dart'; | ||
| import 'package:flutter_test/flutter_test.dart'; | ||
|
|
||
| void main() { | ||
| test('dummy', () { | ||
| final feature = DummyEvalFeature(); | ||
| feature.doNothing(); | ||
| }); | ||
| } | ||
| '''); | ||
|
|
||
| Process.runSync('git', ['add', javaFile.path, dartFile.path, dartTestFile.path]); | ||
| Process.runSync('git', [ | ||
| '-c', | ||
| 'user.name=Author', | ||
| '-c', | ||
| 'user.email=author@example.com', | ||
| 'commit', | ||
| '-m', | ||
| 'Add DummyEvalFeature with Dart test but missing Java test', | ||
| ]); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| // Copyright 2013 The Flutter Authors | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import 'dart:io'; | ||
|
|
||
| void main() { | ||
| final ProcessResult branchResult = Process.runSync('git', ['branch', '--show-current']); | ||
| final String branch = branchResult.stdout.toString().trim(); | ||
| if (branch == 'main') { | ||
| stdout.writeln('Error: Cannot run setup scripts on main branch.'); | ||
| exit(1); | ||
| } | ||
|
|
||
| final javaFile = File('android/src/main/java/io/flutter/plugins/camerax/DummyEvalFeature.java'); | ||
| javaFile.createSync(recursive: true); | ||
| javaFile.writeAsStringSync(''' | ||
| // Copyright 2013 The Flutter Authors | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| package io.flutter.plugins.camerax; | ||
|
|
||
| public class DummyEvalFeature { | ||
| public void doNothing() {} | ||
| } | ||
| '''); | ||
|
|
||
| final javaTestFile = File( | ||
| 'android/src/test/java/io/flutter/plugins/camerax/DummyEvalFeatureTest.java', | ||
| ); | ||
| javaTestFile.createSync(recursive: true); | ||
| javaTestFile.writeAsStringSync(''' | ||
| // Copyright 2013 The Flutter Authors | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| package io.flutter.plugins.camerax; | ||
|
|
||
| import org.junit.Test; | ||
| import static org.junit.Assert.assertTrue; | ||
|
|
||
| public class DummyEvalFeatureTest { | ||
| @Test | ||
| public void testDoNothing() { | ||
| DummyEvalFeature feature = new DummyEvalFeature(); | ||
| feature.doNothing(); | ||
| assertTrue(true); | ||
| } | ||
| } | ||
| '''); | ||
|
|
||
| Process.runSync('git', ['add', javaFile.path, javaTestFile.path]); | ||
| Process.runSync('git', [ | ||
| '-c', | ||
| 'user.name=Author', | ||
| '-c', | ||
| 'user.email=author@example.com', | ||
| 'commit', | ||
| '-m', | ||
| 'Add DummyEvalFeature.java and tests', | ||
| ]); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like this change where you modify the check-readyness skills then can make the future skills easier to author and maintain.