Skip to content

[engine_tool] Allow a dot in GN target names - #192423

Merged
auto-submit[bot] merged 3 commits into
flutter:masterfrom
pleiondev:et-label-dot
Sep 18, 2026
Merged

auto-submit[bot] merged 3 commits into
flutter:masterfrom
pleiondev:et-label-dot

Conversation

@dzolotov

@dzolotov dzolotov commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Label._checkTarget validated target names with _identifier, the same pattern used for package components, which allows no dot. testing/dart/BUILD.gn derives a compile target from each test file name, so all 55 of them - compile_gpu_test.dart and friends - were rejected, along with the :dart group that depends on them. Building or running any Dart test through et was impossible; ninja was the only way in.

_identifier gains . here, for both halves of a label. Target names need it for compile_gpu_test.dart, and package components need it too: DEPS brings third_party/swiftshader/third_party/llvm-16.0 into the checkout, and its BUILD.gn defines swiftshader_llvm. An identifier still has to start with a letter or underscore, so ., .. and ... remain invalid as a package name component, which is what keeps a label from walking out of the source tree.

Fixes #192422

Verified on macOS, host_debug_unopt_arm64. Both commands from the issue fail on master and succeed with this change:

$ et build -c host_debug_unopt_arm64 //flutter/testing/dart:compile_gpu_test.dart
100.0% (1/1) ACTION //flutter/testing/dart:compile_gpu_test.dart

$ et build -c host_debug_unopt_arm64 //flutter/testing/dart:dart
100.0% (53/53) ACTION //flutter/testing/dart:compile_text_test.dart

dart test test/label_test.dart in engine_tool: 20 passed.

Pre-launch Checklist

@github-actions github-actions Bot added the engine flutter/engine related. See also e: labels. label Sep 8, 2026
@dzolotov
dzolotov marked this pull request as ready for review September 8, 2026 18:56

@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 target name validation in the Label class to allow dots, aligning with GN requirements, and adds corresponding unit tests. The review feedback suggests updating the validation error message to be more descriptive of the allowed characters, adhering to the style guide's recommendation that error messages should be useful.


static FormatException? _checkTarget(String target) {
if (!_identifier.hasMatch(target)) {
if (!_targetName.hasMatch(target)) {

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.

medium

According to the Flutter Repository Style Guide (under General Philosophy): "Error messages should be useful: Every error message is an opportunity to make someone love our product." Since target names now allow dots and hyphens, the error message "Target name must be a valid identifier." is slightly outdated and could be misleading. Consider updating the error message to be more descriptive of the allowed characters (e.g., "Target name must be a valid GN target name containing only alphanumeric characters, underscores, hyphens, or dots, and starting with a letter or underscore").

References
  1. Error messages should be useful: Every error message is an opportunity to make someone love our product. (link)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in 7ee04a7. The message now spells out what is accepted:

Target name must start with a letter or underscore and contain only letters, digits, "_", "-", or ".".

I stopped short of calling it a valid GN target name, because this regexp is stricter than GN's: GN also allows + and $, and does not require the first character to be a letter or underscore. Naming GN in the message would promise more than the check actually enforces.

I also updated two doc comments that still described the old rule: the class-level bullet listing valid identifier characters, and the doc on the target field. Those are the ones someone reads when they want to know why compile_gpu_test.dart is accepted but //foo/bar.baz is not.

@gaaclarke
gaaclarke requested a review from b-luk September 15, 2026 20:41

@b-luk b-luk 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.

Thanks for tracking down this issue.

I see no reason why we need a different regex for the package components vs the target name. I think package components may also contain a period, e.g. //flutter/third_party/swiftshader/third_party/llvm-16.0:swiftshader_llvm. Should we just expand the existing regex instead of making a separate one for the target?

@dzolotov

Copy link
Copy Markdown
Contributor Author

You're right, and the example is real: DEPS brings in third_party/swiftshader/third_party/llvm-16.0, whose BUILD.gn defines swiftshader_llvm, so that label is rejected today as well. I had only looked at flutter/flutter itself, which misses everything DEPS pulls in.

Fixed in 8467016: _targetName is gone, _identifier gains the dot, and both error messages share one sentence describing the rule. The leading [a-zA-Z_] stays, so ., .. and ... still fail as a package component, which matters because TargetPattern strips only a trailing /... before handing the rest to Label. The test that pinned //foo/bar.baz as invalid now parses the swiftshader label instead. 20 tests pass, and I rewrote the paragraph in the description that made the wrong claim.

@b-luk b-luk added the CICD Run CI/CD label Sep 16, 2026
@b-luk

b-luk commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Thanks @dzolotov. The change looks good to me. But two issues need addressing:

  1. I see a failing ci.yaml validation check. This can be resolved by merging the latest changes from master.
  2. the cla/google check is failing: https://github.com/flutter/flutter/pull/192423/checks?check_run_id=105006415276. It seems like one of your commits is using a different email, which does not match the email associated with your CLA. Please either add the new email address to the CLA or rebase the commit with the correct email address.

The label parser validated target names with the same pattern it uses for
package components, which has no dot. Every Dart test target is named after
its test file, so `et` rejected all of them and the group that depends on
them, leaving ninja as the only way to build them.
The target regexp now permits a dot, but the FormatException text and the
doc comments still said "valid identifier". Spell out the accepted
characters in the message, and split the package and target rules in the
class documentation.
The separate target pattern was wrong: package components need the dot
too. `flutter/third_party/swiftshader/third_party/llvm-16.0` comes in
through DEPS and defines `swiftshader_llvm`, so a label pointing at it
was rejected before this change and after it as well.

The dot goes into `_identifier`, `_targetName` is gone, and both error
messages share one sentence describing the rule. The leading letter or
underscore still keeps `.`, `..` and `...` out of package names, which
matters because `TargetPattern` strips only a trailing `/...` before
handing the rest to `Label`.
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Sep 17, 2026
@dzolotov

Copy link
Copy Markdown
Contributor Author

Both done. The CLA fix needed a force-push anyway, so I rebased the branch onto today's master (9ead586). One commit had gone out under a second account of mine; all three now carry the address my CLA is signed with, and cla/google is green on the new head, e4b43bf. The diff is identical to what you reviewed.

@b-luk b-luk added the CICD Run CI/CD label Sep 17, 2026
@b-luk

b-luk commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Thanks, @dzolotov

PR process tip: After you've addressed a reviewer's comments, use the "re-request review" button to bring it to the reviewer's attention again.

@b-luk

b-luk commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

@gaaclarke for second review (or to pass to someone else)

@b-luk
b-luk requested a review from gaaclarke September 18, 2026 17:42

@gaaclarke gaaclarke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm!

@gaaclarke gaaclarke added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 18, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Sep 18, 2026
Merged via the queue into flutter:master with commit 2cb5ae4 Sep 18, 2026
30 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD engine flutter/engine related. See also e: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[engine_tool] et rejects every Dart test target because their names contain a dot

3 participants