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

Unified Diff: pkg/analyzer_cli/test/driver_test.dart

Issue 1820233003: Respect `machineFormat` in package-mode. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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
« no previous file with comments | « pkg/analyzer_cli/lib/src/package_analyzer.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer_cli/test/driver_test.dart
diff --git a/pkg/analyzer_cli/test/driver_test.dart b/pkg/analyzer_cli/test/driver_test.dart
index 244788c174717685d6a90a69170657f627f9781f..7bf181a95e03854159dfbe86058f913638c51129 100644
--- a/pkg/analyzer_cli/test/driver_test.dart
+++ b/pkg/analyzer_cli/test/driver_test.dart
@@ -252,8 +252,7 @@ linter:
outSink.toString(),
contains(
"[error] This function declares a return type of 'int'"));
- expect(outSink.toString(),
- contains("1 error and 1 warning found."));
+ expect(outSink.toString(), contains("1 error and 1 warning found."));
});
test('language', () {
@@ -280,12 +279,29 @@ linter:
// Should not be made fatal by `--fatal-warnings`.
expect(outSink.toString(),
contains("[warning] The function 'baz' is not defined"));
- expect(outSink.toString(),
- contains("1 error and 1 warning found."));
+ expect(outSink.toString(), contains("1 error and 1 warning found."));
});
});
});
+ group('package-mode', () {
+ // Shared driver command.
+ var doDrive = () => drive('data/options_tests_project/test_file.dart',
+ args: [
+ '--dart-sdk',
+ findSdkDirForSummaries(),
+ '--package-mode',
+ '--machine'
+ ],
+ options: 'data/options_tests_project/.analysis_options');
+
+ test('no stats', () {
+ doDrive();
+ // Should not print stat summary.
+ expect(outSink.toString(), isEmpty);
+ });
+ });
+
//TODO(pq): fix to be bot-friendly (sdk#25258).
// group('in temp directory', () {
// Directory savedCurrentDirectory;
@@ -348,8 +364,6 @@ linter:
// });
// });
});
-
-
}
const emptyOptionsFile = 'data/empty_options.yaml';
@@ -360,9 +374,6 @@ Driver driver;
List<ErrorProcessor> get processors =>
driver.context.getConfigurationData(CONFIGURED_ERROR_PROCESSORS);
-ErrorProcessor processorFor(AnalysisError error) =>
- processors.firstWhere((p) => p.appliesTo(error));
-
/// Start a driver for the given [source], optionally providing additional
/// [args] and an [options] file path. The value of [options] defaults to
/// an empty options file to avoid unwanted configuration from an otherwise
@@ -378,9 +389,55 @@ void drive(String source,
driver.start(cmd);
}
+/// Try to find a appropriate directory to pass to "--dart-sdk" that will
+/// allow summaries to be found.
+String findSdkDirForSummaries() {
+ Set<String> triedDirectories = new Set<String>();
+ bool isSuitable(String sdkDir) {
+ triedDirectories.add(sdkDir);
+ return new File(path.join(sdkDir, 'lib', '_internal', 'spec.sum'))
+ .existsSync();
+ }
+ // Usually the sdk directory is the parent of the parent of the "dart"
+ // executable.
+ Directory executableParent = new File(Platform.executable).parent;
+ Directory executableGrandparent = executableParent.parent;
+ if (isSuitable(executableGrandparent.path)) {
+ return executableGrandparent.path;
+ }
+ // During buildbot execution, the sdk directory is simply the parent of the
+ // "dart" executable.
+ if (isSuitable(executableParent.path)) {
+ return executableParent.path;
+ }
+ // If neither of those are suitable, assume we are running locally within the
+ // SDK project (e.g. within an IDE). Find the build output directory and
+ // search all built configurations.
+ Directory sdkRootDir =
+ new File(Platform.script.toFilePath()).parent.parent.parent.parent;
+ for (String outDirName in ['out', 'xcodebuild']) {
+ Directory outDir = new Directory(path.join(sdkRootDir.path, outDirName));
+ if (outDir.existsSync()) {
+ for (FileSystemEntity subdir in outDir.listSync()) {
+ if (subdir is Directory) {
+ String candidateSdkDir = path.join(subdir.path, 'dart-sdk');
+ if (isSuitable(candidateSdkDir)) {
+ return candidateSdkDir;
+ }
+ }
+ }
+ }
+ }
+ throw new Exception('Could not find an SDK directory containing summaries.'
+ ' Tried: ${triedDirectories.toList()}');
+}
+
Map<String, YamlNode> parseOptions(String src) =>
new AnalysisOptionsProvider().getOptionsFromString(src);
+ErrorProcessor processorFor(AnalysisError error) =>
+ processors.firstWhere((p) => p.appliesTo(error));
+
class TestPlugin extends Plugin {
TestProcessor processor;
TestPlugin(this.processor);
« no previous file with comments | « pkg/analyzer_cli/lib/src/package_analyzer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698