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

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

Issue 2710313002: rework analyzer_cli to use ContextBuilder getAnalysisOptions (Closed)
Patch Set: remove commented code Created 3 years, 10 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/test/all.dart ('k') | pkg/analyzer_cli/test/data/flutter_analysis_options/lib/main.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer_cli/test/analysis_options_test.dart
diff --git a/pkg/analyzer_cli/test/analysis_options_test.dart b/pkg/analyzer_cli/test/analysis_options_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..5efb26a72a3f80d4f79363ef3b0bc98d79fb263a
--- /dev/null
+++ b/pkg/analyzer_cli/test/analysis_options_test.dart
@@ -0,0 +1,98 @@
+import 'dart:async';
+import 'dart:io';
+
+import 'package:analyzer_cli/src/driver.dart' show Driver, outSink, errorSink;
+import 'package:analyzer_cli/src/options.dart' show ExitHandler, exitHandler;
+import 'package:path/path.dart' as path;
+import 'package:test/test.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import 'utils.dart' show testDirectory, withTempDir;
+
+main() {
+ defineReflectiveTests(OptionsTest);
+}
+
+
+@reflectiveTest
+class OptionsTest {
+ _Runner runner;
+
+ void setUp() {
+ runner = new _Runner.setUp();
+ }
+
+ void tearDown() {
+ runner.tearDown();
+ runner = null;
+ }
+
+ test_options() async {
+ Future<Null> copy(FileSystemEntity src, String dstPath) async {
+ if (src is Directory) {
+ await (new Directory(dstPath)).create(recursive: true);
+ for (FileSystemEntity entity in src.listSync()) {
+ await copy(entity, path.join(dstPath, path.basename(entity.path)));
+ }
+ } else if (src is File) {
+ await src.copy(dstPath);
+ }
+ }
+
+ // Copy to temp dir so that existing analysis options
+ // in the test directory hierarchy do not interfere
+ var projDir = path.join(testDirectory, 'data', 'flutter_analysis_options');
+ await withTempDir((String tempDirPath) async {
+ await copy(new Directory(projDir), tempDirPath);
+ var expectedPath = path.join(tempDirPath, 'somepkgs', 'flutter', 'lib', 'analysis_options_user.yaml');
+ expect(FileSystemEntity.isFileSync(expectedPath), isTrue);
+ await runner.run2([
+ "--packages",
+ path.join(tempDirPath, 'packagelist'),
+ path.join(tempDirPath, 'lib', 'main.dart')
+ ]);
+ expect(runner.stdout, contains('The parameter \'child\' is required'));
+ // Should be a warning as specified in analysis_options_user.yaml
+ // not a hint
+ expect(runner.stdout, contains('1 warning found'));
+ });
+ }
+}
+
+class _Runner {
+ final _stdout = new StringBuffer();
+ final _stderr = new StringBuffer();
+
+ final StringSink _savedOutSink;
+ final StringSink _savedErrorSink;
+ final int _savedExitCode;
+ final ExitHandler _savedExitHandler;
+
+ _Runner.setUp()
+ : _savedOutSink = outSink,
+ _savedErrorSink = errorSink,
+ _savedExitHandler = exitHandler,
+ _savedExitCode = exitCode {
+ outSink = _stdout;
+ errorSink = _stderr;
+ exitHandler = (_) {};
+ }
+
+ String get stderr => _stderr.toString();
+
+ String get stdout => _stdout.toString();
+
+ Future<Null> run2(List<String> args) async {
+ await new Driver().start(args);
+ if (stderr.isNotEmpty) {
+ fail("Unexpected output to stderr:\n$stderr");
+ }
+ }
+
+ void tearDown() {
+ outSink = _savedOutSink;
+ errorSink = _savedErrorSink;
+ exitCode = _savedExitCode;
+ exitHandler = _savedExitHandler;
+ }
+}
« no previous file with comments | « pkg/analyzer_cli/test/all.dart ('k') | pkg/analyzer_cli/test/data/flutter_analysis_options/lib/main.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698