Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(399)

Unified Diff: bin/deferred_library_check.dart

Issue 1411153009: move deferred_library_check functionality to a library (Closed) Base URL: git@github.com:dart-lang/dart2js_info.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « CHANGELOG.md ('k') | lib/deferred_library_check.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bin/deferred_library_check.dart
diff --git a/bin/deferred_library_check.dart b/bin/deferred_library_check.dart
index 0c092c5c5a2f537a50e82f29ee4174ec9dd36e6c..d9cd15115b6be8f7ed538a7a884efd98e1fff0d8 100644
--- a/bin/deferred_library_check.dart
+++ b/bin/deferred_library_check.dart
@@ -40,7 +40,7 @@ import 'dart:convert';
import 'dart:io';
import 'package:dart2js_info/info.dart';
-import 'package:quiver/collection.dart';
+import 'package:dart2js_info/deferred_library_check.dart';
import 'package:yaml/yaml.dart';
Future main(List<String> args) async {
@@ -51,81 +51,9 @@ Future main(List<String> args) async {
var info = await infoFromFile(args[0]);
var manifest = await manifestFromFile(args[1]);
- // For each part in the manifest, record the expected "packages" for that
- // part.
- var packages = <String, String>{};
- for (var part in manifest.keys) {
- for (var package in manifest[part]['packages']) {
- if (packages.containsKey(package)) {
- print('You cannot specify that package "$package" maps to both parts '
- '"$part" and "${packages[package]}".');
- exit(1);
- }
- packages[package] = part;
- }
- }
-
- var guessedPartMapping = new BiMap<String, String>();
- guessedPartMapping['main'] = 'main';
-
- bool anyFailed = false;
-
- checkInfo(BasicInfo info) {
- var lib = getLibraryOf(info);
- if (lib != null && isPackageUri(lib.uri)) {
- var packageName = getPackageName(lib.uri);
- var outputUnitName = info.outputUnit.name;
- var expectedPart;
- if (packages.containsKey(packageName)) {
- expectedPart = packages[packageName];
- } else {
- expectedPart = 'main';
- }
- var expectedOutputUnit = guessedPartMapping[expectedPart];
- if (expectedOutputUnit == null) {
- guessedPartMapping[expectedPart] = outputUnitName;
- } else {
- if (expectedOutputUnit != outputUnitName) {
- // TODO(het): add options for how to treat unspecified packages
- if (!packages.containsKey(packageName)) {
- print('"${info.name}" from package "$packageName" was not declared '
- 'to be in an explicit part but was not in the main part');
- } else {
- var actualPart = guessedPartMapping.inverse[outputUnitName];
- print('"${info.name}" from package "$packageName" was specified to '
- 'be in part $expectedPart but is in part $actualPart');
- }
- anyFailed = true;
- }
- }
- }
- }
-
- info.functions.forEach(checkInfo);
- info.fields.forEach(checkInfo);
- if (anyFailed) {
- print('The dart2js output did not meet the specification.');
- } else {
- print('The dart2js output meets the specification');
- }
-}
-
-LibraryInfo getLibraryOf(Info info) {
- var current = info;
- while (current is! LibraryInfo) {
- if (current == null) {
- return null;
- }
- current = current.parent;
- }
- return current;
-}
-
-bool isPackageUri(Uri uri) => uri.scheme == 'package';
-
-String getPackageName(Uri uri) {
- assert(isPackageUri(uri));
- return uri.pathSegments.first;
+ var failures = checkDeferredLibraryManifest(info, manifest);
+ failures.forEach(print);
+ if (failures.isNotEmpty) exitCode = 1;
}
Future<AllInfo> infoFromFile(String fileName) async {
« no previous file with comments | « CHANGELOG.md ('k') | lib/deferred_library_check.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698