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

Unified Diff: lib/src/analysis.dart

Issue 1415723007: SDK mocking for improved test throughput. (Closed) Base URL: https://github.com/dart-lang/linter.git@master
Patch Set: Created 5 years, 1 month 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 | « no previous file | lib/src/linter.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/analysis.dart
diff --git a/lib/src/analysis.dart b/lib/src/analysis.dart
index a6bf01c26a994b9b3f45839a77a2b7b319168e0c..0cd13a3b0011a0cb69084e2c9f7a70eb51f504b0 100644
--- a/lib/src/analysis.dart
+++ b/lib/src/analysis.dart
@@ -25,6 +25,7 @@ import 'package:linter/src/io.dart';
import 'package:linter/src/linter.dart';
import 'package:linter/src/project.dart';
import 'package:linter/src/rules.dart';
+import 'package:linter/src/sdk.dart';
import 'package:package_config/packages.dart' show Packages;
import 'package:package_config/packages_file.dart' as pkgfile show parse;
import 'package:package_config/src/packages_impl.dart' show MapPackages;
@@ -62,8 +63,12 @@ class AnalysisDriver {
int get numSourcesAnalyzed => _sourcesAnalyzed.length;
List<UriResolver> get resolvers {
- DartSdk sdk = new DirectoryBasedDartSdk(new JavaFile(sdkDir));
+ DartSdk sdk = options.useMockSdk
+ ? new MockSdk()
+ : new DirectoryBasedDartSdk(new JavaFile(sdkDir));
+
List<UriResolver> resolvers = [new DartUriResolver(sdk)];
+
if (options.packageRootPath != null) {
JavaFile packageDirectory = new JavaFile(options.packageRootPath);
resolvers.add(new PackageUriResolver([packageDirectory]));
@@ -78,6 +83,7 @@ class AnalysisDriver {
PhysicalResourceProvider.INSTANCE, packageMap));
}
}
+
// File URI resolver must come last so that files inside "/lib" are
// are analyzed via "package:" URI's.
resolvers.add(new FileUriResolver());
@@ -211,16 +217,19 @@ class DriverOptions {
/// The path to the package root.
String packageRootPath;
+ /// If non-null, the function to use to run pub list. This is used to mock
+ /// out executions of pub list when testing the linter.
+ RunPubList runPubList = null;
+
/// Whether to show SDK warnings.
bool showSdkWarnings = false;
+ /// Whether to use a mock SDK (to speed up testing).
+ bool useMockSdk = false;
+
/// Whether to show lints for the transitive closure of imported and exported
/// libraries.
bool visitTransitiveClosure = false;
-
- /// If non-null, the function to use to run pub list. This is used to mock
- /// out executions of pub list when testing the linter.
- RunPubList runPubList = null;
}
/// Prints logging information comments to the [outSink] and error messages to
« no previous file with comments | « no previous file | lib/src/linter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698