[tests] Fix language/type_object/runtime_type_function when obfuscated.

Add the "vm:keep-name" pragma to the class whose name is checked.

Add isObfuscated to guard the check that includes named parameter
names, since currently they are obfuscated, even if the function is
marked with the "vm:keep-name" pragma.

TEST=language/type_object/runtime_type_function on
     vm-aot-obfuscate-linux-release-x64

Fixes: https://github.com/dart-lang/sdk/issues/53879

Cq-Include-Trybots: luci.dart.try:vm-aot-obfuscate-linux-release-x64-try
Change-Id: I7698607ed6e1c95860f2e26ede923320a409eba4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332425
Reviewed-by: Daco Harkes <dacoharkes@google.com>
This commit is contained in:
Tess Strickland 2023-10-27 14:02:22 +00:00
parent 6f29e7fce4
commit e7fd34b82c
2 changed files with 18 additions and 1 deletions

View file

@ -38,3 +38,14 @@ Type print string does not match expectation
Actual: '$type'
""");
}
const testRunnerKey = 'test_runner.configuration';
/// Is the test running on a test configuration with VM obfuscation enabled?
final bool isObfuscated = (() {
if (const bool.hasEnvironment(testRunnerKey)) {
const config = String.fromEnvironment(testRunnerKey);
return config.contains('obfuscate');
}
return false;
})();

View file

@ -25,7 +25,12 @@ main() {
// Class static member tear-offs.
check(fn('String', 'String, [String?, dynamic]'), Xyzzy.opt);
check(fn('String', 'String', {'a': 'String?', 'b': 'dynamic'}), Xyzzy.nam);
// TODO(dartbug.com/53879): VM obfuscation also obfuscates named parameters,
// but currently they are not deobfuscated if the function is annotated
// with @pragma("vm:keep-name"), just the function name.
if (!isObfuscated) {
check(fn('String', 'String', {'a': 'String?', 'b': 'dynamic'}), Xyzzy.nam);
}
// Instance method tear-offs.
check(fn('void', 'Object?'), new MyList<String>().add);
@ -50,6 +55,7 @@ main() {
check(fn('void', 'int'), localFunc2);
}
@pragma("vm:keep-name")
class Xyzzy {
static void foo() {}
static String opt(String x, [String? a, b]) => "";