Sitelet https://github.com/flutter/packages/pull/12369
Skip to content

[camera_android_camerax] Add agentic guidance for adding native unit tests - #12369

Merged
auto-submit[bot] merged 25 commits into
flutter:mainfrom
camsim99:cos_nativetests
Aug 20, 2026
Merged

auto-submit[bot] merged 25 commits into
flutter:mainfrom
camsim99:cos_nativetests

Conversation

@camsim99

@camsim99 camsim99 commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Adds guidance for agents to ensure native unit tests are added when native Android code is modified by:

  • Updating AGENTS.md to explicitly note how to run native unit tests + that tests should be added if any of the Java files re touched
  • Updating the pre-push skill to ensure native unit tests are added as expected + pass
  • Adds evals for the new guidance added to the pre-push skill to ensure native unit tests not being added or failing causes the skill to fail. Results of running them:
    • Eval 1 (Missing Native Test): PASSED – Detected that CameraProxyApi.java was modified without tests in android/src/test/ and blocked push readiness (# NO, you are not ready to push.).
    • Eval 2 (Success Native Test): PASSED – Ran both dart-test and native-test --no-integration, verified CameraTest.java covered CameraProxyApi.java, handled unrelated test environment exceptions per the rubric, and approved push readiness (# YES, you are ready to push!).
    • Eval 3 (Mixed Missing Native Test): PASSED – Detected that although Dart unit tests were updated for Dart changes, CameraProxyApi.java lacked a test update in android/src/test/, and blocked push readiness.
    • Eval 4 (Bypassed Mixed Missing Native Test): PASSED -- Explicitly identified that CameraProxyApi.java
      was modified without a native test update, but noted: "since you explicitly approved bypassing the native test requirement for this comment-only change, this check is marked as approved."

Follow up from one-shot attempt #12302. See go/flutter-project-one-shot for more information on the project.

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Aug 4, 2026
@flutter-dashboard

Copy link
Copy Markdown

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the pre-push skill documentation and agent guidelines to require and verify native Android unit tests alongside Dart unit tests, and adds evaluation scripts to test this behavior. The reviewer feedback suggests wrapping command substitutions in double quotes to handle paths with spaces, running repository-level tools from the repository root, and configuring temporary git author information in evaluation scripts to prevent commit failures in clean CI/CD environments.

Comment thread packages/camera/camera_android_camerax/.agents/skills/pre-push-skill/SKILL.md Outdated
Comment thread packages/camera/camera_android_camerax/AGENTS.md Outdated
@camsim99 camsim99 added override: no versioning needed Override the check requiring version bumps for most changes override: no changelog needed Override the check requiring CHANGELOG updates for most changes labels Aug 4, 2026
@camsim99
camsim99 requested a review from reidbaker August 5, 2026 17:32
# Commit so git status is clean and git diff against origin/main shows the Java change
cd "$PACKAGE_DIR" || exit 1
git add "$JAVA_FILE"
git -c user.name="Author" -c user.email="author@example.com" commit -m "eval: temporary commit with Java change and no test update"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there a way to see if git can confirm it is in a tree and not on master. I can see agents running this eval in the wrong context and polluting the git history.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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.

Comment thread packages/camera/camera_android_camerax/AGENTS.md Outdated
any new logic. For integration tests, see [flutter-add-integration-test](.agents/skills/flutter-add-integration-test/SKILL.md).
any new logic.
- **Dart Unit Tests**: See [dart-add-unit-test](.agents/skills/dart-add-unit-test/SKILL.md).
- **Native Unit Tests**: Run `cd "$(git rev-parse --show-toplevel)" && dart run script/tool/bin/flutter_plugin_tools.dart native-test --packages camera_android_camerax --no-integration`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do you need to run cd "$(git rev-parse --show-toplevel)" Shouldn't the flutter_plugin_tools command work no matter the directory? If we need to find flutter_plugin_tools we can modify the bootstrapping skill that runs to make sure agents are ready to work by either installing the tool or adding an environment variable.

@camsim99
camsim99 requested a review from reidbaker August 11, 2026 23:40
}

Future<bool> _activateFlutterPluginTools(String workspaceRoot) async {
_log('5. Activating flutter_plugin_tools...');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit. If we are going to include numbers then lets put the methods in log number order.

"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 a native Java file was modified.",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we want the agent to say the name of the file? if so maybe this should say Agent points out that <path to fille> was modified

"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"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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.

```bash
cd $(git rev-parse --show-toplevel)
dart run script/tool/bin/flutter_plugin_tools.dart \
dart pub global run flutter_plugin_tools \

Copy link
Copy Markdown
Contributor

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.

@camsim99
camsim99 requested a review from reidbaker August 19, 2026 17:46

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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.

…-skill/evals/evals.json

Co-authored-by: Reid Baker <1063596+reidbaker@users.noreply.github.com>
@camsim99 camsim99 added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 20, 2026
@auto-submit
auto-submit Bot merged commit e31dfab into flutter:main Aug 20, 2026
13 checks passed
pull Bot pushed a commit to ScorpiusDraconis83/flutter that referenced this pull request Aug 21, 2026
…r#191480)

flutter/packages@1785501...252bb33

2026-08-20 pateltirth454@gmail.com [material_ui] A typo in the README
file of the package. (flutter/packages#12526)
2026-08-20 jmccandless@google.com [material_ui] Animated theme test from
flutter/flutter (flutter/packages#12487)
2026-08-20 fluttergithubbot@gmail.com Sync release-material_ui-1.0.1 to
main (flutter/packages#12513)
2026-08-20 pateltirth454@gmail.com [material_ui] [cupertino_ui] Add
missing Widget of the Week videos to widget API docs
(flutter/packages#12468)
2026-08-20 43054281+camsim99@users.noreply.github.com
[camera_android_camerax] Add agentic guidance for adding native unit
tests (flutter/packages#12369)
2026-08-20 21270878+elliette@users.noreply.github.com [material_ui]
SearchAnchor overlay expands to full screen when viewport size changes
(flutter/packages#12466)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC flutter-ecosystem@google.com on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
auto-submit Bot pushed a commit that referenced this pull request Sep 30, 2026
…logic (#12371)

Corrects the version and merge conflict validation logic in the `pre-push` skill to compare the local branch against the upstream branch. If the merge conflict check fails, then the skill immediately reports that the code is not ready to push now.

Also, adds an eval to ensure this update works as expected. Result of running it:

| Eval ID | Scenario | Expected Outcome | Result | Justification |
| :---: | :--- | :--- | :---: | :--- |
| **1** | Behind Upstream (`setup_behind_upstream.sh`) | Detect branch is behind `upstream/main`, stop immediately without updating release info | **PASS** | Checked merge-base against `upstream/main`, halted immediately with `# NO, you are not ready to push`, and left `pubspec.yaml` and `CHANGELOG.md` unmodified. |
| **2** | Behind Upstream with Conflicts (`setup_behind_upstream_conflict.dart`) | Detect that the branch is behind the upstream repository | **PASS** | Detected that the branch is behind the upstream repository, Ran git merge-tree and detected merge conflicts (CONFLICT (content): Merge conflict in .ci/flutter_master.version), Stopped immediately without running subsequent checks, Output # NO, you are not ready to push. and provided actionable instructions on how to resolve conflicts before pushing

Ideally #12369 lands first so I can update the references of origin to upstream.

---- 

Follow up from one-shot attempt #12302. See go/flutter-project-one-shot for more information on the project.

## Pre-Review Checklist

**Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

[^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD override: no changelog needed Override the check requiring CHANGELOG updates for most changes override: no versioning needed Override the check requiring version bumps for most changes p: camera

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants