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

Unified Diff: dart/frog/leg/apiimpl.dart

Issue 9813012: Add "mock" compilation feature to dart2js and use it to improve test coverage. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments Created 8 years, 9 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
Index: dart/frog/leg/apiimpl.dart
diff --git a/dart/frog/leg/apiimpl.dart b/dart/frog/leg/apiimpl.dart
index 9fa9b49dca6f32ab212572ddadb51392f547e1f1..4fcea25fe39aedcef917de830433b9f1aec08b30 100644
--- a/dart/frog/leg/apiimpl.dart
+++ b/dart/frog/leg/apiimpl.dart
@@ -16,8 +16,10 @@ class Compiler extends leg.Compiler {
ReadUriFromString provider;
DiagnosticHandler handler;
Uri libraryRoot;
+ List<String> options;
+ bool mockableLibraryUsed = false;
- Compiler(this.provider, this.handler, this.libraryRoot)
+ Compiler(this.provider, this.handler, this.libraryRoot, this.options)
: super.withCurrentDirectory(null, tracer: new ssa.HTracer());
leg.LibraryElement scanBuiltinLibrary(String filename) {
@@ -50,14 +52,17 @@ class Compiler extends leg.Compiler {
String uriName = uri.toString();
// TODO(ahe): Clean this up.
if (uriName == 'dart:dom') {
+ mockableLibraryUsed = true;
return libraryRoot.resolve('../../../client/dom/frog/dom_frog.dart');
} else if (uriName == 'dart:html') {
+ mockableLibraryUsed = true;
return libraryRoot.resolve('../../../client/html/frog/html_frog.dart');
} else if (uriName == 'dart:json') {
return libraryRoot.resolve('../../../lib/json/json.dart');
} else if (uriName == 'dart:isolate') {
return libraryRoot.resolve('../../../lib/isolate/isolate_leg.dart');
} else if (uriName == 'dart:io') {
+ mockableLibraryUsed = true;
return libraryRoot.resolve('io.dart');
} else if (uriName == 'dart:utf') {
return libraryRoot.resolve('../../../lib/utf/utf.dart');
@@ -82,4 +87,9 @@ class Compiler extends leg.Compiler {
handler(span.uri, span.begin, span.end, message, fatal);
}
}
+
+ bool get isMockCompilation() {
+ return mockableLibraryUsed
+ && (options.indexOf('--allow-mock-compilation') !== -1);
+ }
}

Powered by Google App Engine
This is Rietveld 408576698