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

Unified Diff: bin/debug_info.dart

Issue 1419903003: merge verify_deps into debug_info (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 | « README.md ('k') | bin/verify_deps.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bin/debug_info.dart
diff --git a/bin/debug_info.dart b/bin/debug_info.dart
index 1c34ccad63f953463e0690a813940be6ce5c3b10..f0dd47bb98796c90ab04dd3674fbc1ab666824af 100644
--- a/bin/debug_info.dart
+++ b/bin/debug_info.dart
@@ -11,6 +11,7 @@ import 'dart:io';
import 'package:dart2js_info/info.dart';
import 'package:dart2js_info/src/graph.dart';
+import 'package:dart2js_info/src/util.dart';
main(args) {
if (args.length < 1) {
@@ -28,6 +29,13 @@ main(args) {
debugLibName = args[2];
}
+ validateSize(info, debugLibName);
+ compareGraphs(info);
+ verifyDeps(info);
+}
+
+/// Validates that codesize of elements adds up to total codesize.
+validateSize(AllInfo info, String debugLibName) {
// Gather data from visiting all info elements.
var tracker = new _SizeTracker(debugLibName);
info.accept(tracker);
@@ -67,9 +75,6 @@ main(args) {
var percent = (missingTotal * 100 / realTotal).toStringAsFixed(2);
_fail('$percent% size missing in libraries (sum of elements > lib.size)');
}
-
- // Validate dependency data.
- compareGraphs(info);
}
class _SizeTracker extends RecursiveInfoVisitor {
@@ -208,6 +213,7 @@ class _State {
int _bodySize = 0;
}
+/// Validates that both forms of dependency information match.
void compareGraphs(AllInfo info) {
var g1 = new EdgeListGraph<Info>();
var g2 = new EdgeListGraph<Info>();
@@ -258,5 +264,23 @@ void compareGraphs(AllInfo info) {
}
}
+// Validates that all elements are reachable from `main` in the dependency
+// graph.
+verifyDeps(AllInfo info) {
+ var graph = graphFromInfo(info);
+ var entrypoint = info.program.entrypoint;
+ var reachables = new Set.from(graph.preOrder(entrypoint));
+
+ var functionsAndFields = []..addAll(info.functions)..addAll(info.fields);
+ var unreachables =
+ functionsAndFields.where((func) => !reachables.contains(func));
+ if (unreachables.isNotEmpty) {
+ _fail('${unreachables.length} elements are unreachable from the '
+ 'entrypoint');
+ } else {
+ _pass('all elements are reachable from the entrypoint');
+ }
+}
+
_pass(String msg) => print('\x1b[32mPASS\x1b[0m: $msg');
_fail(String msg) => print('\x1b[31mFAIL\x1b[0m: $msg');
« no previous file with comments | « README.md ('k') | bin/verify_deps.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698