Skip to content

fix: Non-ASCII test names being escaped when creating run configurations#8838

Merged
pq merged 4 commits intoflutter:mainfrom
chika3742:fix-non-ascii-test-name-escaped
Mar 23, 2026
Merged

fix: Non-ASCII test names being escaped when creating run configurations#8838
pq merged 4 commits intoflutter:mainfrom
chika3742:fix-non-ascii-test-name-escaped

Conversation

@chika3742
Copy link
Copy Markdown
Contributor

@chika3742 chika3742 commented Feb 28, 2026

StringUtil.escapeProperty() was incorrectly applied to test names in CommonTestConfigUtils.findTestName(), converting non-ASCII characters (e.g. Japanese "テスト") to Unicode escape sequences. This caused flutter test --plain-name to receive an escaped string that did not match the actual test name, preventing the test from running.

Fix by removing the escapeProperty() call, which is intended for .properties file encoding and is unnecessary here.

fixes #7985


  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.
Contribution guidelines:

Copy link
Copy Markdown
Contributor

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

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 correctly resolves an issue where non-ASCII test names were improperly escaped, preventing tests from running. The refactoring of test name extraction logic into a separate, testable method is a positive change for code quality. My review includes suggestions to further improve the new code by adhering to the repository's style guide, specifically by using java.util.Optional to avoid returning null values, which enhances null safety.

Comment thread src/io/flutter/run/common/CommonTestConfigUtils.java
Comment thread src/io/flutter/run/common/CommonTestConfigUtils.java
Comment thread testSrc/unit/io/flutter/run/common/CommonTestConfigUtilsTest.java
@chika3742 chika3742 marked this pull request as ready for review February 28, 2026 13:26
@chika3742 chika3742 marked this pull request as draft February 28, 2026 14:07
@chika3742 chika3742 marked this pull request as ready for review February 28, 2026 14:15
@helin24
Copy link
Copy Markdown
Member

helin24 commented Mar 11, 2026

Thanks for the contribution! This seems like a good change. Are you able to run locally (or build a local copy of the plugin) and provide a gif of this working? (also, sorry about the delay in my response. I missed checking PRs last week)

@chika3742
Copy link
Copy Markdown
Contributor Author

chika3742 commented Mar 12, 2026

@helin24 Thanks for the review! No worries about the delay.

Here's a demo of it working locally:

Before After
画面収録 2026-03-12 12 05 14 画面収録 2026-03-12 12 00 19

While recording this, I noticed that the first test marker in the file is not showing sometimes. After some investigation, I found the following issues:

  1. Comparison between the cache and the value obtained from outlineService is incorrect, causing outlineOutdated to always be true if the cache is present.
    final OutlineCache entry = cache.get(path);
    outlineOutdated = cache.containsKey(path) && outline != entry.outline;
  2. Because the workaround applied for main functions (line 81) is not applied for other test calls, the first test markers disappears when editing the file.
    if (dartId.getParent().getParent() instanceof DartCallExpression dartCallExpression) {
    final TestType testCall = testConfigUtils.asTestCall(dartCallExpression);
    if (testCall != null) {
    final Icon icon = getTestStateIcon(element, testCall.getIcon());
    final Function<PsiElement, String> tooltipProvider =
    psiElement -> testCall.getTooltip(psiElement, testConfigUtils);
    return new RunLineMarkerContributor.Info(icon, ExecutorAction.getActions(), tooltipProvider);
    }
    }
    else if (dartId.getParent().getParent() instanceof DartFunctionDeclarationWithBodyOrNative) {
    if (testConfigUtils instanceof TestConfigUtils) {
    // TODO(messick) Find a better way to eliminate duplicate pop-up menu entries.
    // The issue is that there are two contributors, one for normal Flutter, one for Bazel,
    // and they should not both produce contributions at the same time.
    return null;
    }
    if ("main".equals(dartId.getText())) {
    // There seems to be an intermittent timing issue that causes the first test call to not get marked.
    // Priming the cache here solves it.
    testConfigUtils.refreshOutline(element);

I can open a separate PR (issue) to fix these if you'd like.

Copy link
Copy Markdown
Member

@helin24 helin24 left a comment

Choose a reason for hiding this comment

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

Thanks for the demo! This LGTM, and I think a separate PR for the missing arrow would be reasonable.

Edit: A couple other things - add a note to CHANGELOG and make sure you are in the AUTHORS file.

StringUtil.escapeProperty() was incorrectly applied to test names in CommonTestConfigUtils.findTestName(), converting non-ASCII characters (e.g. Japanese "テスト") to Unicode escape sequences. This caused `flutter test --plain-name` to receive an escaped string that did not match the actual test name, preventing the test from running.

Fix by removing the escapeProperty() call, which is intended for .properties file encoding and is unnecessary here.
@chika3742 chika3742 force-pushed the fix-non-ascii-test-name-escaped branch from fbe0345 to 5d04b09 Compare March 20, 2026 11:23
@chika3742 chika3742 force-pushed the fix-non-ascii-test-name-escaped branch from 5d04b09 to f2a1c38 Compare March 20, 2026 11:27
Copy link
Copy Markdown
Member

@helin24 helin24 left a comment

Choose a reason for hiding this comment

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

lgtm - adding @pq to review and merge.

Comment thread CHANGELOG.md Outdated
@helin24 helin24 requested a review from pq March 20, 2026 18:54
Co-authored-by: Helin Shiah <helinx@google.com>
@pq pq merged commit dc2db7f into flutter:main Mar 23, 2026
11 of 12 checks passed
@chika3742 chika3742 deleted the fix-non-ascii-test-name-escaped branch April 1, 2026 03:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tests are not run if the name contains Cyrillic(or Korean) characters . When running flutter tests in IntelliJ IDEA.

3 participants