Skip to content

Commit dc2db7f

Browse files
chika3742helin24
andauthored
fix: Non-ASCII test names being escaped when creating run configurations (#8838)
`StringUtil.escapeProperty()` was incorrectly applied to test names in [`CommonTestConfigUtils.findTestName()`](https://github.com/flutter/flutter-intellij/blob/24d11f2a5b5165dc284df06e982a2b56892b632f/src/io/flutter/run/common/CommonTestConfigUtils.java#L139), 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 --- - [x] I’ve reviewed the contributor guide and applied the relevant portions to this PR. <details> <summary>Contribution guidelines:</summary><br> - See our [contributor guide]([https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md](https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md) for general expectations for PRs. - Larger or significant changes should be discussed in an issue before creating a PR. - Dart contributions to our repos should follow the [Dart style guide](https://dart.dev/guides/language/effective-dart) and use `dart format`. - Java and Kotlin contributions should strive to follow Java and Kotlin best practices ([discussion](#8098)). </details> --------- Co-authored-by: Helin Shiah <helinx@google.com>
1 parent 5287c54 commit dc2db7f

4 files changed

Lines changed: 42 additions & 4 deletions

File tree

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ Mohamed El Sayed <devblooming@tutanota.com>
2626
Edwin Ludik <edwin.ludik@gmail.com>
2727
Japnit Singh <truejswalia@gmail.com>
2828
Dmitry Kandalov <dmitry.kandalov@gmail.com>
29+
Kazuya Chikamatsu <kazu.chika.shima@gmail.com>

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
### Fixed
1212

1313
- Silent failure when opening Flutter projects without `.idea` directory in IntelliJ IDEA, by removing `FlutterProjectOpenProcessor` and migrating configuration logic to `FlutterInitializer`. (#8845)
14+
- Gutter buttons not running tests with non-ASCII characters in their names. (#7985)
1415

1516
## 90.0.0
1617

src/io/flutter/run/common/CommonTestConfigUtils.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,16 @@ public String findTestName(@Nullable PsiElement elt) {
130130
final DartCallExpression call = findEnclosingTestCall(elt, getTestsFromOutline(elt.getContainingFile()));
131131
if (call == null) return null;
132132

133+
return extractTestName(call);
134+
}
135+
136+
@VisibleForTesting
137+
@Nullable
138+
public String extractTestName(@NotNull DartCallExpression call) {
133139
final DartStringLiteralExpression lit = DartSyntax.getArgument(call, 0, DartStringLiteralExpression.class);
134140
if (lit == null) return null;
135141

136-
final String name = DartSyntax.unquote(lit);
137-
if (name == null) return null;
138-
139-
return StringUtil.escapeProperty(name, false);
142+
return DartSyntax.unquote(lit);
140143
}
141144

142145
/**
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2026 The Chromium Authors. All rights reserved.
3+
* Use of this source code is governed by a BSD-style license that can be
4+
* found in the LICENSE file.
5+
*/
6+
package io.flutter.run.common;
7+
8+
import com.intellij.psi.PsiElement;
9+
import com.intellij.psi.impl.source.tree.LeafPsiElement;
10+
import com.jetbrains.lang.dart.psi.DartCallExpression;
11+
import io.flutter.AbstractDartElementTest;
12+
import io.flutter.dart.DartSyntax;
13+
import io.flutter.run.test.TestConfigUtils;
14+
import org.junit.Test;
15+
16+
import static org.junit.Assert.assertEquals;
17+
import static org.junit.Assert.assertNotNull;
18+
19+
public class CommonTestConfigUtilsTest extends AbstractDartElementTest {
20+
@Test
21+
public void extractTestNameShouldNotEscapeNonAscii() throws Exception {
22+
run(() -> {
23+
final PsiElement testKeyword = setUpDartElement(
24+
"main() { test('テスト', () {}); }", "test", LeafPsiElement.class);
25+
final DartCallExpression call =
26+
DartSyntax.findEnclosingFunctionCall(testKeyword, "test");
27+
assertNotNull(call);
28+
29+
final String name = TestConfigUtils.getInstance().extractTestName(call);
30+
assertEquals("テスト", name);
31+
});
32+
}
33+
}

0 commit comments

Comments
 (0)