Write the package config location to the test bootstrap. (#150440)
Work towards. This is the Flutter companion to https://github.com/dart-lang/test/pull/2245. Work towards https://github.com/dart-lang/test/issues/2246.
This commit is contained in:
@@ -13,6 +13,7 @@ import 'package:flutter_tools/src/base/common.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/base/terminal.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/commands/test.dart';
|
||||
import 'package:flutter_tools/src/device.dart';
|
||||
@@ -1479,6 +1480,7 @@ class FakeFlutterTestRunner implements FlutterTestRunner {
|
||||
String? integrationTestUserIdentifier,
|
||||
TestTimeRecorder? testTimeRecorder,
|
||||
TestCompilerNativeAssetsBuilder? nativeAssetsBuilder,
|
||||
BuildInfo? buildInfo,
|
||||
}) async {
|
||||
lastEnableVmServiceValue = enableVmService;
|
||||
lastDebuggingOptionsValue = debuggingOptions;
|
||||
|
||||
@@ -122,4 +122,41 @@ void main() {
|
||||
expect(flutterPlatform.uriConverter?.call('hello'), 'hello/test');
|
||||
});
|
||||
});
|
||||
|
||||
group('generateTestBootstrap', () {
|
||||
group('writes a "const packageConfigLocation" string', () {
|
||||
test('with null packageConfigUri', () {
|
||||
final String contents = generateTestBootstrap(
|
||||
testUrl:
|
||||
Uri.parse('file:///Users/me/some_package/test/some_test.dart'),
|
||||
host: InternetAddress('127.0.0.1', type: InternetAddressType.IPv4),
|
||||
);
|
||||
// IMPORTANT: DO NOT RENAME, REMOVE, OR MODIFY THE
|
||||
// 'const packageConfigLocation' VARIABLE.
|
||||
// Dash tooling like Dart DevTools performs an evaluation on this variable
|
||||
// at runtime to get the package config location for Flutter test targets.
|
||||
expect(contents, contains("const packageConfigLocation = 'null';"));
|
||||
});
|
||||
|
||||
test('with non-null packageConfigUri', () {
|
||||
final String contents = generateTestBootstrap(
|
||||
testUrl:
|
||||
Uri.parse('file:///Users/me/some_package/test/some_test.dart'),
|
||||
host: InternetAddress('127.0.0.1', type: InternetAddressType.IPv4),
|
||||
packageConfigUri: Uri.parse(
|
||||
'file:///Users/me/some_package/.dart_tool/package_config.json'),
|
||||
);
|
||||
// IMPORTANT: DO NOT RENAME, REMOVE, OR MODIFY THE
|
||||
// 'const packageConfigLocation' VARIABLE.
|
||||
// Dash tooling like Dart DevTools performs an evaluation on this variable
|
||||
// at runtime to get the package config location for Flutter test targets.
|
||||
expect(
|
||||
contents,
|
||||
contains(
|
||||
"const packageConfigLocation = 'file:///Users/me/some_package/.dart_tool/package_config.json';",
|
||||
),
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user