Skip to content

Commit b14d346

Browse files
authored
Fix Platform.script for flutter_tester (flutter#46911)
This addresses the problem in flutter/flutter#12847 which changed slightly over time. Today, `Platform.script` does not give an empty `file` URI, it gives something like `file://path/to/package/main.dart` _regardless of how the file is actually named_. After this change, it will give the absolute path to the file being run under test. So before this change, the new test would have a URI like ``` file:///Users/dnfield/src/flutter/engine/src/main.dart ``` And now it has ``` file:///Users/dnfield/src/flutter/engine/src/out/host_debug_unopt_arm64/gen/platform_test.dart.dill ``` This is going to be helpful in generating relative paths from the test file.
1 parent 2692787 commit b14d346

3 files changed

Lines changed: 16 additions & 0 deletions

File tree

shell/testing/tester_main.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,7 @@ int main(int argc, char* argv[]) {
526526
// it as a positional argument instead.
527527
settings.application_kernel_asset = command_line.positional_args()[0];
528528
}
529+
settings.advisory_script_uri = settings.application_kernel_asset;
529530

530531
if (settings.application_kernel_asset.empty()) {
531532
FML_LOG(ERROR) << "Dart kernel file not specified.";

testing/dart/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ tests = [
3838
"paragraph_test.dart",
3939
"path_test.dart",
4040
"picture_test.dart",
41+
"platform_test.dart",
4142
"platform_view_test.dart",
4243
"plugin_utilities_test.dart",
4344
"semantics_test.dart",

testing/dart/platform_test.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'dart:io';
6+
7+
import 'package:litetest/litetest.dart';
8+
9+
void main() {
10+
test('Platform.script has right URI', () async {
11+
// Platform.script should look like file:///path/to/engine/src/out/variant/gen/platform_test.dart.dill
12+
expect(Platform.script.path, endsWith('gen/platform_test.dart.dill'));
13+
});
14+
}

0 commit comments

Comments
 (0)