mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 01:21:07 +00:00
57e54cdd31
Flutter has migrated away from using the discontinued `package:package_resolver`, see [0], which should allow us to prefer the new `.dart_tool/package_config.json` format now. [0] https://github.com/flutter/flutter/issues/56289 Closes https://github.com/dart-lang/sdk/issues/41748 Change-Id: I9026af05756d01f4a3e0e0fc97fa77d27bf805b4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146840 Reviewed-by: Siva Annamalai <asiva@google.com> Commit-Queue: Martin Kustermann <kustermann@google.com>
47 lines
1.6 KiB
Dart
47 lines
1.6 KiB
Dart
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
import 'dart:io';
|
|
|
|
import 'package:path/path.dart' as path;
|
|
|
|
import 'spawn_uri__package_uri__test.dart';
|
|
|
|
final executable = Platform.executable;
|
|
|
|
main() async {
|
|
// Make a folder structure that has both ".dart_tool/package_config.json" and
|
|
// ".packages" and ensure VM prefers to use ".packages".
|
|
await withTempDir((String tempDir) async {
|
|
// Setup bogus ".packages" with "foo -> ..." with invalid mapping.
|
|
final dotPackagesPath = path.join(tempDir, '.packages');
|
|
final dotPackagesFile = File(dotPackagesPath);
|
|
await dotPackagesFile.writeAsString(buildDotPackages('invalid'));
|
|
|
|
// Setup ".dart_tool/package_config.json".
|
|
final dotDartToolDir = path.join(tempDir, '.dart_tool');
|
|
await Directory(dotDartToolDir).create();
|
|
final packageConfigJsonPath =
|
|
path.join(dotDartToolDir, 'package_config.json');
|
|
final packageConfigJsonFile = File(packageConfigJsonPath);
|
|
await packageConfigJsonFile.writeAsString(buildPackageConfig('foo', true));
|
|
|
|
final mainFile = path.join(tempDir, 'main.dart');
|
|
await File(mainFile).writeAsString('''
|
|
import 'dart:io' as io;
|
|
import 'dart:isolate';
|
|
|
|
main() async {
|
|
final uri = await Isolate.packageConfig;
|
|
final expectedUri = Uri.parse('${packageConfigJsonFile.uri}');
|
|
if (uri != expectedUri) {
|
|
throw 'VM should use .packages file (but used \$uri).';
|
|
}
|
|
}
|
|
''');
|
|
|
|
await run(executable, [mainFile]);
|
|
});
|
|
}
|