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

Side by Side Diff: pkg/analyzer_cli/test/driver_test.dart

Issue 2963323002: Add analytics to analyzer-cli and analysis server. (Closed)
Patch Set: update from review comments Created 3 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer_cli.test.driver; 5 library analyzer_cli.test.driver;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import 'package:analyzer/error/error.dart'; 10 import 'package:analyzer/error/error.dart';
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 await drive('data/NO_DART_FILE_HERE.dart'); 104 await drive('data/NO_DART_FILE_HERE.dart');
105 expect(exitCode, 3); 105 expect(exitCode, 3);
106 }); 106 });
107 107
108 test('part file', () async { 108 test('part file', () async {
109 await drive('data/library_and_parts/part2.dart'); 109 await drive('data/library_and_parts/part2.dart');
110 expect(exitCode, 3); 110 expect(exitCode, 3);
111 }); 111 });
112 112
113 test('non-dangling part file', () async { 113 test('non-dangling part file', () async {
114 Driver driver = new Driver(); 114 Driver driver = new Driver(isTesting: true);
115 await driver.start([ 115 await driver.start([
116 path.join(testDirectory, 'data/library_and_parts/lib.dart'), 116 path.join(testDirectory, 'data/library_and_parts/lib.dart'),
117 path.join(testDirectory, 'data/library_and_parts/part1.dart') 117 path.join(testDirectory, 'data/library_and_parts/part1.dart')
118 ]); 118 ]);
119 expect(exitCode, 0); 119 expect(exitCode, 0);
120 }); 120 });
121 121
122 test('extra part file', () async { 122 test('extra part file', () async {
123 Driver driver = new Driver(); 123 Driver driver = new Driver(isTesting: true);
124 await driver.start([ 124 await driver.start([
125 path.join(testDirectory, 'data/library_and_parts/lib.dart'), 125 path.join(testDirectory, 'data/library_and_parts/lib.dart'),
126 path.join(testDirectory, 'data/library_and_parts/part1.dart'), 126 path.join(testDirectory, 'data/library_and_parts/part1.dart'),
127 path.join(testDirectory, 'data/library_and_parts/part2.dart') 127 path.join(testDirectory, 'data/library_and_parts/part2.dart')
128 ]); 128 ]);
129 expect(exitCode, 3); 129 expect(exitCode, 3);
130 }); 130 });
131 131
132 test('bazel workspace relative path', () async { 132 test('bazel workspace relative path', () async {
133 // Copy to temp dir so that existing analysis options 133 // Copy to temp dir so that existing analysis options
134 // in the test directory hierarchy do not interfere 134 // in the test directory hierarchy do not interfere
135 await withTempDirAsync((String tempDirPath) async { 135 await withTempDirAsync((String tempDirPath) async {
136 String dartSdkPath = path.absolute(getSdkPath()); 136 String dartSdkPath = path.absolute(getSdkPath());
137 await recursiveCopy( 137 await recursiveCopy(
138 new Directory(path.join(testDirectory, 'data', 'bazel')), 138 new Directory(path.join(testDirectory, 'data', 'bazel')),
139 tempDirPath); 139 tempDirPath);
140 Directory origWorkingDir = Directory.current; 140 Directory origWorkingDir = Directory.current;
141 try { 141 try {
142 Directory.current = path.join(tempDirPath, 'proj'); 142 Directory.current = path.join(tempDirPath, 'proj');
143 Driver driver = new Driver(); 143 Driver driver = new Driver(isTesting: true);
144 try { 144 try {
145 await driver.start([ 145 await driver.start([
146 path.join('lib', 'file.dart'), 146 path.join('lib', 'file.dart'),
147 '--dart-sdk', 147 '--dart-sdk',
148 dartSdkPath, 148 dartSdkPath,
149 ]); 149 ]);
150 } catch (e) { 150 } catch (e) {
151 print('=== debug info ==='); 151 print('=== debug info ===');
152 print('dartSdkPath: $dartSdkPath'); 152 print('dartSdkPath: $dartSdkPath');
153 print('stderr:\n${errorSink.toString()}'); 153 print('stderr:\n${errorSink.toString()}');
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 return '$uriPrefix${path.join(testDirectory, relativePath)}'; 544 return '$uriPrefix${path.join(testDirectory, relativePath)}';
545 } 545 }
546 546
547 /// Start a driver for the given [source], optionally providing additional 547 /// Start a driver for the given [source], optionally providing additional
548 /// [args] and an [options] file path. The value of [options] defaults to 548 /// [args] and an [options] file path. The value of [options] defaults to
549 /// an empty options file to avoid unwanted configuration from an otherwise 549 /// an empty options file to avoid unwanted configuration from an otherwise
550 /// discovered options file. 550 /// discovered options file.
551 Future<Null> drive(String source, 551 Future<Null> drive(String source,
552 {String options: emptyOptionsFile, 552 {String options: emptyOptionsFile,
553 List<String> args: const <String>[]}) async { 553 List<String> args: const <String>[]}) async {
554 driver = new Driver(); 554 driver = new Driver(isTesting: true);
555 var cmd = [ 555 var cmd = [
556 '--options', 556 '--options',
557 path.join(testDirectory, options), 557 path.join(testDirectory, options),
558 adjustFileSpec(source) 558 adjustFileSpec(source)
559 ]..addAll(args); 559 ]..addAll(args);
560 await driver.start(cmd); 560 await driver.start(cmd);
561 } 561 }
562 562
563 /// Try to find a appropriate directory to pass to "--dart-sdk" that will 563 /// Try to find a appropriate directory to pass to "--dart-sdk" that will
564 /// allow summaries to be found. 564 /// allow summaries to be found.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 612
613 /// Normalize text with bullets. 613 /// Normalize text with bullets.
614 String _bulletToDash(item) => '$item'.replaceAll('•', '-'); 614 String _bulletToDash(item) => '$item'.replaceAll('•', '-');
615 615
616 class TestSource implements Source { 616 class TestSource implements Source {
617 TestSource(); 617 TestSource();
618 618
619 @override 619 @override
620 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 620 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
621 } 621 }
OLDNEW
« no previous file with comments | « pkg/analyzer_cli/test/analysis_options_test.dart ('k') | pkg/analyzer_cli/test/embedder_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698